rvlib-shipkit 2.12.0 → 2.14.0

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 (378) hide show
  1. package/CHANGELOG.md +75 -21
  2. package/README.md +1 -1
  3. package/package.json +4 -2
  4. package/src/agent-time/store.ts +2 -2
  5. package/src/assets/run-assets.ts +2 -2
  6. package/src/assets/server/studio-server.ts +27 -23
  7. package/src/check.ts +4 -4
  8. package/src/checks/SK001-package-json-shape.check.ts +8 -4
  9. package/src/checks/SK002-contracts-fulfillness.check.ts +2 -2
  10. package/src/checks/SK003-claude-md-shape.check.ts +20 -13
  11. package/src/checks/SK004-gitignore-policy.check.ts +45 -6
  12. package/src/checks/SK005-rvlib-versions.check.ts +2 -2
  13. package/src/checks/SK006-npm-publish-safety.check.ts +3 -3
  14. package/src/checks/SK007-github-visibility.check.ts +2 -2
  15. package/src/checks/SK008-reviewer-agent.check.ts +3 -3
  16. package/src/checks/SK010-undeclared-unit.check.ts +2 -2
  17. package/src/checks/SK011-sibling-unit-ranges.check.ts +2 -2
  18. package/src/checks/SK012-config-barrel-import.check.ts +2 -2
  19. package/src/checks/SK013-one-way-in-policy.check.ts +2 -2
  20. package/src/checks/SK015-nested-repo.check.ts +3 -3
  21. package/src/checks/SK016-legacy-check-shapes.check.ts +2 -2
  22. package/src/checks/SK017-vscode-hub-task.check.ts +2 -2
  23. package/src/checks/SK018-test-files-run.check.ts +2 -2
  24. package/src/checks/SK019-tests-run-in-units.check.ts +2 -2
  25. package/src/checks/SK020-self-spawning-check.check.ts +2 -2
  26. package/src/checks/SK022-machine-runs-the-pin.check.ts +2 -2
  27. package/src/checks/SK024-identity-colors.check.ts +1 -1
  28. package/src/checks/SK025-release-drift.check.ts +2 -2
  29. package/src/checks/SK026-asks-autoclose.check.ts +2 -2
  30. package/src/checks/SK027-agent-wiki-links.check.ts +8 -2
  31. package/src/checks/SK028-readme.check.ts +2 -2
  32. package/src/checks/SK029-explicit-check-files.check.ts +3 -3
  33. package/src/checks/SK030-cache-audit.check.ts +7 -5
  34. package/src/checks/SK031-trace-audit.check.ts +7 -7
  35. package/src/checks/SK032-ignored-inputs.check.ts +3 -3
  36. package/src/checks/SK033-global-contribution.check.ts +11 -4
  37. package/src/checks/SK034-commit-gates-armed.check.ts +2 -2
  38. package/src/checks/SK035-public-clean.check.ts +46 -0
  39. package/src/checks/SK036-draft-media-size.check.ts +28 -0
  40. package/src/checks/SK037-keyword-additions.check.ts +43 -0
  41. package/src/cli/cmd_Backup.ts +152 -0
  42. package/src/cli/cmd_Ci.ts +8 -11
  43. package/src/cli/cmd_Commands.ts +4 -4
  44. package/src/cli/cmd_ConfigKeys.ts +2 -2
  45. package/src/cli/cmd_Drill.ts +145 -0
  46. package/src/cli/cmd_Home.ts +50 -3
  47. package/src/cli/cmd_Init.ts +1 -1
  48. package/src/cli/cmd_Media.ts +10 -8
  49. package/src/cli/cmd_Mv.ts +14 -7
  50. package/src/cli/cmd_Review.ts +6 -4
  51. package/src/cli/cmd_Shot.ts +5 -2
  52. package/src/cli/cmd_Smoke.ts +5 -2
  53. package/src/cli/cmd_Social.ts +226 -0
  54. package/src/cli/cmd_Sound.ts +1 -1
  55. package/src/cli/cmd_Start.ts +1 -1
  56. package/src/cli/cmd_Time.ts +1 -1
  57. package/src/cli/cmd_TraceAudit.ts +6 -6
  58. package/src/cli/cmd_Trailer.ts +7 -4
  59. package/src/cli/cmd_Veille.ts +173 -0
  60. package/src/cli/cmd_When.ts +2 -2
  61. package/src/cli/family-pages.ts +19 -16
  62. package/src/cli/registry.ts +13 -2
  63. package/src/cli.ts +5 -2
  64. package/src/collections/actions.ts +1 -49
  65. package/src/collections/checks.ts +2 -1
  66. package/src/collections/collection-types.ts +12 -3
  67. package/src/collections/providers.ts +4 -4
  68. package/src/collections/review.ts +3 -2
  69. package/src/collections/tests.ts +19 -8
  70. package/src/comfy/comfy-panel.ts +2 -2
  71. package/src/contracts/apply-contracts.ts +1 -3
  72. package/src/contracts/contract-manifests.ts +2 -3
  73. package/src/contracts/contract-types.ts +0 -1
  74. package/src/contracts/contracts-engine.ts +0 -3
  75. package/src/contracts/manifests/discord.contract.ts +1 -1
  76. package/src/contracts/manifests/identity.contract.ts +1 -1
  77. package/src/contracts/manifests/itch.contract.ts +1 -1
  78. package/src/contracts/manifests/steam.contract.ts +1 -1
  79. package/src/core/agent-dir-at.ts +12 -0
  80. package/src/core/agent-dir.ts +16 -0
  81. package/src/core/app-icon.ts +9 -3
  82. package/src/core/budget.ts +1 -1
  83. package/src/core/bun-builtins.ts +2 -2
  84. package/src/core/canonical-scripts.ts +2 -2
  85. package/src/core/discover-checks.ts +38 -6
  86. package/src/core/fix-scope.ts +4 -2
  87. package/src/core/floor-resolve.ts +68 -48
  88. package/src/core/floor.ts +9 -0
  89. package/src/core/git-root.ts +24 -0
  90. package/src/core/global-contribution.ts +4 -1
  91. package/src/core/ignored-block.ts +1 -1
  92. package/src/core/ignored-inputs.ts +3 -2
  93. package/src/core/last-good.ts +3 -1
  94. package/src/core/layout.ts +8 -0
  95. package/src/core/log-stamp.ts +36 -0
  96. package/src/core/loop-watch.ts +93 -0
  97. package/src/core/machine-link.ts +134 -0
  98. package/src/core/memory-watch.ts +41 -0
  99. package/src/core/motherhome.ts +2 -2
  100. package/src/core/one-way-in-policy.ts +34 -26
  101. package/src/core/run-ci.ts +9 -11
  102. package/src/core/run-fixers.ts +9 -9
  103. package/src/core/runs-matrix.ts +1 -1
  104. package/src/core/slots.ts +30 -0
  105. package/src/core/trace-audit.ts +50 -9
  106. package/src/core/tree-rev.ts +60 -0
  107. package/src/core/unit-files.ts +42 -0
  108. package/src/drill/render.ts +140 -0
  109. package/src/drill/run.ts +269 -0
  110. package/src/fleet/scan-fleet.ts +6 -5
  111. package/src/home/daemon-jobs.ts +201 -0
  112. package/src/home/global-context.ts +44 -8
  113. package/src/home/gui-app/ShipkitGui.swift +91 -2
  114. package/src/home/home-routes.ts +22 -15
  115. package/src/home/hubs.ts +10 -3
  116. package/src/home/inbox-shape.ts +54 -5
  117. package/src/home/inbox.ts +17 -2
  118. package/src/home/lib-watch.ts +10 -3
  119. package/src/home/machine-stores.ts +15 -29
  120. package/src/home/pm-config.ts +4 -1
  121. package/src/home/pm-inputs.ts +2 -0
  122. package/src/home/resources.ts +7 -2
  123. package/src/home/run-daemon.ts +15 -18
  124. package/src/home/run-pm.ts +3 -1
  125. package/src/home/serve-daemon.ts +4 -3
  126. package/src/home/serve-web.ts +104 -1
  127. package/src/hooks/commit-message.ts +29 -20
  128. package/src/hooks/hook-gates.ts +1 -1
  129. package/src/hooks/leak-guard.ts +69 -9
  130. package/src/hooks/run-hooks.ts +18 -22
  131. package/src/identities/identities.ts +334 -0
  132. package/src/identities/machine-route.ts +126 -0
  133. package/src/identities/machine.ts +62 -0
  134. package/src/init-repo.ts +3 -3
  135. package/src/ledger/check-stats.ts +10 -9
  136. package/src/ledger/gate-checks.ts +32 -1
  137. package/src/ledger/record-kept.ts +112 -0
  138. package/src/ledger/repo-view.ts +10 -0
  139. package/src/ledger/run-log.ts +17 -12
  140. package/src/ledger/run-timeline.ts +8 -4
  141. package/src/ledger/store.ts +7 -0
  142. package/src/ledger/suite-log.ts +17 -13
  143. package/src/media-kinds.ts +3 -2
  144. package/src/media-store/backup/daemon.ts +73 -0
  145. package/src/media-store/backup/keys.ts +25 -0
  146. package/src/media-store/backup/manifest.ts +193 -0
  147. package/src/media-store/backup/restore.ts +192 -0
  148. package/src/media-store/backup/run.ts +278 -0
  149. package/src/media-store/backup/secret.ts +86 -0
  150. package/src/media-store/backup/snapshot.ts +64 -0
  151. package/src/media-store/backup/sources.ts +199 -0
  152. package/src/media-store/content.ts +1 -1
  153. package/src/media-store/daemon.ts +56 -70
  154. package/src/media-store/db.ts +1 -1
  155. package/src/media-store/fact.ts +1 -1
  156. package/src/media-store/hand.ts +1 -1
  157. package/src/media-store/kind.ts +1 -1
  158. package/src/media-store/purge.ts +1 -1
  159. package/src/media-store/put.ts +5 -3
  160. package/src/media-store/remote.ts +1 -1
  161. package/src/media-store/space.ts +24 -5
  162. package/src/mv/mv-md.ts +63 -22
  163. package/src/pages/forward.ts +35 -0
  164. package/src/pages/frame-client.ts +118 -0
  165. package/src/pages/routes.ts +29 -0
  166. package/src/pages/unit.ts +92 -0
  167. package/src/plan/planner.ts +12 -0
  168. package/src/plan/repo-source.ts +19 -5
  169. package/src/reflect/transcript.ts +35 -10
  170. package/src/release/public-clean.ts +319 -0
  171. package/src/release/published-here.ts +22 -0
  172. package/src/release/run-bump.ts +3 -2
  173. package/src/release/run-release.ts +7 -4
  174. package/src/repo-config.ts +71 -13
  175. package/src/review/anim.ts +1 -1
  176. package/src/review/auto.ts +1 -1
  177. package/src/review/cells.ts +15 -1
  178. package/src/review/format.ts +2 -2
  179. package/src/review/http.ts +16 -2
  180. package/src/review/marks.ts +1 -1
  181. package/src/review/media-kind.ts +1 -1
  182. package/src/review/media-read.ts +1 -1
  183. package/src/review/model.ts +27 -6
  184. package/src/review/notes.ts +125 -0
  185. package/src/review/previews.ts +1 -1
  186. package/src/review/project.ts +7 -39
  187. package/src/review/role.ts +1 -1
  188. package/src/review/routes.ts +18 -14
  189. package/src/review/store.ts +42 -2
  190. package/src/review/threads.ts +1 -1
  191. package/src/review/trailer-desk.ts +3 -3
  192. package/src/review/trailer-media.ts +8 -5
  193. package/src/review/trailer-model.ts +1 -1
  194. package/src/review/trailer-routes.ts +1 -1
  195. package/src/review/trailer-shots.ts +22 -5
  196. package/src/review/unit.ts +2 -2
  197. package/src/scaffold/files/agent-handoff.md +3 -0
  198. package/src/scaffold/files/agent-index.md +4 -12
  199. package/src/scaffold/files/tsconfig.json +1 -1
  200. package/src/scaffold/project-scaffold.ts +6 -5
  201. package/src/serve/embed.ts +2 -2
  202. package/src/serve/hub-app/check-words.ts +1 -1
  203. package/src/serve/hub-app/col-card.tsx +3 -17
  204. package/src/serve/hub-app/col-tables-view.tsx +2 -1
  205. package/src/serve/hub-app/cols-svc.ts +0 -13
  206. package/src/serve/hub-app/dock-st.ts +4 -2
  207. package/src/serve/hub-app/dock-view.tsx +2 -0
  208. package/src/serve/hub-app/frames-st.ts +35 -0
  209. package/src/serve/hub-app/hash-route.ts +64 -1
  210. package/src/serve/hub-app/home-st.ts +32 -8
  211. package/src/serve/hub-app/home-strip.css +9 -1
  212. package/src/serve/hub-app/home-strip.tsx +7 -6
  213. package/src/serve/hub-app/home.html +5 -0
  214. package/src/serve/hub-app/hub-app.tsx +51 -7
  215. package/src/serve/hub-app/hub.css +29 -11
  216. package/src/serve/hub-app/icons.tsx +16 -1
  217. package/src/serve/hub-app/identities-st.ts +210 -0
  218. package/src/serve/hub-app/identities-view.tsx +353 -0
  219. package/src/serve/hub-app/identities.css +48 -0
  220. package/src/serve/hub-app/identity-address.ts +52 -0
  221. package/src/serve/hub-app/inbox-st.ts +60 -7
  222. package/src/serve/hub-app/inbox-view.tsx +49 -7
  223. package/src/serve/hub-app/inbox.css +12 -1
  224. package/src/serve/hub-app/index.html +3 -0
  225. package/src/serve/hub-app/kept-cols.tsx +30 -0
  226. package/src/serve/hub-app/keys.ts +10 -2
  227. package/src/serve/hub-app/list-walk.ts +89 -0
  228. package/src/serve/hub-app/machine-st.ts +12 -0
  229. package/src/serve/hub-app/media-svc.ts +1 -1
  230. package/src/serve/hub-app/media-view.tsx +2 -1
  231. package/src/serve/hub-app/pages-frames.tsx +134 -0
  232. package/src/serve/hub-app/pages-svc.ts +111 -0
  233. package/src/serve/hub-app/palette-st.ts +18 -3
  234. package/src/serve/hub-app/palette-view.tsx +9 -2
  235. package/src/serve/hub-app/planned-view.tsx +2 -1
  236. package/src/serve/hub-app/project-list.css +18 -14
  237. package/src/serve/hub-app/project-list.tsx +88 -49
  238. package/src/serve/hub-app/projects-svc.ts +33 -3
  239. package/src/serve/hub-app/repo-sections.ts +19 -2
  240. package/src/serve/hub-app/repo-st.ts +76 -20
  241. package/src/serve/hub-app/review/review-board.tsx +1 -1
  242. package/src/serve/hub-app/review/review-cells.tsx +6 -5
  243. package/src/serve/hub-app/review/review-kit.ts +30 -7
  244. package/src/serve/hub-app/review/review-page.tsx +6 -5
  245. package/src/serve/hub-app/review/review-st.ts +34 -15
  246. package/src/serve/hub-app/review/review-thread.tsx +63 -14
  247. package/src/serve/hub-app/review/review-views.tsx +133 -51
  248. package/src/serve/hub-app/review/thread-st.ts +80 -37
  249. package/src/serve/hub-app/review/trailer-page.tsx +7 -5
  250. package/src/serve/hub-app/review/trailer-st.ts +1 -1
  251. package/src/serve/hub-app/review.css +26 -9
  252. package/src/serve/hub-app/site/site-part.tsx +173 -0
  253. package/src/serve/hub-app/site/site-st.ts +157 -0
  254. package/src/serve/hub-app/site.css +35 -0
  255. package/src/serve/hub-app/social/calendar.tsx +182 -0
  256. package/src/serve/hub-app/social/comms-page.tsx +330 -0
  257. package/src/serve/hub-app/social/kit.tsx +244 -0
  258. package/src/serve/hub-app/social/post-card.tsx +456 -0
  259. package/src/serve/hub-app/social/problems.tsx +60 -0
  260. package/src/serve/hub-app/social/social-model.ts +154 -0
  261. package/src/serve/hub-app/social/social-page.tsx +681 -0
  262. package/src/serve/hub-app/social/social-st.ts +1014 -0
  263. package/src/serve/hub-app/social.css +289 -0
  264. package/src/serve/hub-app/stores/stores-page.tsx +312 -0
  265. package/src/serve/hub-app/stores/stores-st.ts +286 -0
  266. package/src/serve/hub-app/stores.css +54 -0
  267. package/src/serve/hub-app/timeline-geometry.ts +1 -1
  268. package/src/serve/hub-app/timeline-view.tsx +3 -2
  269. package/src/serve/hub-app/tree-build.ts +6 -0
  270. package/src/serve/hub-app/tree-row.tsx +27 -4
  271. package/src/serve/hub-app/tree-svc.ts +18 -49
  272. package/src/serve/hub-app/veille/veille-page.tsx +515 -0
  273. package/src/serve/hub-app/veille/veille-st.ts +443 -0
  274. package/src/serve/hub-app/veille.css +84 -0
  275. package/src/serve/hub-runtime.ts +20 -11
  276. package/src/serve/project-gutter-route.ts +44 -12
  277. package/src/serve/run-lanes.ts +7 -4
  278. package/src/serve/same-origin.ts +1 -1
  279. package/src/serve/serve-hub.ts +20 -12
  280. package/src/serve/tracked-watch.ts +24 -3
  281. package/src/serve/warm-cell.ts +5 -1
  282. package/src/shipkit-files.ts +15 -4
  283. package/src/shipkit.ts +0 -1
  284. package/src/shot/box.ts +160 -0
  285. package/src/shot/browser-slot.ts +74 -0
  286. package/src/shot/client.ts +42 -7
  287. package/src/shot/clip-encoder.ts +108 -24
  288. package/src/shot/film-box.ts +292 -0
  289. package/src/shot/shooter.ts +71 -17
  290. package/src/shot/shot-ask.ts +10 -2
  291. package/src/shot/stepped-clip.ts +5 -4
  292. package/src/site/desk.ts +242 -0
  293. package/src/site/routes.ts +66 -0
  294. package/src/site/unit.ts +62 -0
  295. package/src/social/brands.ts +22 -0
  296. package/src/social/card-drafts.ts +24 -0
  297. package/src/social/compose.ts +97 -0
  298. package/src/social/desk-index.ts +123 -0
  299. package/src/social/desk-wire.ts +64 -0
  300. package/src/social/drafts.ts +183 -0
  301. package/src/social/house.ts +24 -0
  302. package/src/social/load.ts +332 -0
  303. package/src/social/md.ts +70 -0
  304. package/src/social/media-facts.ts +53 -0
  305. package/src/social/media-kind.ts +189 -0
  306. package/src/social/media-limit.ts +42 -0
  307. package/src/social/media-of.ts +30 -0
  308. package/src/social/migrate.ts +123 -0
  309. package/src/social/open.ts +17 -0
  310. package/src/social/post-url.ts +158 -0
  311. package/src/social/presence.ts +332 -0
  312. package/src/social/public-read.ts +53 -0
  313. package/src/social/publish/bluesky.ts +168 -0
  314. package/src/social/publish/discord.ts +76 -0
  315. package/src/social/publish/index.ts +24 -0
  316. package/src/social/publish/secret.ts +13 -0
  317. package/src/social/push.ts +37 -0
  318. package/src/social/richtext.ts +37 -0
  319. package/src/social/routes.ts +186 -0
  320. package/src/social/stats.ts +134 -0
  321. package/src/social/text.ts +267 -0
  322. package/src/social/tracker-route.ts +39 -0
  323. package/src/social/tracker.ts +255 -0
  324. package/src/social/unit.ts +53 -0
  325. package/src/social/writes.ts +130 -0
  326. package/src/start-repo.ts +14 -9
  327. package/src/stores/collection.ts +27 -0
  328. package/src/stores/desk.ts +336 -0
  329. package/src/stores/model.ts +187 -0
  330. package/src/stores/routes.ts +126 -0
  331. package/src/stores/unit.ts +57 -0
  332. package/src/suite/calibrate.ts +127 -0
  333. package/src/suite/core-counters.ts +91 -0
  334. package/src/suite/judge-suites.ts +95 -35
  335. package/src/suite/suite-cli.ts +44 -10
  336. package/src/suite/suite-cpu-preload.ts +34 -9
  337. package/src/trace/tracer.ts +12 -5
  338. package/src/trailer/adapter.ts +5 -1
  339. package/src/trailer/build.ts +45 -12
  340. package/src/trailer/ffmpeg.ts +11 -0
  341. package/src/trailer/footage.ts +30 -13
  342. package/src/trailer/grammar.ts +18 -2
  343. package/src/trailer/graph.ts +28 -6
  344. package/src/trailer/holes.ts +1 -1
  345. package/src/trailer/passage.ts +18 -6
  346. package/src/trailer/plan.ts +74 -3
  347. package/src/trailer/prune.ts +1 -1
  348. package/src/trailer/states.ts +1 -1
  349. package/src/trailer/stitch.ts +67 -26
  350. package/src/trailer/url.ts +1 -1
  351. package/src/trailer/versions.ts +24 -0
  352. package/src/trailer/words.ts +1 -1
  353. package/src/ts/gate-typecheck.ts +32 -0
  354. package/src/ts/typecheck-cli.ts +9 -11
  355. package/src/tui/run-tui.ts +1 -1
  356. package/src/tui/tui-app.tsx +0 -1
  357. package/src/tui/tui-store.ts +1 -1
  358. package/src/veille/asks.ts +155 -0
  359. package/src/veille/auto.ts +31 -0
  360. package/src/veille/batch.ts +27 -0
  361. package/src/veille/chrome.ts +127 -0
  362. package/src/veille/collection.ts +28 -0
  363. package/src/veille/desk.ts +242 -0
  364. package/src/veille/identity.ts +80 -0
  365. package/src/veille/import.ts +68 -0
  366. package/src/veille/log.ts +183 -0
  367. package/src/veille/platforms.ts +118 -0
  368. package/src/veille/reads.ts +66 -0
  369. package/src/veille/replied.ts +110 -0
  370. package/src/veille/routes.ts +185 -0
  371. package/src/veille/service.ts +81 -0
  372. package/src/veille/watch.ts +116 -0
  373. package/src/veille/worth.ts +46 -0
  374. package/src/wiki/scan-md.ts +18 -0
  375. package/src/collections/posts.ts +0 -142
  376. package/src/contracts/manifests/social.contract.ts +0 -20
  377. package/src/scaffold/files/agent-coding.md +0 -35
  378. package/src/ts/typecheck-cache.ts +0 -11
@@ -10,6 +10,7 @@
10
10
  // /api/projects/fork in Fork: a request names a repo, never a path. The rail ORDER is one text file for the whole machine
11
11
  // (ORDER_FILE), so every hub shows the same order and a hand edit is seen
12
12
  // within one poll; POST /api/projects/order writes it.
13
+ import { loopWatch } from '../core/loop-watch.ts'
13
14
  import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync } from 'fs'
14
15
  import { readFile, stat } from 'fs/promises'
15
16
  import { homedir } from 'os'
@@ -24,7 +25,11 @@ import { identityOfText, identityProblem, type Identity } from '../core/identity
24
25
  import { writeIdentity } from '../core/identity.ts'
25
26
  import { appIconOf, appIconPngs, identityOfRoot } from '../core/app-icon.ts'
26
27
  import { waitingCards } from '../collections/review.ts'
28
+ import { storeDir, warmStore } from '../review/store.ts'
27
29
  import { writeArchived } from '../core/archived.ts'
30
+ import { identitiesDir } from '../identities/identities.ts'
31
+ import { identityCache, markFile, railOf, speakerIdOf, type RailIdentity } from '../identities/machine.ts'
32
+ import { speaksAsOfText } from '../social/house.ts'
28
33
 
29
34
  export type { Gate }
30
35
 
@@ -42,6 +47,8 @@ function cardsOf(path: string): ProjectRow['cards'] {
42
47
  const PREVIEW_PX = 256
43
48
  /** the rail's app icon, cropped to the plate: 40px at 2x, the largest rail size */
44
49
  const RAIL_PX = 96
50
+ /** the plate's opacity on a rail row that is not shown: the mark stays whole, project-list.css fades the rest */
51
+ const DIM_PLATE = 0.5
45
52
  /** how long a release answer holds for a checkout whose `.git` is not a
46
53
  * folder, since no stat can say when it moved */
47
54
  export const RELEASE_TTL_MS = 60_000
@@ -88,8 +95,12 @@ export type ProjectRow = {
88
95
  live: string | null
89
96
  /** the colours its repo.config.ts declares (SK024), null when it declares none */
90
97
  identity: Identity | null
98
+ /** the identity it speaks as (wiki tools/shipkit/social.md): its `speaksAs`, else the default; null when none holds it */
99
+ speaksAs: string | null
91
100
  /** its app icon cropped to the plate (core/app-icon.ts), what the folded rail draws; null with no mark */
92
101
  appIcon: string | null
102
+ /** the same with its plate faded and its mark whole: the folded rail's rows that are not shown */
103
+ appIconDim: string | null
93
104
  /** epoch ms of the newest of: the last commit, the last shipkit run, the
94
105
  * newest Claude Code transcript. null when none of them exists */
95
106
  activity: number | null
@@ -99,7 +110,8 @@ export type ProjectRow = {
99
110
  /** a repo whose repo.config.ts says `archived: true`: only the archived page lists it */
100
111
  export type ArchivedRow = { name: string; icon: string | null }
101
112
 
102
- export type ProjectsAnswer = { projects: ProjectRow[]; archived: ArchivedRow[]; ms: number; at: number }
113
+ /** `identities`: every identity of the machine, in their order, as the list's headers draw them */
114
+ export type ProjectsAnswer = { projects: ProjectRow[]; archived: ArchivedRow[]; identities: RailIdentity[]; ms: number; at: number }
103
115
 
104
116
  /** a command's exit code and stdout, or null when its binary is missing */
105
117
  export type Run = (cmd: string[], cwd?: string) => Promise<{ code: number; out: string } | null>
@@ -132,7 +144,7 @@ const runCmd: Run = async (cmd, cwd) => {
132
144
  return { code: await p.exited, out }
133
145
  }
134
146
 
135
- function openInCode(path: string): void {
147
+ export function openInCode(path: string): void {
136
148
  const code = Bun.which('code')
137
149
  if (code != null) {
138
150
  Bun.spawn([code, path], { stdio: ['ignore', 'ignore', 'ignore'] }).unref()
@@ -315,26 +327,36 @@ export function projectGutter(d: GutterDeps) {
315
327
 
316
328
  const iconUrl = (r: WiredRepo): string | null => (r.icon == null ? null : `/api/projects/icon/${encodeURIComponent(r.name)}?v=${iconStamp(join(r.path, r.icon))}`)
317
329
  // the url names the mark's stamp and both colours, so a new mark or a colour change is a new url, cached a day
318
- const railIconUrl = (r: WiredRepo, id: Identity): string | null => {
330
+ const railIconUrl = (r: WiredRepo, id: Identity, plate: '1' | 'dim' = '1'): string | null => {
319
331
  const mark = appIconOf(r.path)
320
332
  if (mark == null) return null
321
- const q = new URLSearchParams({ plate: '1', light: id.colorLight, dark: id.colorDark, v: String(iconStamp(mark)) })
333
+ const q = new URLSearchParams({ plate, light: id.colorLight, dark: id.colorDark, v: String(iconStamp(mark)) })
322
334
  return `/api/projects/app-icon/${encodeURIComponent(r.name)}?${q}`
323
335
  }
324
336
  /** drawn plates, by url: a page load asks for every repo's at once */
325
337
  const plates = new Map<string, Promise<Buffer>>()
338
+ const identities = identityCache()
339
+ let idDir: string | null | undefined
340
+ const readIds = async () => identities(idDir === undefined ? (idDir = await identitiesDir(d.root)) : idDir)
326
341
 
327
342
  async function measure(): Promise<ProjectsAnswer> {
328
343
  const t0 = performance.now()
329
- const house = houseRepos(d.root, userHome)
344
+ const house = loopWatch.timed('projects: house repos', () => houseRepos(d.root, userHome))
330
345
  home = house.home
331
346
  if (house.index == null) warnOnce('house', `WARN project gutter: ${home} includes no house wiki index, so no sibling shares one and the gutter is empty`)
332
347
  repos = house.repos
333
348
  archivedRepos = house.archived
334
- const [open, cwds, facts] = await Promise.all([vscodeFolders(), sessionCwds(), gitFacts(repos.map((r) => r.path))])
335
- const transcripts = lastSessionAt(transcriptRoots(), repos.map((r) => r.path))
349
+ const [open, cwds, facts] = await Promise.all([
350
+ loopWatch.spanned('projects: vscode', vscodeFolders),
351
+ loopWatch.spanned('projects: sessions', sessionCwds),
352
+ loopWatch.spanned('projects: git', () => gitFacts(repos.map((r) => r.path))),
353
+ ])
354
+ const transcripts = loopWatch.timed('projects: transcripts', () => lastSessionAt(transcriptRoots(), repos.map((r) => r.path)))
336
355
  const counts = cwds == null ? null : countSessions(cwds, repos.map((r) => r.path))
337
- const projects = repos.map((r, i): ProjectRow => {
356
+ const ids = await loopWatch.spanned('projects: ids', readIds)
357
+ // each store read whole once, in steps, before the rows read its waiting cards
358
+ await loopWatch.spanned('projects: review stores', async () => { for (const r of repos) await warmStore(storeDir(r.path)) })
359
+ const projects = repos.map((r, i): ProjectRow => loopWatch.timed(`projects: row ${r.name}`, () => {
338
360
  const config = readText(join(r.path, 'repo.config.ts'))
339
361
  const pkg = readText(join(r.path, 'package.json'))
340
362
  const asks = openAsks(join(r.path, asksDirOf(config, r.path)))
@@ -360,13 +382,15 @@ export function projectGutter(d: GutterDeps) {
360
382
  release: facts[i]!.release,
361
383
  live: liveUrlOf(config),
362
384
  identity: identityOfText(config),
385
+ speaksAs: speakerIdOf(speaksAsOfText(config), ids),
363
386
  appIcon: railIconUrl(r, identityOfRoot(r.path)),
387
+ appIconDim: railIconUrl(r, identityOfRoot(r.path), 'dim'),
364
388
  activity: lastActivity(facts[i]!.commitAt, lastRunAt(r.path), transcripts.get(r.path)),
365
389
  commit: facts[i]!.commitAt,
366
390
  }
367
- })
391
+ }))
368
392
  const archived = archivedRepos.map((r) => ({ name: r.name, icon: iconUrl(r) }))
369
- return { projects: inOrder(projects, parseOrder(readText(orderFile))), archived, ms: Math.round(performance.now() - t0), at: now() }
393
+ return { projects: inOrder(projects, parseOrder(readText(orderFile))), archived, identities: ids.identities.map(railOf), ms: Math.round(performance.now() - t0), at: now() }
370
394
  }
371
395
 
372
396
  /** the last answer while it is younger than POLL_MS, one measure otherwise,
@@ -412,6 +436,13 @@ export function projectGutter(d: GutterDeps) {
412
436
  headers: { 'content-type': ICON_TYPES[r.icon.split('.').pop()!] ?? 'application/octet-stream', 'cache-control': 'max-age=86400' },
413
437
  })
414
438
  }
439
+ if (path.startsWith('/api/projects/identity-mark/')) {
440
+ const id = decodeURIComponent(path.slice('/api/projects/identity-mark/'.length))
441
+ const i = (await readIds()).identities.find((x) => x.id === id)
442
+ const file = i == null ? null : markFile(i)
443
+ if (file == null || !existsSync(file)) return new Response(`no mark for the identity ${JSON.stringify(id)}`, { status: 404 })
444
+ return new Response(Bun.file(file), { headers: { 'cache-control': 'max-age=86400' } })
445
+ }
415
446
  if (path.startsWith('/api/projects/app-icon/')) {
416
447
  if (repos.length === 0) await answer()
417
448
  const r = findAny(decodeURIComponent(path.slice('/api/projects/app-icon/'.length)))
@@ -423,11 +454,12 @@ export function projectGutter(d: GutterDeps) {
423
454
  const asked = { colorLight: q.get('light') ?? '', colorDark: q.get('dark') ?? '' }
424
455
  const id = identityProblem(asked) == null ? asked : identityOfRoot(r.path)
425
456
  try {
426
- if (q.get('plate') === '1') {
457
+ const plate = q.get('plate')
458
+ if (plate === '1' || plate === 'dim') {
427
459
  const key = `${r.path}?${q}`
428
460
  let png = plates.get(key)
429
461
  if (png == null) {
430
- png = readFile(icon).then(async (b) => (await appIconPngs(b, id, [RAIL_PX], 'plate'))[0]!)
462
+ png = readFile(icon).then(async (b) => (await appIconPngs(b, id, [RAIL_PX], 'plate', { plateAlpha: plate === 'dim' ? DIM_PLATE : 1 }))[0]!)
431
463
  plates.set(key, png)
432
464
  png.catch(() => plates.delete(key))
433
465
  }
@@ -108,10 +108,13 @@ export function runKey(kind: string, opts: Record<string, unknown>): string {
108
108
  return `${kind} ${JSON.stringify(sorted)}`
109
109
  }
110
110
 
111
- /** a run whose repair pass runs (core/fix-scope.ts): the structural fixers
112
- * and the hooks only ever run inside it */
113
- export const writesTree = (opts: Record<string, unknown>): boolean =>
114
- fixPassRuns({ fix: typeof opts.fix === 'boolean' ? opts.fix : undefined, onlyIds: Array.isArray(opts.onlyIds) ? (opts.onlyIds as string[]) : undefined })
111
+ /** a WHOLE gate whose repair pass runs (core/fix-scope.ts): its tree wide
112
+ * fixers and the hooks run there. A narrowed run repairs only what its checks
113
+ * own, under the fix lease, so it never makes other lanes wait */
114
+ export const writesTree = (opts: Record<string, unknown>): boolean => {
115
+ const onlyIds = Array.isArray(opts.onlyIds) ? (opts.onlyIds as string[]) : undefined
116
+ return (onlyIds ?? []).length === 0 && fixPassRuns({ fix: typeof opts.fix === 'boolean' ? opts.fix : undefined, onlyIds })
117
+ }
115
118
 
116
119
  /** HEAD, what git status lists, and the stat of each listed path, hashed:
117
120
  * equal stamps mean no tracked or untracked file moved in between. Null
@@ -10,7 +10,7 @@ export function sameOrigin(req: Request): boolean {
10
10
  if (site != null && site !== 'same-origin' && site !== 'none') return false
11
11
  const origin = req.headers.get('origin')
12
12
  if (origin == null) return true
13
- // behind a proxy that frames the page under its own origin (pkm-multi's admin), the host the browser asked is the
13
+ // behind a proxy that frames the page under its own origin (a project's admin), the host the browser asked is the
14
14
  // proxy's, which it passes on. A browser cannot forge the header: a page of another site that sets it is held at
15
15
  // its preflight, which this server never answers
16
16
  const host = req.headers.get('x-forwarded-host') ?? new URL(req.url).host
@@ -11,7 +11,7 @@ import { pageOf, searchWiki } from 'rvlib-shipkit/src/wiki/graph-pages.ts'
11
11
  import { graphRoutes } from 'rvlib-shipkit/src/wiki/serve-graph.ts'
12
12
  import type { StudioRoutes } from '../assets/server/studio-server.ts'
13
13
  import { comfyBoxUp, type ComfyBox, type ComfyPanelUp } from '../comfy/comfy-panel.ts'
14
- import { appendAskRemark, appendAssetNote, appendPostFeedback, askDone, askProof, markPosted, pickPostVariant } from '../collections/actions.ts'
14
+ import { appendAskRemark, appendAssetNote, askDone, askProof } from '../collections/actions.ts'
15
15
  import { brokenRow, projectResources, type Collection, type Instance, type NeedItem, type Resource } from '../collections/collection-types.ts'
16
16
  import type { CheckEvent } from '../core/run-check.ts'
17
17
  import { configDirty, readGateBlock, writeGateBlock, type GateEdit } from '../core/when-block.ts'
@@ -36,7 +36,11 @@ import { WarmCell } from './warm-cell.ts'
36
36
  import { resourcesAnswer, testRunsAnswer } from './resources-wire.ts'
37
37
  import { readmeRoutes } from './readme-route.ts'
38
38
  import { reviewRoutes } from '../review/routes.ts'
39
+ import { veilleRoutes } from '../veille/routes.ts'
40
+ import { storesRoutes } from '../stores/routes.ts'
41
+ import { socialRoutes } from '../social/routes.ts'
39
42
  import { embedRoute } from './embed.ts'
43
+ import { pagesRoutes } from '../pages/routes.ts'
40
44
 
41
45
  export { sameOrigin }
42
46
 
@@ -186,10 +190,10 @@ export function hubHandler(d: HubDeps, o: { base?: string; projects?: Gutter } =
186
190
  await d.refresh?.()
187
191
  const cols = d.collections()
188
192
  return { collections: cols.map((c) => ({ id: c.id, title: c.title, media: c.media })), resources: await projectResources(cols, d.hubProblems?.collector) }
189
- }, warmOpts)
193
+ }, { ...warmOpts, what: `warm rows: ${d.name}` })
190
194
  // the run record and the config are all it reads, and the stamp sees both
191
- const timeline = d.timeline == null ? null : new WarmCell(d.timeline, { stamp: d.stamp })
192
- const graphs = new Map(d.graphs.map((g) => [g.id, new WarmCell(async () => g.load(), { maxAgeMs: WARM_MAX_AGE_MS })]))
195
+ const timeline = d.timeline == null ? null : new WarmCell(d.timeline, { stamp: d.stamp, what: `warm timeline: ${d.name}` })
196
+ const graphs = new Map(d.graphs.map((g) => [g.id, new WarmCell(async () => g.load(), { maxAgeMs: WARM_MAX_AGE_MS, what: `warm graph ${g.id}: ${d.name}` })]))
193
197
  const fresh = (req: Request): boolean => new URL(req.url).searchParams.get('fresh') === '1'
194
198
  /** the last gzipped list, answered again to the next page while it holds */
195
199
  let zipped: Parameters<typeof resourcesAnswer>[3] = null
@@ -276,13 +280,6 @@ export function hubHandler(d: HubDeps, o: { base?: string; projects?: Gutter } =
276
280
  const b = (await req.json()) as Record<string, string>
277
281
  if (path === '/api/act/ask-done') askDone(d.root, d.asksDir, b.file ?? '')
278
282
  else if (path === '/api/act/ask-proof') askProof(d.root, d.asksDir, b.file ?? '', b.url ?? '')
279
- else if (path === '/api/act/post-pick') pickPostVariant(d.root, b.channel ?? '', b.file ?? '')
280
- else if (path === '/api/act/post-posted') {
281
- const rating = b.rating != null ? Number(b.rating) : undefined
282
- if (rating != null && (!Number.isFinite(rating) || rating < 1 || rating > 5)) return new Response('rating must be 1-5', { status: 400 })
283
- markPosted(d.root, b.channel ?? '', b.file ?? '', b.url ?? '', rating)
284
- }
285
- else if (path === '/api/act/post-feedback') appendPostFeedback(d.root, b.channel ?? '', b.file ?? '', b.text ?? '')
286
283
  else if (path === '/api/act/remark') {
287
284
  // ONE remark verb, routed by collection: a remark
288
285
  // lands in the item's own truth file
@@ -290,7 +287,6 @@ export function hubHandler(d: HubDeps, o: { base?: string; projects?: Gutter } =
290
287
  if (text === '') return new Response('empty remark', { status: 400 })
291
288
  if (b.kind === 'ask') appendAskRemark(d.root, d.asksDir, b.file ?? '', text)
292
289
  else if (b.kind === 'media') appendAssetNote(d.root, b.id ?? '', text)
293
- else if (b.kind === 'post') appendPostFeedback(d.root, b.channel ?? '', b.file ?? '', text)
294
290
  else return new Response('unknown remark kind', { status: 400 })
295
291
  }
296
292
  else return new Response('unknown act', { status: 404 })
@@ -346,12 +342,24 @@ export function hubHandler(d: HubDeps, o: { base?: string; projects?: Gutter } =
346
342
  // the empty page shows the README, its images served from the repo
347
343
  const readme = await readmeRoutes(d.root, path)
348
344
  if (readme != null) return readme
345
+ // the repo's own pages: their list, each one proxied from the repo's process (pages/routes.ts)
346
+ const pages = await pagesRoutes(d.root, req, path, srv)
347
+ if (pages != null) return pages
349
348
  // the review or trailer page alone, for another tool's frame (embed.ts)
350
349
  const embed = await embedRoute(path)
351
350
  if (embed != null) return embed
352
351
  // the one feedback store and the trailer view (review/routes.ts)
353
352
  const review = await reviewRoutes(d.root, req, path)
354
353
  if (review != null) return review
354
+ // the Veille of the identity this repo speaks as (veille/routes.ts)
355
+ const veille = await veilleRoutes(d.root, req, path)
356
+ if (veille != null) return veille
357
+ // the store pages' desk (stores/routes.ts)
358
+ const stores = await storesRoutes(d.root, req, path)
359
+ if (stores != null) return stores
360
+ // the Communications and Social desks (social/routes.ts)
361
+ const social = await socialRoutes(d.root, req, path)
362
+ if (social != null) return social
355
363
  if (path === '/api/status.json') {
356
364
  const p = join(d.root, LAYOUT.status)
357
365
  return Response.json({ statusMd: existsSync(p) ? await Bun.file(p).text() : null })
@@ -7,6 +7,8 @@ import { join } from 'path'
7
7
  import { GENERATED_IGNORE_LINES } from '../rules/untrack-generated.ts'
8
8
  import { gitBin } from '../core/git-bin.ts'
9
9
  import { LAYOUT } from '../core/layout.ts'
10
+ import { followTree, treeMoved } from '../core/tree-rev.ts'
11
+ import { yieldLoop } from '../core/loop-watch.ts'
10
12
 
11
13
  /** every path a run of the gate or the hub itself writes, whatever the repo
12
14
  * ignores: the status files, the per run logs under the scratch dir, an atomic write's
@@ -58,8 +60,14 @@ export function isRefMove(rel: string): boolean {
58
60
  * or untracked and not ignored. What the gate itself writes (GATE_WRITES,
59
61
  * the ledger in .git) never counts, ignored or not, so a run never triggers
60
62
  * the next one */
61
- export function watchTracked(root: string, onChange: () => void, o: { ignored?: (paths: string[]) => Promise<Set<string>>; onError?: (e: Error) => void } = {}): { close: () => void; error: string | null } {
63
+ export function watchTracked(root: string, onOwnerEdit: () => void, o: { ignored?: (paths: string[]) => Promise<Set<string>>; onError?: (e: Error) => void } = {}): { close: () => void; error: string | null } {
62
64
  const ignored = o.ignored ?? ((paths: string[]) => gitIgnored(root, paths))
65
+ // the tree's revision (core/tree-rev.ts) moves with every edit this watch hears, and is gone with the watch
66
+ let unfollow: (() => void) | null = null
67
+ const onChange = (): void => {
68
+ treeMoved(root)
69
+ onOwnerEdit()
70
+ }
63
71
  const pending = new Set<string>()
64
72
  let flushing = false
65
73
  const flush = async (): Promise<void> => {
@@ -89,11 +97,21 @@ export function watchTracked(root: string, onChange: () => void, o: { ignored?:
89
97
  })
90
98
  // a watcher that dies mid session (the tree was removed, a limit hit)
91
99
  // says so, rather than crashing the hub or going quiet
92
- w.on('error', (e) => o.onError?.(e instanceof Error ? e : new Error(String(e))))
100
+ w.on('error', (e) => {
101
+ unfollow?.()
102
+ o.onError?.(e instanceof Error ? e : new Error(String(e)))
103
+ })
104
+ unfollow = followTree(root)
93
105
  } catch (e) {
94
106
  error = e instanceof Error ? e.message : String(e)
95
107
  }
96
- return { close: () => w?.close(), error }
108
+ return {
109
+ close: () => {
110
+ unfollow?.()
111
+ w?.close()
112
+ },
113
+ error,
114
+ }
97
115
  }
98
116
 
99
117
  /** did the owner edit anything after `since`: a tracked file, or an untracked
@@ -112,7 +130,10 @@ export async function movedSince(root: string, since: number): Promise<boolean>
112
130
  const later = (rel: string): boolean => {
113
131
  try { return statSync(join(root, rel)).mtimeMs > since } catch { return false }
114
132
  }
133
+ let n = 0
115
134
  for (const rel of out.split('\0')) {
135
+ // a stat a file over tens of thousands: the loop is given back between two thousand of them
136
+ if (++n % 2_000 === 0) await yieldLoop()
116
137
  if (rel === '' || rel.split('/').includes('node_modules') || isGateWrite(rel)) continue
117
138
  if (later(rel)) return true
118
139
  }
@@ -9,6 +9,8 @@
9
9
  // changed the truth (an act, the end of a run) asks for `fresh`, which waits
10
10
  // on a compute that started after its call.
11
11
 
12
+ import { loopWatch } from '../core/loop-watch.ts'
13
+
12
14
  /** a cell read within this long has a reader: a save recomputes it in the
13
15
  * background. Past it, nothing recomputes until a reader asks */
14
16
  export const WARM_WATCH_MS = 30_000
@@ -25,6 +27,8 @@ export type WarmCellOpts = {
25
27
  * nothing said it moved: what no watch sees (a clock, another repo) */
26
28
  maxAgeMs?: number
27
29
  now?: () => number
30
+ /** the span a compute carries on the loop watch (core/loop-watch.ts), so a stall names it */
31
+ what?: string
28
32
  }
29
33
 
30
34
  export class WarmCell<T> {
@@ -54,7 +58,7 @@ export class WarmCell<T> {
54
58
  const p = (async (): Promise<T> => {
55
59
  try {
56
60
  // never synchronously: `running` is set before this settles
57
- const v = await Promise.resolve().then(() => this.compute())
61
+ const v = await Promise.resolve().then(() => (this.o.what == null ? this.compute() : loopWatch.spanned(this.o.what, () => this.compute())))
58
62
  this.value = { v, at: this.now(), stamp }
59
63
  return v
60
64
  } finally {
@@ -11,16 +11,26 @@
11
11
  // review({...}) the repo's parts of the review store: its subject
12
12
  // kinds, topics, sources, auto rules, the dispatcher
13
13
  // (review/unit.ts)
14
+ // social({...}) the repo's parts of the social desks: its topics,
15
+ // its articles and their preview (social/unit.ts)
16
+ // stores({...}) the repo's parts of the stores desk: extra texts,
17
+ // the account's ask, the commands that make its
18
+ // pictures again (stores/unit.ts)
19
+ // site({...}) the repo's parts of its identity's site desk: its
20
+ // pages, preview, deploy, what changed (site/unit.ts)
14
21
  //
15
22
  // the one constraint a reader breaks first: every kind is IMPORTED by the
16
23
  // process that reads it (discovery, pm's config child, the daemon), so a file
17
24
  // keeps its top level cheap and puts heavy work inside a function.
18
25
  import { check, type CheckDef } from './check.ts'
19
26
  import { review, type AutoRule, type KindDef, type ReviewDef, type ReviewSource, type ReviewUnit } from './review/unit.ts'
27
+ import { site, type SiteDef, type SiteUnit } from './site/unit.ts'
28
+ import { social, type SocialDef, type SocialUnit } from './social/unit.ts'
29
+ import { stores, type StoresDef, type StoresUnit } from './stores/unit.ts'
20
30
  import { trailer, type TrailerDef, type TrailerUnit } from './trailer/adapter.ts'
21
31
 
22
- export { check, review, trailer }
23
- export type { AutoRule, KindDef, ReviewDef, ReviewSource, ReviewUnit, TrailerDef, TrailerUnit }
32
+ export { check, review, site, social, stores, trailer }
33
+ export type { AutoRule, KindDef, ReviewDef, ReviewSource, ReviewUnit, SiteDef, SiteUnit, SocialDef, SocialUnit, StoresDef, StoresUnit, TrailerDef, TrailerUnit }
24
34
 
25
35
  /** one button beside a global process: a command, or a function of the file */
26
36
  export type ProcessAction = {
@@ -77,7 +87,7 @@ export type WidgetDef = {
77
87
  export type GlobalProcessUnit = GlobalProcessDef & { kind: 'globalProcess' }
78
88
  export type WidgetUnit = WidgetDef & { kind: 'widget' }
79
89
 
80
- export const UNIT_KINDS = ['globalProcess', 'widget', 'trailer', 'review'] as const
90
+ export const UNIT_KINDS = ['globalProcess', 'widget', 'trailer', 'review', 'stores', 'social', 'site', 'page'] as const
81
91
 
82
92
  const KEBAB = /^[a-z0-9][a-z0-9-]*$/
83
93
  const words = (v: unknown): boolean => Array.isArray(v) && v.length > 0 && v.every((w) => typeof w === 'string')
@@ -132,7 +142,8 @@ export function widget(d: WidgetDef): WidgetUnit {
132
142
 
133
143
  /** the kind a default export says it is: a unit, else a check */
134
144
  export function unitKind(d: unknown): (typeof UNIT_KINDS)[number] | 'check' {
135
- const k = (d as { kind?: unknown } | null)?.kind
145
+ // a repo's pages may come as one array (src/pages/unit.ts)
146
+ const k = Array.isArray(d) && d.length > 0 && d.every((u) => (u as { kind?: unknown } | null)?.kind === 'page') ? 'page' : (d as { kind?: unknown } | null)?.kind
136
147
  return UNIT_KINDS.includes(k as (typeof UNIT_KINDS)[number]) ? (k as (typeof UNIT_KINDS)[number]) : 'check'
137
148
  }
138
149
 
package/src/shipkit.ts CHANGED
@@ -20,7 +20,6 @@ export { resolveHubDeps, defaultHubPort, baseWikiRoot, loadHub } from './serve/h
20
20
  export { projectNeeds, redCount } from './collections/collection-types.ts'
21
21
  export type { Collection, Instance, NeedItem, NeedSeverity, CurationVerb } from './collections/collection-types.ts'
22
22
  export { buildCollections } from './collections/providers.ts'
23
- export { socialPostsCollection, listPosts } from './collections/posts.ts'
24
23
  // units — the ONE discovery every release surface reads (drift
25
24
  // probes, per-unit tests, per-unit typecheck, the stranded-tag probe)
26
25
  export { resolveUnits, releaseOrder, unitById, renderTag, tagGlobs, prepublishScripts, unitPrepublishScripts } from './release/units.ts'
@@ -0,0 +1,160 @@
1
+ // THE BOX ROUTE: a repo whose repo.config.ts `browsers.box` names an ssh host films there when it runs on a Mac. Every
2
+ // browser start of the repo (a take, a Shooter: sk shot, look sheets, thumbs, the trailer's films) asks `openBrowser`,
3
+ // which on such a Mac connects to the box's warm chromium (film-box.ts) instead of launching one: its devtools reached
4
+ // through an ssh forward, each localhost page it opens reached back on this Mac through a reverse forward (the urls
5
+ // unchanged), its frames drawn and encoded on the box's GPU, only the result crossing back. Anywhere else, or with
6
+ // SK_FILM_HERE=1 for one run, it launches here as before, under the browser cap either way.
7
+ //
8
+ // The one constraint a reader breaks first: a box that does not answer is one loud line and nothing filmed, never a
9
+ // browser launched on the Mac instead (the Mac is the machine the route protects).
10
+ import { createHash } from 'crypto'
11
+ import { readFileSync } from 'fs'
12
+ import { browserCap, browserSlot, filmBox, HERE_ENV } from './browser-slot.ts'
13
+ import { CDP_PORT } from './film-box.ts'
14
+
15
+
16
+ /** the slice of playwright the route drives: a browser to connect to, its default context, a page's viewport */
17
+ type PwPage = { setViewportSize(v: { width: number; height: number }): Promise<void>; addInitScript(s: { content: string }): Promise<void>; close(): Promise<void> }
18
+ type PwContext = { newPage(): Promise<PwPage>; newCDPSession(p: PwPage): Promise<{ send(m: string, p?: Record<string, unknown>): Promise<unknown> }> }
19
+ export type PwBrowser = { contexts(): PwContext[]; close(): Promise<void>; isConnected(): boolean; on(e: 'disconnected', cb: () => void): void }
20
+ export type Pw = { chromium: { launch(o: { headless: boolean; args: string[] }): Promise<unknown>; connectOverCDP(url: string): Promise<PwBrowser> } }
21
+
22
+ /** a browser opened for a repo: `browser` takes newContext as a launched one does; `reach` before a page goes to a
23
+ * url (the box needs this Mac's localhost port forwarded); `close` ends it and frees its slot */
24
+ export type Opened<B> = { browser: B; where: string; reach(url: string): Promise<void>; close(): Promise<void> }
25
+
26
+ const SSH = (box: string) => ['ssh', '-o', 'ConnectTimeout=5', '-o', 'BatchMode=yes', box]
27
+ /** where the box's devtools answer on this Mac */
28
+ const localCdp = (box: string): number => 40000 + (parseInt(createHash('sha1').update(box).digest('hex').slice(0, 4), 16) % 9000)
29
+ const FILM_DIR = 'dev/shipkit-film'
30
+ const BOX_FILE = new URL('./film-box.ts', import.meta.url).pathname
31
+ const BOX_SCRIPT = readFileSync(BOX_FILE)
32
+ const BOX_HASH = createHash('sha1').update(BOX_SCRIPT).digest('hex').slice(0, 12)
33
+ const MISSING = 86
34
+
35
+ const down = (box: string, why: string): Error =>
36
+ new Error(`${box} is down, nothing filmed (${why.trim().split('\n').at(-1) ?? why}). To film on this Mac for one run: ${HERE_ENV}=1 <the same command>`)
37
+
38
+ async function run(cmd: string[], stdin?: Uint8Array): Promise<{ code: number; out: string; err: string }> {
39
+ const p = Bun.spawn(cmd, { stdin: stdin ?? 'ignore', stdout: 'pipe', stderr: 'pipe' })
40
+ const [out, err] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text()])
41
+ return { code: await p.exited, out, err }
42
+ }
43
+
44
+ /** the box's warm browser answering, its script uploaded first when the box lacks this version of it */
45
+ async function boxUp(box: string, version: string, say: (l: string) => void): Promise<string> {
46
+ const script = `${FILM_DIR}/film-box-${BOX_HASH}.ts`
47
+ const go = () => run([...SSH(box), `if exist ${script.replaceAll('/', '\\')} (bun ${script} up ${version}) else (exit ${MISSING})`])
48
+ let r = await go()
49
+ if (r.code === MISSING) {
50
+ await run([...SSH(box), `mkdir ${FILM_DIR.replaceAll('/', '\\')} 2>nul`])
51
+ const up = await run(['scp', '-q', '-o', 'ConnectTimeout=5', '-o', 'BatchMode=yes', BOX_FILE, `${box}:${script}`])
52
+ if (up.code === 255 && /connect|resolve|timed out|refused/i.test(up.err)) throw down(box, up.err)
53
+ if (up.code !== 0) throw new Error(`${box}: uploading ${script} failed (exit ${up.code}): ${up.err.trim()}`)
54
+ r = await go()
55
+ }
56
+ if (r.code === 255) throw down(box, r.err)
57
+ if (r.code !== 0) throw new Error(`${box}: its film browser did not come up (exit ${r.code}): ${r.err.trim()}`)
58
+ for (const l of r.err.split('\n').filter(Boolean)) say(l)
59
+ return r.out.trim()
60
+ }
61
+
62
+ /** an ssh forward added to the box's master connection (instant, kept with it), else a tunnel process of our own */
63
+ async function forward(box: string, spec: string[], own: { p: ReturnType<typeof Bun.spawn> | null }): Promise<void> {
64
+ const r = await run(['ssh', '-O', 'forward', ...spec, box])
65
+ if (r.code === 0) return
66
+ own.p?.kill()
67
+ own.p = Bun.spawn([...SSH(box), '-N', '-o', 'ExitOnForwardFailure=yes', ...spec], { stdin: 'ignore', stdout: 'ignore', stderr: 'pipe' })
68
+ await Bun.sleep(1500)
69
+ if (own.p.exitCode != null) throw down(box, await new Response(own.p.stderr as ReadableStream).text())
70
+ }
71
+
72
+ const LOCAL = new Set(['localhost', '127.0.0.1', '[::1]'])
73
+
74
+ /** the box's default context as a launched browser's newContext: each context a set of pages there, the viewport set
75
+ * per page; one context because only it keeps the profile's HTTP cache */
76
+ function asLaunched(b: PwBrowser, all: PwPage[]) {
77
+ return {
78
+ isConnected: () => b.isConnected(),
79
+ on: (e: 'disconnected', cb: () => void) => b.on(e, cb),
80
+ close: async () => {
81
+ await Promise.all(all.splice(0).map((p) => p.close().catch(() => undefined)))
82
+ await b.close()
83
+ },
84
+ async newContext(o: { viewport: { width: number; height: number }; deviceScaleFactor: number }) {
85
+ const ctx = b.contexts()[0]
86
+ if (ctx == null) throw new Error('the box browser has no default context')
87
+ const pages: PwPage[] = []
88
+ const scripts: string[] = []
89
+ return {
90
+ async newPage() {
91
+ const p = await ctx.newPage()
92
+ pages.push(p)
93
+ all.push(p)
94
+ await p.setViewportSize(o.viewport)
95
+ if (o.deviceScaleFactor !== 1)
96
+ await (await ctx.newCDPSession(p)).send('Emulation.setDeviceMetricsOverride', { ...o.viewport, deviceScaleFactor: o.deviceScaleFactor, mobile: false })
97
+ for (const content of scripts) await p.addInitScript({ content })
98
+ return p
99
+ },
100
+ newCDPSession: (p: PwPage) => ctx.newCDPSession(p),
101
+ async addInitScript(s: { content: string }) {
102
+ scripts.push(s.content)
103
+ for (const p of pages) await p.addInitScript(s)
104
+ },
105
+ async close() {
106
+ await Promise.all(pages.splice(0).map((p) => p.close().catch(() => undefined)))
107
+ },
108
+ }
109
+ },
110
+ }
111
+ }
112
+
113
+ /** a browser for `who` of the repo at `root`: on its box from a Mac (filmBox), else launched here; one of the repo's
114
+ * browser slots held until close */
115
+ export async function openBrowser<B>(pw: Pw, o: { root?: string; who: string; args: string[]; say?: (l: string) => void }): Promise<Opened<B>> {
116
+ const say = o.say ?? ((l: string) => console.error(l))
117
+ const cap = await browserCap(o.root)
118
+ const box = filmBox(cap)
119
+ const release = await browserSlot(o.who, { ...(o.root ? { root: o.root } : {}), say, onBox: box != null })
120
+ try {
121
+ if (box == null) {
122
+ const b = (await pw.chromium.launch({ headless: true, args: o.args })) as B & { close(): Promise<void> }
123
+ return { browser: b, where: 'here', reach: async () => undefined, close: () => b.close().catch(() => undefined).finally(release) }
124
+ }
125
+ const t = performance.now()
126
+ const version = (JSON.parse(readFileSync(Bun.resolveSync('playwright-core/package.json', import.meta.dir), 'utf8')) as { version: string }).version
127
+ const state = await boxUp(box, version, say)
128
+ const own: { p: ReturnType<typeof Bun.spawn> | null } = { p: null }
129
+ // the box's browser answers on the port up names (a replacement runs beside a draining one on another)
130
+ const port = Number(/ port (\d+)/.exec(state)?.[1] ?? CDP_PORT)
131
+ const cdp = localCdp(box) + (port - CDP_PORT)
132
+ await forward(box, ['-L', `${cdp}:127.0.0.1:${port}`], own)
133
+ const b = await pw.chromium.connectOverCDP(`http://127.0.0.1:${cdp}`)
134
+ say(`${o.who}: filming on ${box} (${state.split(' ').slice(0, 2).join(' ')}, ${Math.round(performance.now() - t)} ms to its browser)`)
135
+ const reached = new Set<number>()
136
+ const pages: PwPage[] = []
137
+ const browser = asLaunched(b, pages)
138
+ return {
139
+ browser: browser as B,
140
+ where: box,
141
+ async reach(url: string) {
142
+ const u = new URL(url)
143
+ if (!LOCAL.has(u.hostname)) return
144
+ const port = Number(u.port || (u.protocol === 'https:' ? 443 : 80))
145
+ if (reached.has(port)) return
146
+ await forward(box, ['-R', `${port}:127.0.0.1:${port}`], own)
147
+ reached.add(port)
148
+ },
149
+ async close() {
150
+ // its pages close, the connection drops, the box's browser stays warm
151
+ await browser.close().catch(() => undefined)
152
+ own.p?.kill()
153
+ release()
154
+ },
155
+ }
156
+ } catch (e) {
157
+ release()
158
+ throw e
159
+ }
160
+ }