@wildshard/engine 0.1.18 → 0.1.19

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.
Files changed (293) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/budgets/shard-size-baseline.json +10 -4
  3. package/index.html +6 -4
  4. package/lint/engine-sides.json +14 -0
  5. package/lint/ratchet.json +0 -68
  6. package/lint/ratchet.mjs +1 -4
  7. package/package.json +17 -15
  8. package/scripts/agent-sync.mjs +27 -8
  9. package/scripts/app-build/appCook.ts +8 -2
  10. package/scripts/app-build/catalogue.ts +10 -7
  11. package/scripts/app-build/gen.ts +22 -2
  12. package/scripts/app-build/isolation.d.mts +10 -0
  13. package/scripts/app-build/isolation.mjs +47 -0
  14. package/scripts/app-build/outputProducts.mjs +4 -0
  15. package/scripts/app-build/previousDeploy.d.mts +2 -0
  16. package/scripts/app-build/previousDeploy.mjs +10 -1
  17. package/scripts/app-build/serviceWorker.ts +10 -3
  18. package/scripts/app-build/splitOutput.mjs +4 -2
  19. package/scripts/app-build/standaloneOutput.d.mts +1 -1
  20. package/scripts/app-build/standaloneOutput.mjs +5 -3
  21. package/scripts/app-build/titlePreloads.d.mts +8 -0
  22. package/scripts/app-build/titlePreloads.mjs +69 -0
  23. package/scripts/app-build/worldMapAtlas.ts +10 -6
  24. package/scripts/app-build-pipeline.mjs +31 -3
  25. package/scripts/built-product.mjs +1 -1
  26. package/scripts/cell-mem-bench.mjs +81 -23
  27. package/scripts/check-custom-sections-zero.mjs +1 -1
  28. package/scripts/check-devserver.mjs +2 -0
  29. package/scripts/check-models.mjs +2 -0
  30. package/scripts/check-paths.allow.json +0 -115
  31. package/scripts/check-paths.mjs +2 -2
  32. package/scripts/check-platform-ratchets.mjs +2 -3
  33. package/scripts/chromium-keychain.d.mts +1 -1
  34. package/scripts/ci-static.sh +1 -1
  35. package/scripts/committed-fast-checks.mjs +0 -2
  36. package/scripts/content-sw-proof.mjs +2 -1
  37. package/scripts/cook-worker.mjs +9 -3
  38. package/scripts/cook.mjs +18 -5
  39. package/scripts/docs-inputs-proof.mjs +6 -6
  40. package/scripts/e7-voice-staging-proof.mjs +1 -1
  41. package/scripts/gate-related-tests.mjs +1 -1
  42. package/scripts/git-source-view.mjs +1 -1
  43. package/scripts/goldens/capture.mjs +17 -5
  44. package/scripts/grid-crossing-nightly.mjs +59 -0
  45. package/scripts/grid-crossing-qa.mjs +44 -0
  46. package/scripts/grid-crossing-ratchet.d.mts +6 -0
  47. package/scripts/grid-crossing-ratchet.mjs +52 -0
  48. package/scripts/grid-crossing-report.mjs +122 -0
  49. package/scripts/grid-crossing-stages.mjs +47 -0
  50. package/scripts/grid-crossing-tour.mjs +277 -0
  51. package/scripts/grid-crossing-walk-proof.mjs +124 -17
  52. package/scripts/host-ruler/roots.mjs +2 -2
  53. package/scripts/host-ruler.d.mts +91 -0
  54. package/scripts/host-ruler.mjs +565 -0
  55. package/scripts/live-prepush.py +3 -5
  56. package/scripts/loading-flow/benchmax.mjs +3 -1
  57. package/scripts/look-loop/test_look_loop.py +1 -38
  58. package/scripts/memory-proof.mjs +61 -6
  59. package/scripts/mmo-bots.mjs +8 -2
  60. package/scripts/net-lag-proof.mjs +219 -0
  61. package/scripts/night-market-kit-budget.mjs +2 -2
  62. package/scripts/offline-proof-rules.d.mts +2 -2
  63. package/scripts/offline-proof-rules.mjs +15 -4
  64. package/scripts/offline-proof.mjs +74 -13
  65. package/scripts/{shard-platform-output.mjs → output-reader.mjs} +1 -1
  66. package/scripts/page-release/content.d.mts +9 -1
  67. package/scripts/page-release/content.mjs +131 -17
  68. package/scripts/page-release/flow.mjs +36 -10
  69. package/scripts/page-release/stamp-content.mjs +24 -0
  70. package/scripts/page-release.mjs +28 -6
  71. package/scripts/page-size.mjs +2 -1
  72. package/scripts/pin-packs.ts +1 -1
  73. package/scripts/pins.ts +4 -4
  74. package/scripts/precommit-checks.mjs +1 -7
  75. package/scripts/precommit-jobs.mjs +0 -1
  76. package/scripts/precommit-source.py +1 -9
  77. package/scripts/program-discovery.mjs +1 -1
  78. package/scripts/ring-cook.mjs +2 -1
  79. package/scripts/ring-step.ts +1 -1
  80. package/scripts/script-scenario-metrics.mjs +1 -1
  81. package/scripts/shard-output-content.d.mts +1 -1
  82. package/scripts/shard-output-content.mjs +2 -2
  83. package/scripts/shard-outputs.mjs +1 -1
  84. package/scripts/shard-public.mjs +1 -1
  85. package/scripts/shard-wire-meter.mjs +24 -9
  86. package/scripts/side-parity.mjs +4 -2
  87. package/scripts/standalone-smoke.mjs +8 -3
  88. package/scripts/tier-textures.mjs +22 -4
  89. package/scripts/tile-bake-report.mjs +1 -1
  90. package/scripts/tile-bakes.mjs +1 -1
  91. package/scripts/title-assets.generated.json +2 -0
  92. package/scripts/tsconfig.json +0 -2
  93. package/scripts/vendor/basisu/LICENSE +201 -0
  94. package/scripts/vendor/basisu/basis_encoder.cjs +2 -0
  95. package/scripts/vendor/basisu/basis_encoder.wasm +0 -0
  96. package/scripts/vitest-push-guards.config.ts +1 -1
  97. package/scripts/vps/harden-apply.sh +4 -1
  98. package/scripts/vps/harden-prometheus.sh +176 -0
  99. package/scripts/vps/harden.sh +16 -0
  100. package/scripts/vps/rebuild.sh +18 -0
  101. package/scripts/vps/wildshard-config +6 -2
  102. package/scripts/worker-client-play.mjs +6 -2
  103. package/scripts/worktree-reap.mjs +5 -5
  104. package/src/.oxlintrc.json +3 -182
  105. package/src/client/app/entry.ts +10 -2
  106. package/src/client/engine/boot/bootCache.ts +2 -2
  107. package/src/client/engine/boot/bootTrace.ts +12 -4
  108. package/src/client/engine/boot/browserChunkRecovery.ts +4 -0
  109. package/src/client/engine/boot/clearDownloads.ts +5 -2
  110. package/src/client/engine/boot/contentRead.ts +11 -0
  111. package/src/client/engine/boot/gpuFiles.ts +4 -2
  112. package/src/client/engine/boot/lastEnd.ts +99 -12
  113. package/src/client/engine/boot/texturePack.ts +2 -2
  114. package/src/client/engine/net/netPlayer.ts +19 -2
  115. package/src/client/engine/net/otherPlayers.ts +55 -8
  116. package/src/client/engine/net/predictor.ts +33 -9
  117. package/src/client/engine/net/redial.ts +29 -6
  118. package/src/client/engine/pwa/cacheNames.ts +58 -1
  119. package/src/client/engine/pwa/sw.js +41 -11
  120. package/src/client/engine/render/dataLook.ts +152 -40
  121. package/src/client/engine/render/families/detail.ts +89 -0
  122. package/src/client/engine/render/families/pbr.ts +7 -1
  123. package/src/client/engine/render/look.ts +6 -0
  124. package/src/client/engine/render/lookLight.ts +103 -11
  125. package/src/client/engine/render/lookRender.ts +105 -0
  126. package/src/client/engine/saves/indexed.ts +2 -2
  127. package/src/client/engine/telemetry/browserErrors.ts +24 -3
  128. package/src/client/engine/telemetry/staleBuildReport.ts +22 -1
  129. package/src/client/engine/ui/debugOptions.ts +1 -1
  130. package/src/client/engine/ui/lookLightOption.ts +10 -6
  131. package/src/client/engine/ui/namePrompt.ts +7 -0
  132. package/src/client/game/boot/audio.generated.ts +114 -114
  133. package/src/client/game/boot/bytes.generated.ts +118 -220
  134. package/src/client/game/boot/placedSpawn.ts +35 -0
  135. package/src/client/game/boot/spawnDownload.ts +25 -6
  136. package/src/client/game/boot/versions.generated.ts +7 -5
  137. package/src/client/game/devScene/hook.ts +291 -0
  138. package/src/client/game/grid/cellLoading.ts +12 -2
  139. package/src/client/game/grid/live.ts +112 -16
  140. package/src/client/game/grid/liveSession.ts +33 -2
  141. package/src/client/game/grid/mapAtlas.ts +18 -4
  142. package/src/client/game/grid/minimapBlend.ts +15 -5
  143. package/src/client/game/grid/oneWayIn.ts +5 -1
  144. package/src/client/game/grid/placedCells.ts +114 -12
  145. package/src/client/game/grid/placedContent.ts +85 -0
  146. package/src/client/game/grid/prefetch.ts +9 -1
  147. package/src/client/game/grid/productInputs.ts +3 -1
  148. package/src/client/game/grid/productLeases.ts +4 -1
  149. package/src/client/game/grid/products.ts +8 -4
  150. package/src/client/game/grid/roadLook.ts +24 -15
  151. package/src/client/game/grid/roadLookPlatform.ts +4 -2
  152. package/src/client/game/grid/roadResources.ts +24 -0
  153. package/src/client/game/grid/roadSign.worker.ts +4 -3
  154. package/src/client/game/grid/roadSignPaint.ts +16 -5
  155. package/src/client/game/grid/roadSignPreparation.ts +4 -3
  156. package/src/client/game/grid/roadSignScale.ts +8 -0
  157. package/src/client/game/grid/roadTileCapture.worker.ts +3 -1
  158. package/src/client/game/grid/roadTileCaptureWorker.ts +2 -1
  159. package/src/client/game/grid/roadTileWrite.worker.ts +4 -2
  160. package/src/client/game/grid/roadTileWriter.ts +2 -1
  161. package/src/client/game/grid/screenReports.ts +39 -0
  162. package/src/client/game/grid/session.ts +20 -4
  163. package/src/client/game/grid/softWallLook.ts +25 -8
  164. package/src/client/game/mainMenu.ts +6 -2
  165. package/src/client/game/plugin/context.ts +2 -1
  166. package/src/client/game/plugin/followedMovers.ts +7 -1
  167. package/src/client/game/quest/figures.ts +2 -0
  168. package/src/client/game/session/finish.ts +6 -0
  169. package/src/client/game/shardfile/assetCache.ts +4 -4
  170. package/src/client/game/shardfile/client.ts +4 -1
  171. package/src/client/game/shardfile/clientAssets.ts +9 -5
  172. package/src/client/game/shardfile/clientLibrary.ts +1 -1
  173. package/src/client/game/shardfile/clientWater.ts +51 -9
  174. package/src/client/game/shardfile/clientWorker.ts +19 -7
  175. package/src/client/game/shardfile/look.ts +8 -3
  176. package/src/client/game/shardfile/product.ts +34 -7
  177. package/src/client/game/shardfile/productChecks.ts +2 -2
  178. package/src/client/game/shardfile/productCost.ts +2 -2
  179. package/src/client/game/shardfile/readAsset.ts +2 -2
  180. package/src/client/game/shardfile/reflectingWater.ts +73 -0
  181. package/src/client/game/shardfile/seatGrace.ts +9 -0
  182. package/src/client/game/shardfile/skinPlayback.ts +1 -1
  183. package/src/client/game/systems/npc/figureRows.ts +9 -0
  184. package/src/client/host/online/doctor.ts +2 -0
  185. package/src/client/host/online/linkScreens.ts +30 -4
  186. package/src/client/host/standalone/shell.ts +4 -0
  187. package/src/cook/game/astc6Encode.ts +55 -0
  188. package/src/cook/game/astc6Wasm.ts +176 -0
  189. package/src/cook/game/cookJob.ts +30 -6
  190. package/src/cook/game/cookWorker.ts +38 -11
  191. package/src/cook/game/entryTotals.ts +51 -24
  192. package/src/cook/game/shardCook.ts +35 -7
  193. package/src/cook/game/spawnParts.ts +33 -8
  194. package/src/cook/game/tierTextures.ts +87 -14
  195. package/src/server/engine/ai/bossContenders.ts +27 -3
  196. package/src/server/engine/ai/phases.ts +1 -1
  197. package/src/server/engine/entities/creatureRefill.ts +9 -2
  198. package/src/server/engine/net/ledgerBook.ts +2 -0
  199. package/src/server/engine/net/room.ts +15 -0
  200. package/src/server/engine/sim/respawn.ts +8 -0
  201. package/src/server/game/boss/arenaRoomEntry.ts +5 -1
  202. package/src/server/game/boss/arenaRoomNative.ts +2 -0
  203. package/src/server/game/boss/native.ts +2 -1
  204. package/src/server/game/boss/nativeWake.ts +9 -5
  205. package/src/server/game/boss/openArenaNative.ts +2 -2
  206. package/src/server/game/boss/openArenaRoom.ts +3 -1
  207. package/src/server/game/grid/room.ts +44 -3
  208. package/src/server/game/grid/simulation.ts +23 -0
  209. package/src/server/game/population/mixedRoster.ts +11 -3
  210. package/src/server/game/population/nativeBake.ts +8 -3
  211. package/src/server/game/population/nativeReturns.ts +6 -3
  212. package/src/server/game/population/roster.ts +5 -3
  213. package/src/server/game/quest/eliteDrops.ts +15 -4
  214. package/src/server/game/quest/nativeChapter.ts +1 -1
  215. package/src/server/game/quest/nativeComposition.ts +5 -1
  216. package/src/server/game/riding/nativeTaming.ts +10 -6
  217. package/src/server/game/riding/wildRefill.ts +3 -2
  218. package/src/server/game/shardfile/bossRow.ts +4 -2
  219. package/src/server/game/shardfile/homeKeeper.ts +4 -2
  220. package/src/server/host/bake/headlessWorker.ts +1 -1
  221. package/src/server/host/dedicated/cellHost.ts +98 -16
  222. package/src/server/host/dedicated/cellProtocol.ts +16 -1
  223. package/src/server/host/dedicated/cellWorker.ts +8 -5
  224. package/src/server/host/dedicated/dedicatedRoom.ts +16 -6
  225. package/src/server/host/dedicated/gridCells.ts +15 -6
  226. package/src/server/host/dedicated/loopLag.ts +21 -0
  227. package/src/server/host/dedicated/main.ts +13 -5
  228. package/src/server/host/dedicated/packReader.ts +3 -3
  229. package/src/server/host/dedicated/placementFile.ts +3 -2
  230. package/src/server/host/dedicated/roadRoom.ts +34 -4
  231. package/src/server/host/dedicated/serverMetrics.ts +126 -0
  232. package/src/server/host/dedicated/socketPump.ts +21 -4
  233. package/src/server/host/dedicated/workerTable.ts +15 -4
  234. package/src/server/host/dedicated/world.ts +65 -7
  235. package/src/server/host/headless.ts +1 -1
  236. package/src/server/host/headlessRuntime.ts +1 -1
  237. package/src/server/host/standalone/roadWorld.ts +15 -3
  238. package/src/server/host/standalone/serverHost.ts +4 -1
  239. package/src/server/host/standalone/serverProduct.ts +41 -11
  240. package/src/shared/engine/ai/BossBrain.ts +8 -0
  241. package/src/shared/game/boss/wake.ts +6 -0
  242. package/src/shared/game/devColliders.ts +47 -0
  243. package/src/shared/game/eliteSystem.ts +8 -0
  244. package/src/shared/game/grid/allocator.ts +3 -0
  245. package/src/shared/game/grid/placementRows.ts +5 -2
  246. package/src/shared/game/plugin/bossRecord.ts +3 -2
  247. package/src/shared/game/shardfile/ktx2Targets.ts +23 -3
  248. package/src/shared/game/shardfile/outputDescriptor.ts +9 -5
  249. package/src/shared/game/shardfile/packReads.ts +28 -3
  250. package/src/shared/game/shardfile/serverPack.ts +9 -0
  251. package/src/shared/game/systems/looks/trampleField.ts +2 -0
  252. package/src/shared/host/formatJsonSchema.ts +2 -2
  253. package/src/tsconfig.json +1 -27
  254. package/lint/host-reviews.json +0 -14
  255. package/lint/listed-view-code.json +0 -13
  256. package/lint/platform-pending-users.json +0 -2520
  257. package/lint/platform-pending-users.md +0 -18
  258. package/scripts/cell-mem/metrics-preload.mjs +0 -65
  259. package/scripts/check-closed-components.d.mts +0 -7
  260. package/scripts/check-closed-components.mjs +0 -87
  261. package/scripts/g571-hosts.d.mts +0 -3
  262. package/scripts/g571-hosts.mjs +0 -54
  263. package/scripts/host-ruler/register-migrate.mjs +0 -242
  264. package/scripts/listed-view-code.d.mts +0 -7
  265. package/scripts/listed-view-code.mjs +0 -93
  266. package/scripts/look-loop/fit-lut.py +0 -142
  267. package/scripts/look-loop/palette-delta.py +0 -183
  268. package/scripts/look-loop/regions/driftwood-isle.json +0 -25
  269. package/scripts/look-loop/regions/far-reach.json +0 -225
  270. package/scripts/look-loop/regions/open-plot-night-market.json +0 -855
  271. package/scripts/look-loop/regions/pine-hollow.json +0 -22
  272. package/scripts/look-loop/regions/sunscar-dunes.json +0 -281
  273. package/scripts/platform-chargebacks.d.mts +0 -9
  274. package/scripts/platform-chargebacks.mjs +0 -135
  275. package/scripts/shard-component-spans.d.mts +0 -15
  276. package/scripts/shard-component-spans.mjs +0 -18
  277. package/scripts/shard-components.d.mts +0 -16
  278. package/scripts/shard-components.mjs +0 -363
  279. package/scripts/shard-platform-hosts.d.mts +0 -2
  280. package/scripts/shard-platform-hosts.mjs +0 -93
  281. package/scripts/shard-platform-sections.d.mts +0 -2
  282. package/scripts/shard-platform-sections.mjs +0 -9
  283. package/scripts/shard-platform.d.mts +0 -76
  284. package/scripts/shard-platform.mjs +0 -1072
  285. package/src/.oxfmtrc.json +0 -48
  286. package/src/scripts/ask-new.sh +0 -29
  287. package/src/scripts/asks.mjs +0 -142
  288. package/src/scripts/herdr-prompt.sh +0 -34
  289. package/src/scripts/herdr-question-open.sh +0 -67
  290. package/src/scripts/md-wrap.mjs +0 -229
  291. /package/scripts/{shard-platform-format.d.mts → node-format.d.mts} +0 -0
  292. /package/scripts/{shard-platform-format.mjs → node-format.mjs} +0 -0
  293. /package/scripts/{shard-platform-output.d.mts → output-reader.d.mts} +0 -0
package/src/.oxfmtrc.json DELETED
@@ -1,48 +0,0 @@
1
- {
2
- "$schema": "./node_modules/oxfmt/configuration_schema.json",
3
- "printWidth": 80,
4
- "tabWidth": 2,
5
- "useTabs": false,
6
- "semi": false,
7
- "singleQuote": true,
8
- "jsxSingleQuote": true,
9
- "trailingComma": "all",
10
- "arrowParens": "avoid",
11
- "endOfLine": "lf",
12
- "insertFinalNewline": true,
13
- "bracketSpacing": true,
14
- "sortPackageJson": false,
15
- "sortImports": {
16
- "groups": [
17
- "builtin",
18
- "external",
19
- "internal",
20
- ["parent", "sibling", "index"],
21
- [
22
- "type-external",
23
- "type-internal",
24
- "type-parent",
25
- "type-sibling",
26
- "type-index"
27
- ]
28
- ],
29
- "newlinesBetween": true
30
- },
31
- "ignorePatterns": [
32
- // Plain-JS repo scripts, outside the TS project; covered by
33
- // `pnpm test:hooks` instead. (.githooks/ sits outside src/.)
34
- "scripts/**",
35
- "dist/**",
36
- "node_modules/**",
37
- "test-results/**",
38
- "playwright-report/**",
39
- "pnpm-lock.yaml",
40
- "**/*.md"
41
- ],
42
- "overrides": [
43
- {
44
- "files": ["*.json", "*.jsonc"],
45
- "options": { "trailingComma": "none" }
46
- }
47
- ]
48
- }
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env bash
2
- # ask-new.sh — claim the next ask id and create docs/tasks/asks/<ID>.md
3
- # (one file per request for work from Jake; rules in
4
- # docs/tasks/asks/README.md). Ported from project-wildshard-singleplayer.
5
- #
6
- # src/scripts/ask-new.sh "<Jake's words>" [series letter, default A]
7
- #
8
- # The file IS the claim: it is created with noclobber (O_EXCL), so two
9
- # agents asking at the same moment get two different ids. Prints the new
10
- # file's path. Fill in the rest with Edit, then commit it by pathspec.
11
- set -uo pipefail
12
- cd "$(git rev-parse --show-toplevel)" || exit 1
13
- ask="${1:?usage: src/scripts/ask-new.sh \"<the request, in Jake words>\" [series letter]}"
14
- series="${2:-A}"
15
- dir=docs/tasks/asks
16
- mkdir -p "$dir"
17
- max="$(ls "$dir" 2>/dev/null | grep -oE "^${series}[0-9]+\.md$" | grep -oE '[0-9]+' | sort -n | tail -1)"
18
- n=$(( ${max:-0} + 1 ))
19
- set -o noclobber
20
- for _ in $(seq 1 50); do
21
- f="$dir/${series}${n}.md"
22
- if { printf '# %s%s\n\n**Status:** open (%s)\n**Ask:** %s\n' "$series" "$n" "$(date +%F)" "$ask" > "$f"; } 2>/dev/null; then
23
- echo "$f"
24
- exit 0
25
- fi
26
- n=$(( n + 1 ))
27
- done
28
- echo "ask-new: could not claim an id in series $series" >&2
29
- exit 1
@@ -1,142 +0,0 @@
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
- // node src/scripts/asks.mjs check --all CI/pre-push: every committed ask, even with an empty index
8
- //
9
- // An ask is a receipt of Jake's words. Follow-up work is a plan row.
10
- import { spawnSync } from 'node:child_process'
11
- import { existsSync, readdirSync, readFileSync } from 'node:fs'
12
- import { basename, resolve } from 'node:path'
13
- import { pathToFileURL } from 'node:url'
14
-
15
- const ROOT = resolve(import.meta.dirname, '..', '..')
16
- const ASKS = 'docs/tasks/asks'
17
- const PLANS = 'docs/plans'
18
- const LEASE_HOURS = 71 // a claim with no commit touching it for 71 h has expired
19
-
20
- /** The Status vocabulary. `folded into` / `superseded by` name the ask or plan that carries the work. */
21
- export const STATES = ['open', 'in flight', 'needs pick', 'done', 'dropped', 'folded into', 'superseded by']
22
- const CLOSED = new Set(['done', 'dropped', 'folded into', 'superseded by'])
23
-
24
- /** @param {string[]} args */
25
- const git = (...args) => {
26
- const r = spawnSync('git', args, { cwd: ROOT, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 })
27
- return r.status === 0 ? r.stdout : ''
28
- }
29
-
30
- /** @param {string} text */
31
- export function parseAsk(text) {
32
- const status = /^\*\*Status:\*\* *(.*)$/mu.exec(text)?.[1]?.trim() ?? ''
33
- const lower = status.toLowerCase()
34
- const state = STATES.find(s => lower.startsWith(s)) ?? null
35
- const date = /(\d{4}-\d{2}-\d{2})/u.exec(status)?.[1] ?? null
36
- const target =
37
- state === 'folded into' || state === 'superseded by'
38
- ? (/^(?:folded into|superseded by) +([A-Za-z][A-Za-z0-9_-]*)/iu.exec(status)?.[1] ?? null)
39
- : null
40
- return {
41
- title: /^# (\S+)/u.exec(text)?.[1] ?? null,
42
- status,
43
- state,
44
- closed: state !== null && CLOSED.has(state),
45
- date,
46
- target,
47
- ask: /^\*\*Ask:\*\* *(.*)$/mu.exec(text)?.[1]?.trim() ?? '',
48
- }
49
- }
50
-
51
- /** A target exists: an ask, a live plan, or a plan archived as project/archive/<date>-<name>.md. */
52
- /** @param {string} target */
53
- export function targetExists(target, root = ROOT) {
54
- if (existsSync(resolve(root, ASKS, `${target}.md`))) return true
55
- if (existsSync(resolve(root, PLANS, `${target}.md`))) return true
56
- const archive = resolve(root, 'project/archive')
57
- if (!existsSync(archive)) return false
58
- const name = target.toLowerCase()
59
- return readdirSync(archive).some(f => f.toLowerCase().endsWith(`-${name}.md`) || f.toLowerCase() === `${name}.md`)
60
- }
61
-
62
- /**
63
- * Every rule an ask file must pass.
64
- * @param {string} id
65
- * @param {string} text
66
- * @returns {string[]} problems; empty when it passes
67
- */
68
- export function checkAsk(id, text, exists = targetExists) {
69
- const a = parseAsk(text)
70
- const out = []
71
- if (a.title !== id) out.push(`first line must be "# ${id}" (create asks with src/scripts/ask-new.sh)`)
72
- if (!a.status) out.push('no **Status:** line')
73
- if (!a.ask) out.push("no **Ask:** line (Jake's words)")
74
- if (a.status && a.state === null) {
75
- out.push(`Status "${a.status.slice(0, 40)}" is not one of: ${STATES.join(' / ')}`)
76
- }
77
- if (a.state === 'in flight' && !/^in flight \(\d{4}-\d{2}-\d{2}, *[^)]+\)/u.test(a.status)) {
78
- out.push('in flight needs its claim: "in flight (YYYY-MM-DD, <owner>)"')
79
- }
80
- if ((a.state === 'open' || a.state === 'needs pick' || a.state === 'done') && !a.date) {
81
- out.push(`${a.state} needs its date: "${a.state} (YYYY-MM-DD)"`)
82
- }
83
- if ((a.state === 'folded into' || a.state === 'superseded by') && (a.target === null || !exists(a.target))) {
84
- out.push(`"${a.state}" must name an existing ask (A12) or plan (a-plan-slug)`)
85
- }
86
- return out
87
- }
88
-
89
- function check(all = false) {
90
- const staged = (all ? git('ls-files', '-z') : git('diff', '--cached', '--name-only', '--diff-filter=AM', '-z'))
91
- .split('\0')
92
- .filter(p => p.startsWith(`${ASKS}/`) && p.endsWith('.md') && !p.endsWith('/README.md'))
93
- let bad = 0
94
- for (const p of staged) {
95
- const problems = checkAsk(basename(p, '.md'), all ? readFileSync(resolve(ROOT, p), 'utf8') : git('show', `:${p}`))
96
- for (const m of problems) console.error(` ${p}: ${m}`)
97
- bad += problems.length
98
- }
99
- if (bad > 0) {
100
- console.error('\n X commit blocked: ask file breaks the rules in docs/tasks/asks/README.md.\n')
101
- process.exitCode = 1
102
- }
103
- }
104
-
105
- /** @param {string} from */
106
- const days = (from, to = Date.now()) => (to - Date.parse(`${from}T00:00:00Z`)) / 86_400_000
107
-
108
- function brief() {
109
- const dir = resolve(ROOT, ASKS)
110
- const files = existsSync(dir) ? readdirSync(dir).filter(n => /^[A-Z]+\d+\.md$/u.test(n)) : []
111
- const now = Date.now()
112
- const rows = []
113
- for (const f of files.sort((x, y) => x.localeCompare(y, 'en', { numeric: true }))) {
114
- const a = parseAsk(readFileSync(resolve(dir, f), 'utf8'))
115
- if (a.closed) continue
116
- let flag = ''
117
- if (a.state === 'in flight') {
118
- const committed = Number(git('log', '-1', '--format=%ct', '--', `${ASKS}/${f}`).trim()) * 1000
119
- const last = Math.max(a.date ? Date.parse(`${a.date}T23:59:59Z`) : 0, committed)
120
- if ((now - last) / 3_600_000 > LEASE_HOURS) {
121
- flag = ` !! CLAIM EXPIRED (no commit in ${LEASE_HOURS} h): anyone may take it`
122
- }
123
- }
124
- if (a.state === 'needs pick') {
125
- const open = a.date ? ` (open ${Math.floor(days(a.date, now))} d)` : ''
126
- flag = ` !! ASK JAKE with the question tool${open}: a pick never expires`
127
- }
128
- if (a.state === null) flag = ' !! Status outside the vocabulary (docs/tasks/asks/README.md)'
129
- rows.push(` ${basename(f, '.md')} | ${a.status.slice(0, 80)}${flag} | ${a.ask.slice(0, 100)}`)
130
- }
131
- console.log(rows.length > 0 ? rows.join('\n') : ' (none)')
132
- }
133
-
134
- if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
135
- const [mode] = process.argv.slice(2)
136
- if (mode === 'check') check(process.argv.includes('--all'))
137
- else if (mode === 'brief') brief()
138
- else {
139
- console.error('usage: node src/scripts/asks.mjs brief | check')
140
- process.exitCode = 2
141
- }
142
- }
@@ -1,34 +0,0 @@
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" "$@"
@@ -1,67 +0,0 @@
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"
@@ -1,229 +0,0 @@
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
- }