@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,141 @@
|
|
|
1
|
+
// asks.mjs — the ask rules (docs/tasks/asks/README.md), one parser for
|
|
2
|
+
// the session brief and the pre-commit hook. Ported from
|
|
3
|
+
// project-wildshard-singleplayer's scripts/asks.mjs.
|
|
4
|
+
//
|
|
5
|
+
// node src/scripts/asks.mjs brief asks still open: expired claims, picks for Jake
|
|
6
|
+
// node src/scripts/asks.mjs check pre-commit: every staged ask file follows the rules
|
|
7
|
+
//
|
|
8
|
+
// An ask is a receipt of Jake's words. Follow-up work is a plan row.
|
|
9
|
+
import { spawnSync } from 'node:child_process'
|
|
10
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs'
|
|
11
|
+
import { basename, resolve } from 'node:path'
|
|
12
|
+
import { pathToFileURL } from 'node:url'
|
|
13
|
+
|
|
14
|
+
const ROOT = resolve(import.meta.dirname, '..', '..')
|
|
15
|
+
const ASKS = 'docs/tasks/asks'
|
|
16
|
+
const PLANS = 'docs/plans'
|
|
17
|
+
const LEASE_HOURS = 71 // a claim with no commit touching it for 71 h has expired
|
|
18
|
+
|
|
19
|
+
/** The Status vocabulary. `folded into` / `superseded by` name the ask or plan that carries the work. */
|
|
20
|
+
export const STATES = ['open', 'in flight', 'needs pick', 'done', 'dropped', 'folded into', 'superseded by']
|
|
21
|
+
const CLOSED = new Set(['done', 'dropped', 'folded into', 'superseded by'])
|
|
22
|
+
|
|
23
|
+
/** @param {string[]} args */
|
|
24
|
+
const git = (...args) => {
|
|
25
|
+
const r = spawnSync('git', args, { cwd: ROOT, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 })
|
|
26
|
+
return r.status === 0 ? r.stdout : ''
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** @param {string} text */
|
|
30
|
+
export function parseAsk(text) {
|
|
31
|
+
const status = /^\*\*Status:\*\* *(.*)$/mu.exec(text)?.[1]?.trim() ?? ''
|
|
32
|
+
const lower = status.toLowerCase()
|
|
33
|
+
const state = STATES.find(s => lower.startsWith(s)) ?? null
|
|
34
|
+
const date = /(\d{4}-\d{2}-\d{2})/u.exec(status)?.[1] ?? null
|
|
35
|
+
const target =
|
|
36
|
+
state === 'folded into' || state === 'superseded by'
|
|
37
|
+
? (/^(?:folded into|superseded by) +([A-Za-z][A-Za-z0-9_-]*)/iu.exec(status)?.[1] ?? null)
|
|
38
|
+
: null
|
|
39
|
+
return {
|
|
40
|
+
title: /^# (\S+)/u.exec(text)?.[1] ?? null,
|
|
41
|
+
status,
|
|
42
|
+
state,
|
|
43
|
+
closed: state !== null && CLOSED.has(state),
|
|
44
|
+
date,
|
|
45
|
+
target,
|
|
46
|
+
ask: /^\*\*Ask:\*\* *(.*)$/mu.exec(text)?.[1]?.trim() ?? '',
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A target exists: an ask, a live plan, or a plan archived as project/archive/<date>-<name>.md. */
|
|
51
|
+
/** @param {string} target */
|
|
52
|
+
export function targetExists(target, root = ROOT) {
|
|
53
|
+
if (existsSync(resolve(root, ASKS, `${target}.md`))) return true
|
|
54
|
+
if (existsSync(resolve(root, PLANS, `${target}.md`))) return true
|
|
55
|
+
const archive = resolve(root, 'project/archive')
|
|
56
|
+
if (!existsSync(archive)) return false
|
|
57
|
+
const name = target.toLowerCase()
|
|
58
|
+
return readdirSync(archive).some(f => f.toLowerCase().endsWith(`-${name}.md`) || f.toLowerCase() === `${name}.md`)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Every rule an ask file must pass.
|
|
63
|
+
* @param {string} id
|
|
64
|
+
* @param {string} text
|
|
65
|
+
* @returns {string[]} problems; empty when it passes
|
|
66
|
+
*/
|
|
67
|
+
export function checkAsk(id, text, exists = targetExists) {
|
|
68
|
+
const a = parseAsk(text)
|
|
69
|
+
const out = []
|
|
70
|
+
if (a.title !== id) out.push(`first line must be "# ${id}" (create asks with src/scripts/ask-new.sh)`)
|
|
71
|
+
if (!a.status) out.push('no **Status:** line')
|
|
72
|
+
if (!a.ask) out.push("no **Ask:** line (Jake's words)")
|
|
73
|
+
if (a.status && a.state === null) {
|
|
74
|
+
out.push(`Status "${a.status.slice(0, 40)}" is not one of: ${STATES.join(' / ')}`)
|
|
75
|
+
}
|
|
76
|
+
if (a.state === 'in flight' && !/^in flight \(\d{4}-\d{2}-\d{2}, *[^)]+\)/u.test(a.status)) {
|
|
77
|
+
out.push('in flight needs its claim: "in flight (YYYY-MM-DD, <owner>)"')
|
|
78
|
+
}
|
|
79
|
+
if ((a.state === 'open' || a.state === 'needs pick' || a.state === 'done') && !a.date) {
|
|
80
|
+
out.push(`${a.state} needs its date: "${a.state} (YYYY-MM-DD)"`)
|
|
81
|
+
}
|
|
82
|
+
if ((a.state === 'folded into' || a.state === 'superseded by') && (a.target === null || !exists(a.target))) {
|
|
83
|
+
out.push(`"${a.state}" must name an existing ask (A12) or plan (a-plan-slug)`)
|
|
84
|
+
}
|
|
85
|
+
return out
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function check() {
|
|
89
|
+
const staged = git('diff', '--cached', '--name-only', '--diff-filter=AM', '-z')
|
|
90
|
+
.split('\0')
|
|
91
|
+
.filter(p => p.startsWith(`${ASKS}/`) && p.endsWith('.md') && !p.endsWith('/README.md'))
|
|
92
|
+
let bad = 0
|
|
93
|
+
for (const p of staged) {
|
|
94
|
+
const problems = checkAsk(basename(p, '.md'), git('show', `:${p}`))
|
|
95
|
+
for (const m of problems) console.error(` ${p}: ${m}`)
|
|
96
|
+
bad += problems.length
|
|
97
|
+
}
|
|
98
|
+
if (bad > 0) {
|
|
99
|
+
console.error('\n X commit blocked: ask file breaks the rules in docs/tasks/asks/README.md.\n')
|
|
100
|
+
process.exitCode = 1
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** @param {string} from */
|
|
105
|
+
const days = (from, to = Date.now()) => (to - Date.parse(`${from}T00:00:00Z`)) / 86_400_000
|
|
106
|
+
|
|
107
|
+
function brief() {
|
|
108
|
+
const dir = resolve(ROOT, ASKS)
|
|
109
|
+
const files = existsSync(dir) ? readdirSync(dir).filter(n => /^[A-Z]+\d+\.md$/u.test(n)) : []
|
|
110
|
+
const now = Date.now()
|
|
111
|
+
const rows = []
|
|
112
|
+
for (const f of files.sort((x, y) => x.localeCompare(y, 'en', { numeric: true }))) {
|
|
113
|
+
const a = parseAsk(readFileSync(resolve(dir, f), 'utf8'))
|
|
114
|
+
if (a.closed) continue
|
|
115
|
+
let flag = ''
|
|
116
|
+
if (a.state === 'in flight') {
|
|
117
|
+
const committed = Number(git('log', '-1', '--format=%ct', '--', `${ASKS}/${f}`).trim()) * 1000
|
|
118
|
+
const last = Math.max(a.date ? Date.parse(`${a.date}T23:59:59Z`) : 0, committed)
|
|
119
|
+
if ((now - last) / 3_600_000 > LEASE_HOURS) {
|
|
120
|
+
flag = ` !! CLAIM EXPIRED (no commit in ${LEASE_HOURS} h): anyone may take it`
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (a.state === 'needs pick') {
|
|
124
|
+
const open = a.date ? ` (open ${Math.floor(days(a.date, now))} d)` : ''
|
|
125
|
+
flag = ` !! ASK JAKE with the question tool${open}: a pick never expires`
|
|
126
|
+
}
|
|
127
|
+
if (a.state === null) flag = ' !! Status outside the vocabulary (docs/tasks/asks/README.md)'
|
|
128
|
+
rows.push(` ${basename(f, '.md')} | ${a.status.slice(0, 80)}${flag} | ${a.ask.slice(0, 100)}`)
|
|
129
|
+
}
|
|
130
|
+
console.log(rows.length > 0 ? rows.join('\n') : ' (none)')
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
|
134
|
+
const [mode] = process.argv.slice(2)
|
|
135
|
+
if (mode === 'check') check()
|
|
136
|
+
else if (mode === 'brief') brief()
|
|
137
|
+
else {
|
|
138
|
+
console.error('usage: node src/scripts/asks.mjs brief | check')
|
|
139
|
+
process.exitCode = 2
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# herdr-prompt.sh: a herdr write, sent only when its target is clear.
|
|
3
|
+
#
|
|
4
|
+
# herdr-prompt.sh <agent> <message> [options] herdr agent prompt
|
|
5
|
+
# herdr-prompt.sh agent prompt|send-keys <target> ...
|
|
6
|
+
# herdr-prompt.sh pane send-text|send-keys|run <pane> ...
|
|
7
|
+
#
|
|
8
|
+
# It asks herdr-question-open.sh (beside it) first and writes only on its
|
|
9
|
+
# "clear" answer. A blocked or unavailable target, an unresolved one, or
|
|
10
|
+
# a missing or non-executable helper refuses with exit 3, so the message
|
|
11
|
+
# never answers Jake's question. Codex lanes call this; Claude lanes get
|
|
12
|
+
# the same check from the PreToolUse guard guard-herdr-prompt.sh, which
|
|
13
|
+
# asks the same helper. Exit 2 is usage.
|
|
14
|
+
set -uo pipefail
|
|
15
|
+
|
|
16
|
+
usage() { echo "usage: herdr-prompt.sh <agent> <message> | agent prompt|send-keys <target> ... | pane send-text|send-keys|run <pane> ..." >&2; exit 2; }
|
|
17
|
+
case "${1:-} ${2:-}" in
|
|
18
|
+
"agent prompt" | "agent send-keys" | "pane send-text" | "pane send-keys" | "pane run")
|
|
19
|
+
group="$1" verb="$2"; shift 2 ;;
|
|
20
|
+
*) group=agent verb=prompt ;;
|
|
21
|
+
esac
|
|
22
|
+
target="${1:-}"
|
|
23
|
+
[ -n "$target" ] && [ $# -ge 2 ] || usage
|
|
24
|
+
shift
|
|
25
|
+
|
|
26
|
+
check="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/herdr-question-open.sh"
|
|
27
|
+
refuse() { echo "herdr-prompt: not sent: $1. Put it in STATE.md or a commit message instead, or retry later." >&2; exit 3; }
|
|
28
|
+
[ -f "$check" ] && [ -x "$check" ] || refuse "$check is missing or not executable, so $target cannot be checked"
|
|
29
|
+
why="$("$check" "$target" 2>&1)" && rc=0 || rc=$?
|
|
30
|
+
case "$rc:$why" in
|
|
31
|
+
1:clear*) ;;
|
|
32
|
+
*) refuse "${why:-herdr-question-open.sh exited $rc}" ;;
|
|
33
|
+
esac
|
|
34
|
+
exec herdr "$group" "$verb" "$target" "$@"
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# herdr-question-open.sh <agent|pane>: may a herdr write go to that target now?
|
|
3
|
+
#
|
|
4
|
+
# A herdr paste into a pane that has a question open (Claude's
|
|
5
|
+
# AskUserQuestion, a Codex question, an approval prompt) lands in the
|
|
6
|
+
# answer field and picks for Jake (Jake, 2026-10-12, G232/G233). Read
|
|
7
|
+
# before write: the PreToolUse guard (guard-herdr-prompt.sh) and the
|
|
8
|
+
# wrapper (herdr-prompt.sh) both ask this script before any herdr
|
|
9
|
+
# write, so both refuse the same targets.
|
|
10
|
+
#
|
|
11
|
+
# It prints one line and exits:
|
|
12
|
+
# 1 "clear: ..." the target resolves, its status and screen
|
|
13
|
+
# were read, and no question is open. Exit 1
|
|
14
|
+
# with "clear" is the only answer that permits
|
|
15
|
+
# a write.
|
|
16
|
+
# 0 "blocked: ..." a question or approval prompt is open.
|
|
17
|
+
# 3 "unavailable: ..." the target does not resolve to an agent or
|
|
18
|
+
# pane, or herdr, jq, its status or its screen
|
|
19
|
+
# could not be read. Not knowing is not clear.
|
|
20
|
+
# 2 usage.
|
|
21
|
+
# Exit 0 keeps the old "a question is open" meaning for `if` callers.
|
|
22
|
+
set -uo pipefail
|
|
23
|
+
|
|
24
|
+
target="${1:-}"
|
|
25
|
+
[ -n "$target" ] && [ $# -eq 1 ] || { echo "usage: herdr-question-open.sh <agent|pane>" >&2; exit 2; }
|
|
26
|
+
|
|
27
|
+
say() { printf '%s\n' "$2"; exit "$1"; }
|
|
28
|
+
unavailable() { say 3 "unavailable: $target $1"; }
|
|
29
|
+
|
|
30
|
+
command -v herdr >/dev/null 2>&1 || unavailable "cannot be inspected: herdr is not on PATH"
|
|
31
|
+
command -v jq >/dev/null 2>&1 || unavailable "cannot be inspected: jq is not on PATH"
|
|
32
|
+
|
|
33
|
+
# Resolve: an agent name or pane id through `agent get`, then a plain
|
|
34
|
+
# pane through `pane get`. Only *_not_found from both means unresolved.
|
|
35
|
+
info="" codes=""
|
|
36
|
+
for kind in agent pane; do
|
|
37
|
+
out="$(herdr "$kind" get "$target" 2>/dev/null)" && rc=0 || rc=$?
|
|
38
|
+
if [ "$rc" -eq 0 ]; then
|
|
39
|
+
info="$(printf '%s' "$out" | jq -ce ".result.$kind | objects" 2>/dev/null)" || info=""
|
|
40
|
+
[ -n "$info" ] && break
|
|
41
|
+
unavailable "could not be read: herdr $kind get gave no $kind status"
|
|
42
|
+
else
|
|
43
|
+
# herdr prints its error JSON on stderr; read it again with both streams.
|
|
44
|
+
code="$(herdr "$kind" get "$target" 2>&1 | jq -r '.error.code // empty' 2>/dev/null | head -n 1)"
|
|
45
|
+
codes="$codes $kind:${code:-exit-$rc}"
|
|
46
|
+
fi
|
|
47
|
+
done
|
|
48
|
+
if [ -z "$info" ]; then
|
|
49
|
+
case "$codes" in
|
|
50
|
+
" agent:agent_not_found pane:pane_not_found") unavailable "does not resolve to a herdr agent or pane" ;;
|
|
51
|
+
*) unavailable "could not be read (herdr:$codes)" ;;
|
|
52
|
+
esac
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
pane="$(printf '%s' "$info" | jq -r '.pane_id // empty')"
|
|
56
|
+
[ -n "$pane" ] || unavailable "resolved without a pane id"
|
|
57
|
+
# A pane running an agent must report its status; a plain shell pane has none.
|
|
58
|
+
has_agent="$(printf '%s' "$info" | jq -r 'if (.agent // null) == null then "no" else "yes" end')"
|
|
59
|
+
status="$(printf '%s' "$info" | jq -r '.agent_status // empty')"
|
|
60
|
+
[ "$has_agent" = no ] || [ -n "$status" ] || unavailable "($pane) has an agent but no readable status"
|
|
61
|
+
[ "$status" = blocked ] && say 0 "blocked: $target ($pane) is blocked (herdr sees a question or approval prompt open)"
|
|
62
|
+
|
|
63
|
+
screen="$(herdr pane read "$pane" --source visible 2>/dev/null)" || unavailable "($pane): its screen could not be read"
|
|
64
|
+
if printf '%s' "$screen" | grep -qE 'Enter to select|to navigate|Skip for now|Type something\.|\? [0-9]+ questions?|Do you want to proceed\?'; then
|
|
65
|
+
say 0 "blocked: $target ($pane) is showing a question on screen"
|
|
66
|
+
fi
|
|
67
|
+
say 1 "clear: $target ($pane) is ${status:-a plain pane} with no question on screen"
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// md-wrap.mjs — markdown prose wraps at 72 characters (Jake's norm;
|
|
2
|
+
// ported from kami-kakushi's md-wrap, written fresh for greenroom).
|
|
3
|
+
//
|
|
4
|
+
// node src/scripts/md-wrap.mjs <file...> reflow long prose in place
|
|
5
|
+
// node src/scripts/md-wrap.mjs --check [--new-only] <file...> list long prose lines (exit 1)
|
|
6
|
+
//
|
|
7
|
+
// --new-only reports only lines added vs HEAD (an untracked file counts
|
|
8
|
+
// whole), so touching one line of an old doc doesn't flag its history.
|
|
9
|
+
// Exempt everywhere: front matter, code fences, tables, headings, HTML,
|
|
10
|
+
// block quotes, and lines whose overflow can't be broken (one long token
|
|
11
|
+
// such as a URL, or an `inline code` span, which is never split). Reflow rewraps only paragraphs and list items that
|
|
12
|
+
// hold a long line, keeping list markers and indentation.
|
|
13
|
+
import { spawnSync } from 'node:child_process'
|
|
14
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
15
|
+
import { pathToFileURL } from 'node:url'
|
|
16
|
+
import { resolve } from 'node:path'
|
|
17
|
+
|
|
18
|
+
export const WIDTH = 72
|
|
19
|
+
const segmenter = new Intl.Segmenter('en', { granularity: 'grapheme' })
|
|
20
|
+
/** @param {string} text */
|
|
21
|
+
export const width = text => Array.from(segmenter.segment(text)).length
|
|
22
|
+
|
|
23
|
+
const FENCE = /^\s*(```|~~~)/u
|
|
24
|
+
const ITEM = /^(\s*)([-*+]|\d+[.)])(\s+)(\[[ xX]\]\s+)?/u
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Classify every line: 'prose' lines may wrap; everything else is left alone.
|
|
28
|
+
* @param {string[]} lines
|
|
29
|
+
* @returns {('prose' | 'item' | 'skip' | 'blank')[]}
|
|
30
|
+
*/
|
|
31
|
+
export function classify(lines) {
|
|
32
|
+
const kinds = []
|
|
33
|
+
let fence = false
|
|
34
|
+
let front = lines[0] === '---'
|
|
35
|
+
for (const [i, line] of lines.entries()) {
|
|
36
|
+
if (front) {
|
|
37
|
+
kinds.push('skip')
|
|
38
|
+
if (i > 0 && line === '---') front = false
|
|
39
|
+
continue
|
|
40
|
+
}
|
|
41
|
+
if (FENCE.test(line)) {
|
|
42
|
+
fence = !fence
|
|
43
|
+
kinds.push('skip')
|
|
44
|
+
continue
|
|
45
|
+
}
|
|
46
|
+
const trimmed = line.trim()
|
|
47
|
+
if (fence) kinds.push('skip')
|
|
48
|
+
else if (trimmed === '') kinds.push('blank')
|
|
49
|
+
else if (/^(#|\||<|>|---+$|\*\*\*+$|\[[^\]]+\]:)/u.test(trimmed)) kinds.push('skip')
|
|
50
|
+
else if (/^ {4,}\S/u.test(line) && kinds.at(-1) === 'blank' && !isInsideList(kinds, lines)) kinds.push('skip')
|
|
51
|
+
else if (ITEM.test(line)) kinds.push('item')
|
|
52
|
+
else kinds.push('prose')
|
|
53
|
+
}
|
|
54
|
+
return kinds
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** An indented block right after a blank line is code unless we are inside a list. */
|
|
58
|
+
function isInsideList(kinds, lines) {
|
|
59
|
+
for (let i = kinds.length - 1; i >= 0; i--) {
|
|
60
|
+
if (kinds[i] === 'item') return true
|
|
61
|
+
if (kinds[i] === 'blank' || /^\s/u.test(lines[i])) continue
|
|
62
|
+
return false
|
|
63
|
+
}
|
|
64
|
+
return false
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The text a line starts with that must stay put (indent, list marker, checkbox). */
|
|
68
|
+
function prefixOf(line) {
|
|
69
|
+
const item = ITEM.exec(line)
|
|
70
|
+
if (item) return item[0]
|
|
71
|
+
return /^\s*/u.exec(line)?.[0] ?? ''
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Split prose into words on spaces, keeping each `inline code` span whole
|
|
76
|
+
* (a command split across lines can't be copied).
|
|
77
|
+
* @param {string} body
|
|
78
|
+
*/
|
|
79
|
+
export function tokens(body) {
|
|
80
|
+
const out = []
|
|
81
|
+
let current = ''
|
|
82
|
+
let code = false
|
|
83
|
+
for (const char of body) {
|
|
84
|
+
if (char === '`') code = !code
|
|
85
|
+
if (char === ' ' && !code) {
|
|
86
|
+
if (current) out.push(current)
|
|
87
|
+
current = ''
|
|
88
|
+
} else {
|
|
89
|
+
current += char
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (current) out.push(current)
|
|
93
|
+
return out
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** A long line can be wrapped only if its first word (after the prefix) fits and another follows. */
|
|
97
|
+
export function breakable(line) {
|
|
98
|
+
const prefix = prefixOf(line)
|
|
99
|
+
const words = tokens(line.slice(prefix.length))
|
|
100
|
+
return words.length > 1 && width(prefix) + width(words[0]) <= WIDTH
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Long prose lines, 1-based.
|
|
105
|
+
* @param {string} text
|
|
106
|
+
* @param {Set<number> | null} only line numbers to report (null = all)
|
|
107
|
+
*/
|
|
108
|
+
export function findLong(text, only = null) {
|
|
109
|
+
const lines = text.split('\n')
|
|
110
|
+
const kinds = classify(lines)
|
|
111
|
+
const found = []
|
|
112
|
+
for (const [i, line] of lines.entries()) {
|
|
113
|
+
if (only && !only.has(i + 1)) continue
|
|
114
|
+
if ((kinds[i] === 'prose' || kinds[i] === 'item') && width(line) > WIDTH && breakable(line)) {
|
|
115
|
+
found.push({ line: i + 1, width: width(line) })
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return found
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Greedy wrap of words under a first-line prefix and a continuation indent. */
|
|
122
|
+
function wrap(words, first, rest) {
|
|
123
|
+
const out = []
|
|
124
|
+
let current = first
|
|
125
|
+
let empty = true
|
|
126
|
+
for (const word of words) {
|
|
127
|
+
const candidate = empty ? current + word : `${current} ${word}`
|
|
128
|
+
if (!empty && width(candidate) > WIDTH) {
|
|
129
|
+
out.push(current)
|
|
130
|
+
current = rest + word
|
|
131
|
+
} else {
|
|
132
|
+
current = candidate
|
|
133
|
+
}
|
|
134
|
+
empty = false
|
|
135
|
+
}
|
|
136
|
+
out.push(current)
|
|
137
|
+
return out
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Rewrap paragraphs and list items that contain a long, breakable line. */
|
|
141
|
+
export function reflow(text) {
|
|
142
|
+
const lines = text.split('\n')
|
|
143
|
+
const kinds = classify(lines)
|
|
144
|
+
const out = []
|
|
145
|
+
let i = 0
|
|
146
|
+
while (i < lines.length) {
|
|
147
|
+
if (kinds[i] !== 'prose' && kinds[i] !== 'item') {
|
|
148
|
+
out.push(lines[i])
|
|
149
|
+
i += 1
|
|
150
|
+
continue
|
|
151
|
+
}
|
|
152
|
+
// A block: this line plus continuation prose lines (not a new item,
|
|
153
|
+
// not after a hard break). Items continue only with indented lines.
|
|
154
|
+
const start = i
|
|
155
|
+
const first = prefixOf(lines[i])
|
|
156
|
+
const indent = kinds[i] === 'item' ? ' '.repeat(width(first)) : first
|
|
157
|
+
let end = i + 1
|
|
158
|
+
while (
|
|
159
|
+
end < lines.length &&
|
|
160
|
+
kinds[end] === 'prose' &&
|
|
161
|
+
!/( {2}|\\)$/u.test(lines[end - 1]) &&
|
|
162
|
+
(kinds[start] !== 'item' || /^\s/u.test(lines[end]))
|
|
163
|
+
) {
|
|
164
|
+
end += 1
|
|
165
|
+
}
|
|
166
|
+
const block = lines.slice(start, end)
|
|
167
|
+
const needs = block.some(line => width(line) > WIDTH && breakable(line))
|
|
168
|
+
if (!needs) {
|
|
169
|
+
out.push(...block)
|
|
170
|
+
} else {
|
|
171
|
+
const hardBreak = /( {2}|\\)$/u.exec(block.at(-1))?.[0] ?? ''
|
|
172
|
+
const joined = block
|
|
173
|
+
.map((line, n) => (n === 0 ? line.slice(first.length) : line.trim()))
|
|
174
|
+
.join(' ')
|
|
175
|
+
.trim()
|
|
176
|
+
const words = tokens(joined)
|
|
177
|
+
const wrapped = wrap(words, first, indent)
|
|
178
|
+
if (hardBreak) wrapped[wrapped.length - 1] += hardBreak
|
|
179
|
+
out.push(...wrapped)
|
|
180
|
+
}
|
|
181
|
+
i = end
|
|
182
|
+
}
|
|
183
|
+
return out.join('\n')
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Line numbers added vs HEAD; null = the whole file is new. */
|
|
187
|
+
function addedLines(file) {
|
|
188
|
+
const tracked = spawnSync('git', ['ls-files', '--error-unmatch', '--', file], { encoding: 'utf8' })
|
|
189
|
+
if (tracked.status !== 0) return null
|
|
190
|
+
const diff = spawnSync('git', ['diff', '-U0', 'HEAD', '--', file], { encoding: 'utf8' }).stdout ?? ''
|
|
191
|
+
const added = new Set()
|
|
192
|
+
for (const match of diff.matchAll(/^@@ -\S+ \+(\d+)(?:,(\d+))? @@/gmu)) {
|
|
193
|
+
const from = Number(match[1])
|
|
194
|
+
const count = match[2] === undefined ? 1 : Number(match[2])
|
|
195
|
+
for (let n = from; n < from + count; n++) added.add(n)
|
|
196
|
+
}
|
|
197
|
+
return added
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function main(argv) {
|
|
201
|
+
const check = argv.includes('--check')
|
|
202
|
+
const newOnly = argv.includes('--new-only')
|
|
203
|
+
const files = argv.filter(arg => !arg.startsWith('--'))
|
|
204
|
+
if (!files.length) {
|
|
205
|
+
console.error('usage: node src/scripts/md-wrap.mjs [--check [--new-only]] <file.md...>')
|
|
206
|
+
return 2
|
|
207
|
+
}
|
|
208
|
+
let status = 0
|
|
209
|
+
for (const file of files) {
|
|
210
|
+
if (!existsSync(file)) continue
|
|
211
|
+
const text = readFileSync(file, 'utf8')
|
|
212
|
+
if (check) {
|
|
213
|
+
const long = findLong(text, newOnly ? addedLines(file) : null)
|
|
214
|
+
for (const { line, width: w } of long) console.log(` ${file}:${line}: ${w} chars (> ${WIDTH})`)
|
|
215
|
+
if (long.length) status = 1
|
|
216
|
+
} else {
|
|
217
|
+
const next = reflow(text)
|
|
218
|
+
if (next !== text) {
|
|
219
|
+
writeFileSync(file, next)
|
|
220
|
+
console.log(`rewrapped ${file}`)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return status
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
|
228
|
+
process.exitCode = main(process.argv.slice(2))
|
|
229
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Hono } from 'hono'
|
|
2
|
+
|
|
3
|
+
import type { Health } from '../shared/health.ts'
|
|
4
|
+
import type { Context } from 'hono'
|
|
5
|
+
|
|
6
|
+
interface AppOptions {
|
|
7
|
+
readonly version: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function createApp(options: AppOptions): Hono {
|
|
11
|
+
const app = new Hono()
|
|
12
|
+
|
|
13
|
+
app.get('/api/health', (context: Context): Response => {
|
|
14
|
+
const body: Health = { ok: true, version: options.version }
|
|
15
|
+
return context.json(body)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
return app
|
|
19
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { once } from 'node:events'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
|
|
4
|
+
import { serve as serveNode } from '@hono/node-server'
|
|
5
|
+
import { serveStatic } from '@hono/node-server/serve-static'
|
|
6
|
+
|
|
7
|
+
import { createApp } from './app.ts'
|
|
8
|
+
|
|
9
|
+
// The built web app, if this repo has one: src/dist/web (src/tools/build-web.ts).
|
|
10
|
+
const WEB_ROOT = fileURLToPath(new URL('../dist/web', import.meta.url))
|
|
11
|
+
|
|
12
|
+
const LOOPBACK_HOST = '127.0.0.1'
|
|
13
|
+
|
|
14
|
+
interface ServeOptions {
|
|
15
|
+
readonly port: number
|
|
16
|
+
readonly version: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface RunningServer {
|
|
20
|
+
readonly url: string
|
|
21
|
+
readonly close: () => Promise<void>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function serve(options: ServeOptions): Promise<RunningServer> {
|
|
25
|
+
const app = createApp({ version: options.version })
|
|
26
|
+
app.use('/*', serveStatic({ root: WEB_ROOT }))
|
|
27
|
+
app.get('/*', serveStatic({ root: WEB_ROOT, path: 'index.html' }))
|
|
28
|
+
|
|
29
|
+
const server = serveNode({
|
|
30
|
+
fetch: app.fetch,
|
|
31
|
+
hostname: LOOPBACK_HOST,
|
|
32
|
+
port: options.port,
|
|
33
|
+
})
|
|
34
|
+
await once(server, 'listening')
|
|
35
|
+
|
|
36
|
+
const address = server.address()
|
|
37
|
+
if (address === null || typeof address === 'string') {
|
|
38
|
+
throw new Error('sharddev: server is not listening on a TCP port')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
url: `http://${LOOPBACK_HOST}:${String(address.port)}`,
|
|
43
|
+
close: async (): Promise<void> => {
|
|
44
|
+
const closed = once(server, 'close')
|
|
45
|
+
server.close()
|
|
46
|
+
await closed
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SHARDFILE_ADMISSION_LIMITS as gameLimits } from '@wildshard/format/admissionLimits';
|
|
2
|
+
import { preflightShardfile as preflight } from '@wildshard/format/preflight';
|
|
3
|
+
|
|
4
|
+
/** Shared source, collection, identifier, text and distinct wire ceilings for author output and client intake. */
|
|
5
|
+
export const SHARDFILE_ADMISSION_LIMITS: Readonly<{ sourceBytes: 2000000; files: 4096; commons: 1024; stateFields: 128; waterBodies: 64; idCharacters: 128; textCharacters: 4096; wireBytes: 256000000; }> = Object.freeze({ ...gameLimits });
|
|
6
|
+
/** Check bounded plain JSON and declared wire totals before opening any immutable asset. Full validation follows separately. */
|
|
7
|
+
export function preflightShardfile(input: unknown): void { preflight(input); }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ARENA_VIEW as view, arenaFunnel as funnel, arenaChainTell as chainTell } from '@wildshard/format/arenaView';
|
|
2
|
+
import type { ArenaWhirlsRows as Whirls } from '@wildshard/format/encounterRows';
|
|
3
|
+
import type { ViewProgramRows } from '@wildshard/format/viewProgram';
|
|
4
|
+
|
|
5
|
+
/** Complete native view-bank declaration before a scoped runtime host is installed. */
|
|
6
|
+
export type AuthorViewProgramRows = ViewProgramRows;
|
|
7
|
+
|
|
8
|
+
/** Fixed numeric arena presentation defaults shared with the runtime's declared view host. */
|
|
9
|
+
export const ARENA_VIEW: typeof view = view;
|
|
10
|
+
/** Admitted numeric arena whirl metadata; no live view or fight bindings. */
|
|
11
|
+
export type ArenaWhirlsRows = Whirls;
|
|
12
|
+
/** Construct the defining arena funnel rows without installing a rendering service. */
|
|
13
|
+
export function arenaFunnel(...args: Parameters<typeof funnel>): ReturnType<typeof funnel> { return funnel(...args); }
|
|
14
|
+
/** Resolve the defining arena chain's tell label in original ordinal order. */
|
|
15
|
+
export function arenaChainTell(index: number): string { return chainTell(index); }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** H4 group-bank helpers over the SAME v2 state/candidate banks. A group call
|
|
2
|
+
* lends one binding; its group state starts at offset and is host-bounded.
|
|
3
|
+
* Claims use the original director's held-member mask, never a host import. */
|
|
4
|
+
export function groupBankSourceV2(offset: number, width: number): string {
|
|
5
|
+
if (!Number.isInteger(offset) || offset < 0 || !Number.isInteger(width) || width < 1
|
|
6
|
+
|| offset + width > 4096) throw new Error('Invalid group bank span');
|
|
7
|
+
return String.raw`
|
|
8
|
+
import * as core from './wsV2';
|
|
9
|
+
@inline function at(index:i32):usize {
|
|
10
|
+
assert(index>=0&&index<${width});
|
|
11
|
+
const binding=core.row(1,0);
|
|
12
|
+
assert(core.count(1)==1&&core.handle()==load<i32>(binding));
|
|
13
|
+
const base=load<u32>(binding+16),count=load<u32>(binding+20);
|
|
14
|
+
assert(${offset}+u32(index)<count);
|
|
15
|
+
return core.row(3,i32(base)+${offset}+index);
|
|
16
|
+
}
|
|
17
|
+
@inline export function value(index:i32):f64 { return load<f64>(at(index)); }
|
|
18
|
+
@inline export function write(index:i32,value:f64):void {
|
|
19
|
+
assert(Math.abs(value)<Infinity);store<f64>(at(index),value);
|
|
20
|
+
}
|
|
21
|
+
@inline function mask(index:i32):u32 {
|
|
22
|
+
const value=valueAt(index);assert(value>=0&&value<=65535&&Math.floor(value)==value);return u32(value);
|
|
23
|
+
}
|
|
24
|
+
@inline function valueAt(index:i32):f64 { return value(index); }
|
|
25
|
+
@inline export function claim(index:i32,slot:i32,capacity:i32):bool {
|
|
26
|
+
assert(slot>=0&&slot<16&&capacity>=0&&capacity<=16);
|
|
27
|
+
const held=mask(index),bit=u32(1)<<slot;assert(i32(popcnt<u32>(held))<=capacity);
|
|
28
|
+
if((held&bit)!=0)return true;
|
|
29
|
+
if(i32(popcnt<u32>(held))>=capacity)return false;
|
|
30
|
+
write(index,f64(held|bit));return true;
|
|
31
|
+
}
|
|
32
|
+
@inline export function release(index:i32,slot:i32):void {
|
|
33
|
+
assert(slot>=0&&slot<16);write(index,f64(mask(index)&~(u32(1)<<slot)));
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Guest reads for the H4 ordered group-member columns. The native owner and
|
|
2
|
+
* build declaration fix the shape; no guest pointer chooses a live object. */
|
|
3
|
+
export function groupStepSourceV2(columns: number, members: number): string {
|
|
4
|
+
if (!Number.isInteger(columns) || columns < 0 || columns > 128 || !Number.isInteger(members) || members < 1 || members > 16)
|
|
5
|
+
throw new Error('Invalid group member column shape');
|
|
6
|
+
return `import * as core from './wsV2';
|
|
7
|
+
@inline export function memberCount():i32{const n=core.parameter(1);assert(n>=0&&n<=${members}&&n==Math.floor(n));return i32(n);}
|
|
8
|
+
@inline export function member(slot:i32,column:i32):f64{
|
|
9
|
+
assert(slot>=0&&slot<memberCount()&&column>=0&&column<${columns});
|
|
10
|
+
const index=slot*${columns}+column;assert(core.fieldId(index)==index+1);return core.field(index);
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** The single ABI-v1 AssemblyScript transport source, injected as sdk/as/ws.ts by the author compiler.
|
|
2
|
+
* It is a source string so guest globals never enter the host TypeScript program. No service is installed.
|
|
3
|
+
* Transport helpers inline before structural metering; capability, IO and bounds checks remain intact. */
|
|
4
|
+
export const WS_CORE: string = String.raw`
|
|
5
|
+
@external("env", "ws_read") declare function scalar(op:i32,a:f64,b:f64):f64;
|
|
6
|
+
@external("env", "ws_list") declare function query(op:i32,a:f64,b:f64,out:usize,cap:i32):i32;
|
|
7
|
+
const IO:usize=memory.data(2496,8), LIST:usize=memory.data(768,8);
|
|
8
|
+
let states:i32=0,params:i32=0,commands:i32=0,current:i32=0,listCount:i32=0;
|
|
9
|
+
@inline export function init(s:i32,p:i32):void {
|
|
10
|
+
assert(s>=0&&s<=16&&p>=0&&p<=32);states=s;params=p;
|
|
11
|
+
store<f64>(IO+40,0);store<f64>(IO+48,0);store<f64>(IO+56,0);
|
|
12
|
+
}
|
|
13
|
+
@inline export function io():i32{return i32(IO);}
|
|
14
|
+
@inline export function begin():void{commands=0;current=0;listCount=0;}
|
|
15
|
+
@inline export function finish():i32{return commands;}
|
|
16
|
+
@inline export function header(index:i32):f64{assert(index>=0&&index<5);return load<f64>(IO+usize(index)*8);}
|
|
17
|
+
@inline export function state(index:i32):f64{assert(index>=0&&index<states);return load<f64>(IO+64+usize(index)*8);}
|
|
18
|
+
@inline export function setState(index:i32,value:f64):void{assert(index>=0&&index<states);store<f64>(IO+64+usize(index)*8,value);}
|
|
19
|
+
@inline export function parameter(index:i32):f64{assert(index>=0&&index<params);return load<f64>(IO+usize(8+states+index)*8);}
|
|
20
|
+
@inline export function events():i32{const n=i32(header(4));assert(n>=0&&n<=16);return n;}
|
|
21
|
+
@inline export function selectEvent(index:i32):void{assert(index>=0&&index<events());current=index;}
|
|
22
|
+
@inline export function event(field:i32):f64{assert(field>=0&&field<6);return load<f64>(IO+usize(8+states+params+current*6+field)*8);}
|
|
23
|
+
@inline export function command(op:i32,target:i32,a:f64=0,b:f64=0,c:f64=0):void{
|
|
24
|
+
assert(commands<32);const out=IO+usize(8+states+params+96+commands*5)*8;
|
|
25
|
+
store<f64>(out,f64(op));store<f64>(out+8,f64(target));store<f64>(out+16,a);store<f64>(out+24,b);store<f64>(out+32,c);commands++;
|
|
26
|
+
}
|
|
27
|
+
@inline export function read(op:i32,a:f64=0,b:f64=0):f64{return scalar(op,a,b);}
|
|
28
|
+
@inline export function list(op:i32,a:f64=0,b:f64=0):i32{listCount=query(op,a,b,LIST,96);assert(listCount>=0&&listCount<=96);return listCount;}
|
|
29
|
+
@inline export function listAt(index:i32):f64{assert(index>=0&&index<listCount);return load<f64>(LIST+usize(index)*8);}
|
|
30
|
+
`;
|