rvlib-shipkit 2.11.0 → 2.13.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 (298) hide show
  1. package/CHANGELOG.md +56 -12
  2. package/README.md +1 -1
  3. package/package.json +4 -2
  4. package/src/agent-time/store.ts +2 -2
  5. package/src/check.ts +1 -1
  6. package/src/checks/SK001-package-json-shape.check.ts +4 -0
  7. package/src/checks/SK003-claude-md-shape.check.ts +1 -1
  8. package/src/checks/SK004-gitignore-policy.check.ts +27 -2
  9. package/src/checks/SK005-rvlib-versions.check.ts +1 -1
  10. package/src/checks/SK008-reviewer-agent.check.ts +2 -2
  11. package/src/checks/SK012-config-barrel-import.check.ts +1 -1
  12. package/src/checks/SK015-nested-repo.check.ts +1 -1
  13. package/src/checks/SK035-public-clean.check.ts +46 -0
  14. package/src/checks/SK036-draft-media-size.check.ts +28 -0
  15. package/src/cli/cmd_Backup.ts +152 -0
  16. package/src/cli/cmd_Ci.ts +8 -11
  17. package/src/cli/cmd_Drill.ts +145 -0
  18. package/src/cli/cmd_Home.ts +50 -3
  19. package/src/cli/cmd_Media.ts +96 -5
  20. package/src/cli/cmd_Review.ts +8 -2
  21. package/src/cli/cmd_Shot.ts +5 -2
  22. package/src/cli/cmd_Smoke.ts +4 -1
  23. package/src/cli/cmd_Social.ts +226 -0
  24. package/src/cli/cmd_Start.ts +1 -1
  25. package/src/cli/cmd_Time.ts +1 -1
  26. package/src/cli/cmd_Trailer.ts +9 -2
  27. package/src/cli/cmd_Veille.ts +173 -0
  28. package/src/cli/family-pages.ts +3 -0
  29. package/src/cli/registry.ts +13 -2
  30. package/src/cli.ts +5 -2
  31. package/src/collections/actions.ts +1 -49
  32. package/src/collections/checks.ts +2 -1
  33. package/src/collections/collection-types.ts +11 -2
  34. package/src/collections/providers.ts +4 -4
  35. package/src/collections/review.ts +2 -1
  36. package/src/collections/tests.ts +19 -8
  37. package/src/contracts/apply-contracts.ts +1 -3
  38. package/src/contracts/contract-manifests.ts +2 -3
  39. package/src/contracts/contract-types.ts +0 -1
  40. package/src/contracts/contracts-engine.ts +0 -3
  41. package/src/core/app-icon.ts +9 -3
  42. package/src/core/bun-builtins.ts +2 -2
  43. package/src/core/discover-checks.ts +37 -5
  44. package/src/core/fix-scope.ts +4 -2
  45. package/src/core/floor-resolve.ts +68 -48
  46. package/src/core/floor.ts +9 -0
  47. package/src/core/git-root.ts +24 -0
  48. package/src/core/last-good.ts +3 -1
  49. package/src/core/layout.ts +8 -0
  50. package/src/core/log-stamp.ts +36 -0
  51. package/src/core/loop-watch.ts +93 -0
  52. package/src/core/machine-link.ts +134 -0
  53. package/src/core/memory-watch.ts +41 -0
  54. package/src/core/one-way-in-policy.ts +27 -19
  55. package/src/core/run-ci.ts +6 -8
  56. package/src/core/run-fixers.ts +9 -9
  57. package/src/core/slots.ts +21 -0
  58. package/src/core/tree-rev.ts +60 -0
  59. package/src/core/unit-files.ts +42 -0
  60. package/src/drill/render.ts +140 -0
  61. package/src/drill/run.ts +269 -0
  62. package/src/fleet/scan-fleet.ts +6 -5
  63. package/src/home/daemon-jobs.ts +201 -0
  64. package/src/home/global-context.ts +34 -1
  65. package/src/home/home-routes.ts +22 -15
  66. package/src/home/hubs.ts +10 -3
  67. package/src/home/inbox-shape.ts +61 -6
  68. package/src/home/inbox.ts +75 -4
  69. package/src/home/lib-watch.ts +10 -3
  70. package/src/home/machine-stores.ts +15 -29
  71. package/src/home/run-daemon.ts +15 -18
  72. package/src/home/run-pm.ts +2 -0
  73. package/src/home/serve-daemon.ts +4 -3
  74. package/src/home/serve-web.ts +110 -1
  75. package/src/hooks/commit-message.ts +28 -19
  76. package/src/hooks/leak-guard.ts +10 -3
  77. package/src/hooks/run-hooks.ts +2 -6
  78. package/src/identities/identities.ts +334 -0
  79. package/src/identities/machine-route.ts +126 -0
  80. package/src/identities/machine.ts +62 -0
  81. package/src/init-repo.ts +1 -1
  82. package/src/ledger/check-stats.ts +10 -9
  83. package/src/ledger/gate-checks.ts +32 -1
  84. package/src/ledger/record-kept.ts +112 -0
  85. package/src/ledger/repo-view.ts +10 -0
  86. package/src/ledger/run-log.ts +17 -12
  87. package/src/ledger/run-timeline.ts +8 -4
  88. package/src/ledger/store.ts +7 -0
  89. package/src/ledger/suite-log.ts +17 -13
  90. package/src/media-kinds.ts +9 -1
  91. package/src/media-store/backup/daemon.ts +73 -0
  92. package/src/media-store/backup/keys.ts +25 -0
  93. package/src/media-store/backup/manifest.ts +193 -0
  94. package/src/media-store/backup/restore.ts +192 -0
  95. package/src/media-store/backup/run.ts +278 -0
  96. package/src/media-store/backup/secret.ts +86 -0
  97. package/src/media-store/backup/snapshot.ts +64 -0
  98. package/src/media-store/backup/sources.ts +199 -0
  99. package/src/media-store/content.ts +11 -1
  100. package/src/media-store/daemon.ts +56 -70
  101. package/src/media-store/hand.ts +58 -0
  102. package/src/media-store/put.ts +122 -0
  103. package/src/media-store/space.ts +73 -11
  104. package/src/pages/forward.ts +35 -0
  105. package/src/pages/frame-client.ts +118 -0
  106. package/src/pages/routes.ts +29 -0
  107. package/src/pages/unit.ts +92 -0
  108. package/src/plan/planner.ts +12 -0
  109. package/src/plan/repo-source.ts +19 -5
  110. package/src/reflect/transcript.ts +35 -10
  111. package/src/release/public-clean.ts +301 -0
  112. package/src/release/published-here.ts +22 -0
  113. package/src/release/run-bump.ts +2 -1
  114. package/src/release/run-release.ts +4 -1
  115. package/src/repo-config.ts +53 -2
  116. package/src/review/http.ts +16 -2
  117. package/src/review/media-kind.ts +3 -3
  118. package/src/review/media-read.ts +3 -3
  119. package/src/review/model.ts +24 -5
  120. package/src/review/notes.ts +77 -0
  121. package/src/review/project.ts +6 -38
  122. package/src/review/routes.ts +8 -13
  123. package/src/review/store.ts +46 -4
  124. package/src/review/trailer-media.ts +24 -3
  125. package/src/review/trailer-shots.ts +106 -0
  126. package/src/review/unit.ts +1 -1
  127. package/src/scaffold/files/agent-handoff.md +3 -0
  128. package/src/scaffold/files/agent-index.md +4 -12
  129. package/src/scaffold/project-scaffold.ts +5 -4
  130. package/src/serve/embed.ts +1 -1
  131. package/src/serve/hub-app/col-card.tsx +3 -17
  132. package/src/serve/hub-app/col-tables-view.tsx +2 -1
  133. package/src/serve/hub-app/cols-svc.ts +12 -14
  134. package/src/serve/hub-app/dock-st.ts +4 -2
  135. package/src/serve/hub-app/dock-view.tsx +2 -0
  136. package/src/serve/hub-app/frames-st.ts +35 -0
  137. package/src/serve/hub-app/hash-route.ts +64 -1
  138. package/src/serve/hub-app/home-st.ts +31 -7
  139. package/src/serve/hub-app/home-strip.css +9 -1
  140. package/src/serve/hub-app/home-strip.tsx +7 -6
  141. package/src/serve/hub-app/home.html +5 -0
  142. package/src/serve/hub-app/hub-app.tsx +49 -5
  143. package/src/serve/hub-app/hub.css +29 -11
  144. package/src/serve/hub-app/icons.tsx +16 -1
  145. package/src/serve/hub-app/identities-st.ts +210 -0
  146. package/src/serve/hub-app/identities-view.tsx +352 -0
  147. package/src/serve/hub-app/identities.css +48 -0
  148. package/src/serve/hub-app/identity-address.ts +52 -0
  149. package/src/serve/hub-app/inbox-st.ts +59 -6
  150. package/src/serve/hub-app/inbox-view.tsx +48 -6
  151. package/src/serve/hub-app/inbox.css +12 -1
  152. package/src/serve/hub-app/index.html +3 -0
  153. package/src/serve/hub-app/keys.ts +10 -2
  154. package/src/serve/hub-app/list-walk.ts +89 -0
  155. package/src/serve/hub-app/machine-st.ts +12 -0
  156. package/src/serve/hub-app/media-view.tsx +2 -1
  157. package/src/serve/hub-app/pages-frames.tsx +134 -0
  158. package/src/serve/hub-app/pages-svc.ts +111 -0
  159. package/src/serve/hub-app/palette-st.ts +18 -3
  160. package/src/serve/hub-app/palette-view.tsx +9 -2
  161. package/src/serve/hub-app/planned-view.tsx +2 -1
  162. package/src/serve/hub-app/project-list.css +18 -14
  163. package/src/serve/hub-app/project-list.tsx +88 -49
  164. package/src/serve/hub-app/projects-svc.ts +33 -3
  165. package/src/serve/hub-app/repo-sections.ts +19 -2
  166. package/src/serve/hub-app/repo-st.ts +75 -19
  167. package/src/serve/hub-app/review/review-cells.tsx +3 -3
  168. package/src/serve/hub-app/review/review-kit.ts +30 -7
  169. package/src/serve/hub-app/review/review-page.tsx +1 -1
  170. package/src/serve/hub-app/review/review-st.ts +33 -11
  171. package/src/serve/hub-app/review/review-thread.tsx +11 -9
  172. package/src/serve/hub-app/review/review-views.tsx +84 -19
  173. package/src/serve/hub-app/review/thread-st.ts +1 -10
  174. package/src/serve/hub-app/review/trailer-page.tsx +2 -1
  175. package/src/serve/hub-app/review.css +17 -8
  176. package/src/serve/hub-app/site/site-part.tsx +173 -0
  177. package/src/serve/hub-app/site/site-st.ts +157 -0
  178. package/src/serve/hub-app/site.css +35 -0
  179. package/src/serve/hub-app/social/calendar.tsx +182 -0
  180. package/src/serve/hub-app/social/comms-page.tsx +306 -0
  181. package/src/serve/hub-app/social/kit.tsx +244 -0
  182. package/src/serve/hub-app/social/post-card.tsx +456 -0
  183. package/src/serve/hub-app/social/problems.tsx +60 -0
  184. package/src/serve/hub-app/social/social-model.ts +154 -0
  185. package/src/serve/hub-app/social/social-page.tsx +674 -0
  186. package/src/serve/hub-app/social/social-st.ts +986 -0
  187. package/src/serve/hub-app/social.css +289 -0
  188. package/src/serve/hub-app/stores/stores-page.tsx +311 -0
  189. package/src/serve/hub-app/stores/stores-st.ts +286 -0
  190. package/src/serve/hub-app/stores.css +54 -0
  191. package/src/serve/hub-app/test-view.tsx +9 -2
  192. package/src/serve/hub-app/tests-svc.ts +16 -1
  193. package/src/serve/hub-app/timeline-geometry.ts +1 -1
  194. package/src/serve/hub-app/timeline-view.tsx +3 -2
  195. package/src/serve/hub-app/tree-build.ts +6 -0
  196. package/src/serve/hub-app/tree-row.tsx +27 -4
  197. package/src/serve/hub-app/tree-svc.ts +18 -49
  198. package/src/serve/hub-app/veille/veille-page.tsx +514 -0
  199. package/src/serve/hub-app/veille/veille-st.ts +443 -0
  200. package/src/serve/hub-app/veille.css +84 -0
  201. package/src/serve/hub-runtime.ts +14 -9
  202. package/src/serve/project-gutter-route.ts +44 -12
  203. package/src/serve/resources-wire.ts +48 -0
  204. package/src/serve/run-lanes.ts +7 -4
  205. package/src/serve/same-origin.ts +1 -1
  206. package/src/serve/serve-hub.ts +27 -18
  207. package/src/serve/tracked-watch.ts +24 -3
  208. package/src/serve/warm-cell.ts +5 -1
  209. package/src/shipkit-files.ts +15 -4
  210. package/src/shipkit.ts +0 -1
  211. package/src/shot/box.ts +162 -0
  212. package/src/shot/browser-slot.ts +62 -0
  213. package/src/shot/client.ts +43 -7
  214. package/src/shot/clip-encoder.ts +93 -12
  215. package/src/shot/film-box.ts +188 -0
  216. package/src/shot/shooter.ts +50 -15
  217. package/src/shot/shot-ask.ts +10 -2
  218. package/src/shot/stepped-clip.ts +5 -4
  219. package/src/site/desk.ts +242 -0
  220. package/src/site/routes.ts +66 -0
  221. package/src/site/unit.ts +62 -0
  222. package/src/social/brands.ts +22 -0
  223. package/src/social/compose.ts +97 -0
  224. package/src/social/desk-index.ts +123 -0
  225. package/src/social/desk-wire.ts +64 -0
  226. package/src/social/drafts.ts +183 -0
  227. package/src/social/house.ts +24 -0
  228. package/src/social/load.ts +319 -0
  229. package/src/social/md.ts +70 -0
  230. package/src/social/media-facts.ts +53 -0
  231. package/src/social/media-kind.ts +189 -0
  232. package/src/social/media-limit.ts +42 -0
  233. package/src/social/media-of.ts +30 -0
  234. package/src/social/migrate.ts +123 -0
  235. package/src/social/open.ts +17 -0
  236. package/src/social/post-url.ts +158 -0
  237. package/src/social/presence.ts +332 -0
  238. package/src/social/public-read.ts +53 -0
  239. package/src/social/publish/bluesky.ts +168 -0
  240. package/src/social/publish/discord.ts +76 -0
  241. package/src/social/publish/index.ts +24 -0
  242. package/src/social/publish/secret.ts +13 -0
  243. package/src/social/push.ts +31 -0
  244. package/src/social/richtext.ts +37 -0
  245. package/src/social/routes.ts +180 -0
  246. package/src/social/stats.ts +134 -0
  247. package/src/social/text.ts +267 -0
  248. package/src/social/tracker-route.ts +39 -0
  249. package/src/social/tracker.ts +255 -0
  250. package/src/social/unit.ts +53 -0
  251. package/src/social/writes.ts +130 -0
  252. package/src/start-repo.ts +14 -9
  253. package/src/stores/collection.ts +27 -0
  254. package/src/stores/desk.ts +336 -0
  255. package/src/stores/model.ts +187 -0
  256. package/src/stores/routes.ts +126 -0
  257. package/src/stores/unit.ts +57 -0
  258. package/src/suite/calibrate.ts +127 -0
  259. package/src/suite/core-counters.ts +91 -0
  260. package/src/suite/judge-suites.ts +94 -34
  261. package/src/suite/suite-cli.ts +44 -10
  262. package/src/suite/suite-cpu-preload.ts +34 -9
  263. package/src/trailer/adapter.ts +4 -0
  264. package/src/trailer/build.ts +42 -11
  265. package/src/trailer/ffmpeg.ts +11 -0
  266. package/src/trailer/footage.ts +30 -13
  267. package/src/trailer/grammar.ts +18 -2
  268. package/src/trailer/graph.ts +28 -6
  269. package/src/trailer/passage.ts +21 -6
  270. package/src/trailer/plan.ts +74 -3
  271. package/src/trailer/shelf.ts +16 -0
  272. package/src/trailer/stitch.ts +67 -26
  273. package/src/trailer/url.ts +1 -1
  274. package/src/trailer/versions.ts +24 -0
  275. package/src/ts/gate-typecheck.ts +32 -0
  276. package/src/ts/typecheck-cli.ts +9 -11
  277. package/src/tui/tui-app.tsx +0 -1
  278. package/src/veille/asks.ts +155 -0
  279. package/src/veille/auto.ts +31 -0
  280. package/src/veille/batch.ts +27 -0
  281. package/src/veille/chrome.ts +127 -0
  282. package/src/veille/collection.ts +28 -0
  283. package/src/veille/desk.ts +242 -0
  284. package/src/veille/identity.ts +80 -0
  285. package/src/veille/import.ts +68 -0
  286. package/src/veille/log.ts +183 -0
  287. package/src/veille/platforms.ts +118 -0
  288. package/src/veille/reads.ts +66 -0
  289. package/src/veille/replied.ts +110 -0
  290. package/src/veille/routes.ts +185 -0
  291. package/src/veille/service.ts +81 -0
  292. package/src/veille/watch.ts +116 -0
  293. package/src/veille/worth.ts +46 -0
  294. package/src/wiki/scan-md.ts +18 -0
  295. package/src/collections/posts.ts +0 -142
  296. package/src/contracts/manifests/social.contract.ts +0 -20
  297. package/src/scaffold/files/agent-coding.md +0 -35
  298. package/src/ts/typecheck-cache.ts +0 -11
@@ -1,60 +1,12 @@
1
1
  // Act-in-place verbs behind the hub feed — every mutation targets a
2
2
  // git-tracked truth file (studio pick-flow precedent: the hub writes, the
3
3
  // repo's diff shows it; Feedback appends are append-only, never destructive).
4
- import { existsSync, readFileSync, readdirSync, writeFileSync } from 'fs'
4
+ import { existsSync, readFileSync, writeFileSync } from 'fs'
5
5
  import { join } from 'path'
6
6
  import { archiveAsk, proofAsk } from '../asks/asks-queue.ts'
7
- import { parsePostFile } from './posts.ts'
8
7
 
9
8
  const today = (): string => new Date().toISOString().slice(0, 10)
10
9
 
11
- const postPath = (root: string, channel: string, file: string): string => {
12
- if (channel.includes('/') || channel.includes('..') || file.includes('/') || file.includes('..')) throw new Error('bad path')
13
- const p = join(root, '.shipkit/social', channel, file)
14
- if (!existsSync(p)) throw new Error(`no such post: ${channel}/${file}`)
15
- return p
16
- }
17
-
18
- const setStatus = (p: string, status: string): void => {
19
- const md = readFileSync(p, 'utf8')
20
- if (!/^status:/m.test(md)) throw new Error('post has no status: frontmatter')
21
- writeFileSync(p, md.replace(/^status:.*$/m, `status: ${status}`))
22
- }
23
-
24
- /** pick one draft variant: it flips to picked, sibling drafts to rejected
25
- * (files KEPT — rejections are training data for the next generation) */
26
- export function pickPostVariant(root: string, channel: string, file: string): void {
27
- const p = postPath(root, channel, file)
28
- const dir = join(root, '.shipkit/social', channel)
29
- const slug = parsePostFile(dir, channel, file).slug
30
- setStatus(p, 'picked')
31
- for (const f of readdirSync(dir).filter((x) => x.endsWith('.md') && x !== file)) {
32
- const sib = parsePostFile(dir, channel, f)
33
- if (sib.slug === slug && sib.status === 'draft') setStatus(join(dir, f), 'rejected')
34
- }
35
- }
36
-
37
- /** the posted-URL proof: status → posted, `posted:` frontmatter carries the URL */
38
- export function markPosted(root: string, channel: string, file: string, url: string, rating?: number): void {
39
- const p = postPath(root, channel, file)
40
- setStatus(p, 'posted')
41
- const md = readFileSync(p, 'utf8')
42
- const withUrl = /^posted:/m.test(md) ? md.replace(/^posted:.*$/m, `posted: ${url}`) : md.replace(/^status:.*$/m, (s) => `${s}\nposted: ${url}`)
43
- const withRating = rating != null
44
- ? (/^rating:/m.test(withUrl) ? withUrl.replace(/^rating:.*$/m, `rating: ${rating}`) : withUrl.replace(/^posted:.*$/m, (s) => `${s}\nrating: ${rating}`))
45
- : withUrl
46
- writeFileSync(p, withRating)
47
- }
48
-
49
- /** append a dated remark under ## Feedback (created if absent) — NEVER
50
- * destructive; future generations re-read these before drafting */
51
- export function appendPostFeedback(root: string, channel: string, file: string, text: string): void {
52
- const p = postPath(root, channel, file)
53
- const md = readFileSync(p, 'utf8')
54
- const line = `- ${today()}: ${text.replace(/\n+/g, ' ').trim()}`
55
- writeFileSync(p, /^## Feedback\s*$/m.test(md) ? `${md.trimEnd()}\n${line}\n` : `${md.trimEnd()}\n\n## Feedback\n${line}\n`)
56
- }
57
-
58
10
  /** an asset remark → `.shipkit/assets/notes.md` (git-tracked; the studio
59
11
  * workspace is gitignored, so notes live beside kit.ts) */
60
12
  export function appendAssetNote(root: string, assetId: string, text: string): void {
@@ -21,7 +21,7 @@ import { FLOOR_IDS } from '../core/floor.ts'
21
21
  import { FOREVER_MS, formatLine, ttlMsOf } from '../core/wire.ts'
22
22
  import { gateInventory, type CheckRow } from '../ledger/gate-checks.ts'
23
23
  import { runsCellsOf } from '../core/runs-matrix.ts'
24
- import { readLastLines, readRuns, runsPath, type LastLine, type RunRow } from '../ledger/run-log.ts'
24
+ import { readLastLines, readRuns, runsPath, warmRuns, type LastLine, type RunRow } from '../ledger/run-log.ts'
25
25
  import { checkStatsFor, type CheckStat } from '../ledger/check-stats.ts'
26
26
  import { NEGATIVE_TTL_CAP_MS } from '../ledger/world-cache.ts'
27
27
  import type { RepoConfig } from '../repo-config.ts'
@@ -66,6 +66,7 @@ export function checksCollection(root: string, c: RepoConfig, o: ChecksOpts = {}
66
66
  kind: 'check',
67
67
  media: 'health',
68
68
  list: async () => {
69
+ if (o.runs == null) await warmRuns(runsPath(root))
69
70
  const rows = await gateInventory(root, c)
70
71
  const stats = o.stats ?? checkStatsFor(root, rows.map((r) => ({ id: r.decl.id })))
71
72
  const lines = o.lastLines ?? readLastLines(runsPath(root))
@@ -6,6 +6,7 @@
6
6
  // default, or a paste-from-elsewhere. Doctrine page: build/collections in
7
7
  // the docs wiki this lib ships beside.
8
8
 
9
+ import { yieldLoop } from '../core/loop-watch.ts'
9
10
  import type { WhenAt, WhenSource } from '../core/when.ts'
10
11
  import type { RunsCells } from '../core/runs-matrix.ts'
11
12
  import type { CheckFrom } from '../ledger/gate-checks.ts'
@@ -31,12 +32,16 @@ export const NO_CHECK = 'in no check'
31
32
  * section a row lives under (hub-app/tree-build.ts KIND_SECTION). There is no
32
33
  * catch all kind: a row belongs to an owner, and what belongs to the hub
33
34
  * itself is its status (serve/hub-problems.ts), never a row */
34
- export const RESOURCE_TYPES = ['ask', 'secret', 'asset', 'post', 'workflow', 'wiki', 'contract', 'check', 'test', 'reflection', 'process', 'card', 'cut'] as const
35
+ export const RESOURCE_TYPES = ['ask', 'secret', 'asset', 'post', 'workflow', 'wiki', 'contract', 'check', 'test', 'reflection', 'process', 'card', 'cut', 'store', 'veille'] as const
35
36
 
36
37
  /** the collection of the review cards that wait on him (collections/review.ts) */
37
38
  export const REVIEW_COL = 'review'
38
39
  /** the collection of the trailer cuts, one row a cut (collections/review.ts) */
39
40
  export const TRAILER_COL = 'trailers'
41
+ /** the collection of the store pages, one row a store (stores/collection.ts) */
42
+ export const STORES_COL = 'stores'
43
+ /** the collection of the Veille, one row for the identity whose posts it ranks (veille/collection.ts) */
44
+ export const VEILLE_COL = 'veille'
40
45
 
41
46
  export type ResourceType = (typeof RESOURCE_TYPES)[number]
42
47
 
@@ -327,10 +332,13 @@ export const brokenRow = (c: Collection, e: unknown): Instance => ({
327
332
  export type OnCollector = (collection: string, error: string | null) => void
328
333
 
329
334
  /** every resource of every collection, failure-isolated per collection: a
330
- * broken source reports itself as ONE red row, never blanks the tree */
335
+ * broken source reports itself as ONE red row, never blanks the tree. The
336
+ * loop is given back between two collections (wiki build/shipkit/home.md,
337
+ * Nothing heavy on the daemon's loop) */
331
338
  export async function projectResources(collections: Collection[], onCollector?: OnCollector): Promise<Resource[]> {
332
339
  const out: Resource[] = []
333
340
  for (const c of collections) {
341
+ await yieldLoop()
334
342
  try {
335
343
  out.push(...(await listResources(c)))
336
344
  onCollector?.(c.id, null)
@@ -348,6 +356,7 @@ export async function projectResources(collections: Collection[], onCollector?:
348
356
  export async function projectNeeds(collections: Collection[], onCollector?: OnCollector): Promise<NeedItem[]> {
349
357
  const out: NeedItem[] = []
350
358
  for (const c of collections) {
359
+ await yieldLoop()
351
360
  try {
352
361
  for (const i of await c.list()) if (i.severity != null) out.push({ ...i, collection: c.id })
353
362
  onCollector?.(c.id, null)
@@ -24,10 +24,11 @@ import type { RepoConfig } from '../repo-config.ts'
24
24
  import { activeContracts, contractsConfigFrom } from '../contracts/apply-contracts.ts'
25
25
  import type { AskFacts, CheckFacts, Collection, Instance } from './collection-types.ts'
26
26
  import { mdBody } from './md-body.ts'
27
- import { socialPostsCollection } from './posts.ts'
28
27
  import { assetState, secretState, type SecretLevel, type SecretProbe } from './state-rules.ts'
29
28
  import { reflectionsCollection } from './reflections.ts'
30
29
  import { reviewCollection, trailersCollection } from './review.ts'
30
+ import { storesCollection } from '../stores/collection.ts'
31
+ import { veilleCollection } from '../veille/collection.ts'
31
32
  import { testsCollection } from './tests.ts'
32
33
  import { checksCollection } from './checks.ts'
33
34
  import { LAYOUT } from '../core/layout.ts'
@@ -415,10 +416,9 @@ export function buildCollections(root: string, c: RepoConfig, kit: ResolvedKit |
415
416
  asksCollection(root, c),
416
417
  credsCollection(root, c, { verdicts: () => verdictsOf(checks) }),
417
418
  mediaKitCollection(root, c.serve?.assets === false ? null : kit),
418
- socialPostsCollection(root),
419
419
  reflectionsCollection(root),
420
420
  testsCollection(root, c),
421
- // only where the repo has a review store or a trailer folder: the section of a repo with none is greyed
422
- ...[reviewCollection(root), trailersCollection(root)].filter((x): x is Collection => x !== null),
421
+ // only where the repo has a review store, a trailer folder or a store folder: the section of a repo with none is greyed
422
+ ...[reviewCollection(root), trailersCollection(root), storesCollection(root), veilleCollection(root)].filter((x): x is Collection => x !== null),
423
423
  ]
424
424
  }
@@ -5,7 +5,7 @@
5
5
  import { existsSync } from 'node:fs'
6
6
  import { join } from 'node:path'
7
7
  import { STATUS_LABEL, isFrame, stateOf, type ReviewItem } from '../review/model.ts'
8
- import { readAllCached, storeDir, storeStamp } from '../review/store.ts'
8
+ import { readAllCached, storeDir, storeStamp, warmStore } from '../review/store.ts'
9
9
  import { statusOf, waitingOnOwner, type Thread } from '../review/threads.ts'
10
10
  import { cutsOf, trailerIds } from '../review/trailer-desk.ts'
11
11
  import { REVIEW_COL, TRAILER_COL, type Collection, type Instance } from './collection-types.ts'
@@ -34,6 +34,7 @@ export function reviewCollection(root: string): Collection | null {
34
34
  kind: 'card',
35
35
  media: 'image',
36
36
  list: async () => {
37
+ await warmStore(dir)
37
38
  const { threads, items } = waitingCards(root)
38
39
  return threads.map(({ head: x }): Instance => ({
39
40
  id: `card:${x.item.id}`,
@@ -6,11 +6,14 @@
6
6
  // testPlanOf, the same plan rule SK018 judges, and whether a file needs fixing
7
7
  // is ledger/run-timeline.ts testFilesToFix, the same function the runs page
8
8
  // tab lists. A second answer to either would drift from the first.
9
- import { posix } from 'path'
10
- import { CheckCtx } from '../core/check-ctx.ts'
9
+ import { readFileSync } from 'fs'
10
+ import { join, posix } from 'path'
11
+ import { listRepoFiles } from '../core/floor.ts'
12
+ import { listingWithoutVendored } from '../core/vendored.ts'
13
+ import { readVendored } from '../core/vendored-read.ts'
11
14
  import { testFilesToFix } from '../ledger/run-timeline.ts'
12
15
  import { runsPath } from '../ledger/run-log.ts'
13
- import { readSuites, type SuiteRow } from '../ledger/suite-log.ts'
16
+ import { readSuites, warmSuites, type SuiteRow } from '../ledger/suite-log.ts'
14
17
  import type { RepoConfig } from '../repo-config.ts'
15
18
  import { rawName } from '../core/canonical-scripts.ts'
16
19
  import { DEFAULT_BUDGET_MS, normSuitePath } from '../suite/judge-suites.ts'
@@ -68,14 +71,22 @@ export function testsCollection(root: string, c: RepoConfig, o: TestsOpts = {}):
68
71
  list: async () => {
69
72
  let files = o.files
70
73
  let read = o.read
71
- if (files == null || read == null) {
72
- const disk = CheckCtx.open({ root, config: c })
73
- files ??= disk.list(TEST_GLOB)
74
- read ??= (rel) => disk.read(rel)
74
+ // what git sees, as a check's `list` lists it (tracked, or untracked and not ignored, the vendored dirs
75
+ // left out), from the repo listing the inventory reads too: kept on the tree's revision in the daemon,
76
+ // where a check context stages and hashes the whole tree
77
+ if (files == null) {
78
+ const glob = new Bun.Glob(TEST_GLOB)
79
+ files = listingWithoutVendored(listRepoFiles(root).filter((f) => glob.match(f)), TEST_GLOB, readVendored(root))
80
+ }
81
+ read ??= (rel) => {
82
+ try { return readFileSync(join(root, rel), 'utf8') } catch { return null }
75
83
  }
76
84
  let suites = o.suites
77
85
  if (suites == null) {
78
- try { suites = readSuites(runsPath(root)) } catch { suites = [] }
86
+ try {
87
+ await warmSuites(runsPath(root))
88
+ suites = readSuites(runsPath(root))
89
+ } catch { suites = [] }
79
90
  }
80
91
  return testInstances({ config: c, files: files.filter(isTestFile), read, suites })
81
92
  },
@@ -15,15 +15,13 @@ import { evaluateContracts, type ContractsConfig, type ContractsResult } from '.
15
15
 
16
16
  export function contractsConfigFrom(c: RepoConfig, d: WebDisk & Pick<ScanCtx, 'root'>): ContractsConfig {
17
17
  const venues = c.venues ?? []
18
- const social = c.social ?? []
19
- const declared = [...venues, ...(social.length > 0 ? ['social'] : [])]
18
+ const declared = [...venues]
20
19
  const deploys = webDeploys(d)
21
20
  // a public repo whose only surface is an npm package has no page to serve an identity on
22
21
  const npmOnly = c.release?.npm === true && deploys.length === 0 && venues.length === 0
23
22
  return {
24
23
  root: d.root,
25
24
  declared,
26
- social,
27
25
  publicSurface: venues.length > 0 || deploys.length > 0 || (c.visibility === 'public' && !npmOnly),
28
26
  webRoot: webRootOf(c.contracts?.webRoot, deploys),
29
27
  exempt: c.contracts?.exempt,
@@ -4,7 +4,6 @@ import type { ContractManifest } from './contract-types.ts'
4
4
  import c0 from './manifests/discord.contract.ts'
5
5
  import c1 from './manifests/identity.contract.ts'
6
6
  import c2 from './manifests/itch.contract.ts'
7
- import c3 from './manifests/social.contract.ts'
8
- import c4 from './manifests/steam.contract.ts'
7
+ import c3 from './manifests/steam.contract.ts'
9
8
 
10
- export const allContracts: ContractManifest[] = [c0, c1, c2, c3, c4]
9
+ export const allContracts: ContractManifest[] = [c0, c1, c2, c3]
@@ -34,7 +34,6 @@ export type ContractEnv = {
34
34
  /** the dir the site serves, what `{web}` in a rule path stands for */
35
35
  webRoot: string
36
36
  venues: string[]
37
- social: string[]
38
37
  exists: (relPath: string) => boolean
39
38
  /** the text of a repo-relative file, null when none. A probe reads the
40
39
  * repo through this and `exists`, so a check reporting it is cached on
@@ -22,8 +22,6 @@ export type ContractsConfig = {
22
22
  root: string
23
23
  /** venue ids the repo declares it ships on (config side of both-ways drift) */
24
24
  declared: string[]
25
- /** social channel list — handed to custom rules via ContractEnv */
26
- social: string[]
27
25
  /** repo has a public surface (a deploy, a declared venue, a public repo) — gates 'always' contracts */
28
26
  publicSurface: boolean
29
27
  /** the dir the site serves, substituted for `{web}` in rule paths (default 'public') */
@@ -186,7 +184,6 @@ export async function evaluateContracts(manifests: ContractManifest[], cfg: Cont
186
184
  root: cfg.root,
187
185
  webRoot,
188
186
  venues: cfg.declared,
189
- social: cfg.social,
190
187
  exists: (rel) => d.exists(rel),
191
188
  read: (rel) => textOf(d, rel),
192
189
  }
@@ -96,8 +96,12 @@ function plate(ctx: ReturnType<Canvas['getContext']>, o: number): void {
96
96
  ctx.roundRect(o, o, PLATE, PLATE, RADIUS)
97
97
  }
98
98
 
99
+ /** how the plate is drawn: `plateAlpha` fades the plate alone, the mark stays whole
100
+ * (the rail's unselected rows). A tile has no plate apart from its mark, so it ignores it */
101
+ export type PlateLook = { plateAlpha?: number }
102
+
99
103
  /** the icon at 1024px, and the plate colour it used (null: the mark is the plate) */
100
- export async function drawAppIcon(bytes: Uint8Array, id: Identity): Promise<{ canvas: Canvas; plate: string | null }> {
104
+ export async function drawAppIcon(bytes: Uint8Array, id: Identity, look: PlateLook = {}): Promise<{ canvas: Canvas; plate: string | null }> {
101
105
  const img = await decode(bytes)
102
106
  const src = createCanvas(img.width, img.height)
103
107
  const sctx = src.getContext('2d')
@@ -127,8 +131,10 @@ export async function drawAppIcon(bytes: Uint8Array, id: Identity): Promise<{ ca
127
131
  g.addColorStop(0, towardWhite(colour, 0.14))
128
132
  g.addColorStop(1, colour)
129
133
  ctx.fillStyle = g
134
+ ctx.globalAlpha = look.plateAlpha ?? 1
130
135
  plate(ctx, o)
131
136
  ctx.fill()
137
+ ctx.globalAlpha = 1
132
138
  const s = (PLATE * MARK) / Math.max(box.w, box.h)
133
139
  ctx.drawImage(src, box.x, box.y, box.w, box.h, ICON_PX / 2 - (box.w * s) / 2, ICON_PX / 2 - (box.h * s) / 2, box.w * s, box.h * s)
134
140
  return { canvas: out, plate: colour }
@@ -138,8 +144,8 @@ export async function drawAppIcon(bytes: Uint8Array, id: Identity): Promise<{ ca
138
144
  * grid's margin away, the rounded plate edge to edge (the hub's rail);
139
145
  * `square` fills the plate's corners with its own edge colours, edge to edge
140
146
  * with no transparency (a phone's home screen cuts its own corners) */
141
- export async function appIconPngs(bytes: Uint8Array, id: Identity, sizes: number[] = [ICON_PX], crop: 'canvas' | 'plate' | 'square' = 'canvas'): Promise<Buffer[]> {
142
- const { canvas } = await drawAppIcon(bytes, id)
147
+ export async function appIconPngs(bytes: Uint8Array, id: Identity, sizes: number[] = [ICON_PX], crop: 'canvas' | 'plate' | 'square' = 'canvas', look: PlateLook = {}): Promise<Buffer[]> {
148
+ const { canvas } = await drawAppIcon(bytes, id, look)
143
149
  const o = crop === 'canvas' ? 0 : (ICON_PX - PLATE) / 2
144
150
  const side = crop === 'canvas' ? ICON_PX : PLATE
145
151
  const edge = (y: number): string => {
@@ -2,7 +2,7 @@
2
2
  // manual `bun fmt` (never a gate step). A repo opts in by declaring the tool's
3
3
  // section in bunfig.toml: the section is where its config lives.
4
4
  //
5
- // bun before 1.4.4 has neither command, and there `bun lint` falls through to
5
+ // bun before 1.4.4 has neither command, nor `bun check` (ts/gate-typecheck.ts), and there `bun lint` falls through to
6
6
  // the package.json `lint` script. A script that calls `bun lint` then calls
7
7
  // itself forever, so an old bun gets a loud refusal instead of a spawn. The
8
8
  // lint slot runs through core/bun-tool-cli.ts, which keeps a same-named script out.
@@ -12,7 +12,7 @@ export type BunTool = 'lint' | 'fmt'
12
12
 
13
13
  export const BUN_TOOLS_SINCE = '1.4.4'
14
14
 
15
- /** does the bun running shipkit ship `bun lint` and `bun fmt` */
15
+ /** does the bun running shipkit ship `bun lint`, `bun fmt` and `bun check` */
16
16
  export const bunHasTools = (version: string = Bun.version): boolean => Bun.semver.order(version.replace(/-.*$/, ''), BUN_TOOLS_SINCE) >= 0
17
17
 
18
18
  const header = (tool: BunTool): RegExp => new RegExp(`^\\s*\\[${tool}(?:\\.[^\\]]+)?\\]\\s*(?:#.*)?$`)
@@ -57,18 +57,50 @@ export type DiscoveredCheck = {
57
57
  from: CheckFrom
58
58
  }
59
59
 
60
- function walk(dir: string, out: string[], suffix = SUFFIX, dirs?: string[], prune?: ReadonlySet<string>): void {
60
+ function walk(dir: string, out: string[], suffix = SUFFIX, dirs?: string[], prune?: ReadonlySet<string>, times?: [string, number][]): void {
61
61
  dirs?.push(dir)
62
+ // the time before the read: a write between the two then reads as moved
63
+ if (times != null) {
64
+ try { times.push([dir, statSync(dir).mtimeMs]) } catch { times.push([dir, -1]) }
65
+ }
62
66
  let entries
63
67
  try { entries = readdirSync(dir, { withFileTypes: true }) } catch { return }
64
68
  for (const e of entries) {
65
69
  if (e.isDirectory()) {
66
70
  const sub = join(dir, e.name)
67
- if (!IGNORED_DIRS.has(e.name) && !e.name.startsWith('.') && prune?.has(sub) !== true) walk(sub, out, suffix, dirs, prune)
71
+ if (!IGNORED_DIRS.has(e.name) && !e.name.startsWith('.') && prune?.has(sub) !== true) walk(sub, out, suffix, dirs, prune, times)
68
72
  } else if (e.name.endsWith(suffix)) out.push(join(dir, e.name))
69
73
  }
70
74
  }
71
75
 
76
+ /** the last walk of each (root, suffix, prune), with the time of every dir it read: a dir's time moves when an entry
77
+ * is added, removed or renamed in it, so while none moved the list is the same, at a stat per dir (2 ms for a
78
+ * thousand dirs, where the walk takes 40 to 60 ms). The daemon's warm answers walk each repo many times */
79
+ const walks = new Map<string, { dirs: [string, number][]; out: string[] }>()
80
+ const WALKS_MAX = 256
81
+
82
+ function walkKept(dir: string, out: string[], suffix: string, dirs: string[] | undefined, prune: ReadonlySet<string>): void {
83
+ const key = `${dir}\0${suffix}\0${[...prune].sort().join('\0')}`
84
+ const held = walks.get(key)
85
+ const same = held != null && held.dirs.every(([d, t]) => {
86
+ try { return statSync(d).mtimeMs === t } catch { return false }
87
+ })
88
+ if (held != null && same) {
89
+ out.push(...held.out)
90
+ for (const [d] of held.dirs) dirs?.push(d)
91
+ return
92
+ }
93
+ const seen: string[] = []
94
+ const found: string[] = []
95
+ const timed: [string, number][] = []
96
+ walk(dir, found, suffix, seen, prune, timed)
97
+ walks.delete(key)
98
+ walks.set(key, { dirs: timed, out: found })
99
+ if (walks.size > WALKS_MAX) walks.delete(walks.keys().next().value!)
100
+ out.push(...found)
101
+ dirs?.push(...seen)
102
+ }
103
+
72
104
  /** the absolute vendored dirs of a repo, which no repo walk enters */
73
105
  const vendoredPrune = (root: string): ReadonlySet<string> => new Set(readVendored(root).map((d) => join(root, d)))
74
106
 
@@ -77,7 +109,7 @@ const vendoredPrune = (root: string): ReadonlySet<string> => new Set(readVendore
77
109
  * mtime, which is how a reader tells the list moved without walking again */
78
110
  export function repoUnitFiles(root: string, dirs?: string[]): string[] {
79
111
  const out: string[] = []
80
- walk(root, out, UNIT_SUFFIX, dirs, vendoredPrune(root))
112
+ walkKept(root, out, UNIT_SUFFIX, dirs, vendoredPrune(root))
81
113
  return out.sort()
82
114
  }
83
115
 
@@ -102,7 +134,7 @@ export async function importFresh(path: string): Promise<unknown> {
102
134
  * Sorted. */
103
135
  export function repoCheckFiles(root: string): string[] {
104
136
  const out: string[] = []
105
- walk(root, out, SUFFIX, undefined, vendoredPrune(root))
137
+ walkKept(root, out, SUFFIX, undefined, vendoredPrune(root))
106
138
  return out.sort()
107
139
  }
108
140
 
@@ -197,7 +229,7 @@ export async function discoverChecks(root: string, o: DiscoverOpts = {}): Promis
197
229
  const builtins: string[] = []
198
230
  walk(builtinDir, builtins)
199
231
  const found: string[] = []
200
- walk(root, found, SUFFIX, undefined, vendoredPrune(root))
232
+ walkKept(root, found, SUFFIX, undefined, vendoredPrune(root))
201
233
  const units = repoUnitFiles(root)
202
234
  // the repo that HOSTS the toolkit walks over `src/checks/` too, and a file
203
235
  // discovered twice is a duplicate id rather than a second check. Real paths,
@@ -1,5 +1,7 @@
1
1
  // does a gate run its repair pass (core/run-fixers.ts). A leaf, so the hub's
2
2
  // run lanes read the same answer the gate acts on without loading the gate.
3
3
 
4
- /** `fix` named wins. Unnamed: a whole gate repairs, a narrowed run does not */
5
- export const fixPassRuns = (o: { fix?: boolean; onlyIds?: readonly string[] }): boolean => o.fix ?? (o.onlyIds ?? []).length === 0
4
+ /** every run repairs: a whole gate all it can, a narrowed run what its named
5
+ * checks own. A repair is mechanical and safe by contract, in a shared tree
6
+ * too. Only an internal report-only run (frozen, the hub's auto) passes false */
7
+ export const fixPassRuns = (o: { fix?: boolean; onlyIds?: readonly string[] }): boolean => o.fix ?? true
@@ -19,23 +19,23 @@ import { rawName, slotBody } from './canonical-scripts.ts'
19
19
  import type { CheckCtx } from './check-ctx.ts'
20
20
  import { checkUnitReader, type UnitReader } from '../release/unit-resolve.ts'
21
21
  import { parseJsonc } from '../ts/jsonc.ts'
22
- import { resolveTypecheckProjects } from '../ts/tsconfig-resolve.ts'
23
- import { gateBuildInfoArgs } from '../ts/typecheck-cache.ts'
22
+ import { gateCheckCmd, tscFallbackNote } from '../ts/gate-typecheck.ts'
24
23
  import { parseBunTestScript, suiteFlags } from '../suite/judge-suites.ts'
25
24
  import { declaredTestUnits, siblingUnits, testCheckId, unitIgnores, unitTestBody, unitTsconfig, type TestUnitDecl } from '../suite/test-units.ts'
26
25
  import { describeFirst, type TaskDef } from '../check.ts'
27
26
  import type { RepoConfig } from '../repo-config.ts'
28
27
  import { repoOff } from './when.ts'
29
- import { bunfigDeclares, bunLintCmd } from './bun-builtins.ts'
28
+ import { bunfigDeclares, bunHasTools, bunLintCmd } from './bun-builtins.ts'
30
29
  import { normalizeVendored } from './vendored.ts'
31
30
 
32
- /** how the floor reads the repo, by repo-relative path, plus the one lookup
33
- * outside it: a binary on PATH */
34
- export type FloorReader = UnitReader & { which: (bin: string) => string | null }
31
+ /** how the floor reads the repo, by repo-relative path, plus the lookups
32
+ * outside it: a binary on PATH, and the bun version (default: the bun
33
+ * running shipkit) */
34
+ export type FloorReader = UnitReader & { which: (bin: string) => string | null; bunVersion?: string }
35
35
 
36
36
  /** the check context as a floor reader. A PATH lookup is not a repo read, so
37
- * it marks the answer untracked, and only a repo with no local tsc and no
38
- * typecheck script ever asks it */
37
+ * it marks the answer untracked, and only the tsc fallback of a bun with no
38
+ * `bun check` ever asks it */
39
39
  export function checkFloorReader(c: CheckCtx): FloorReader {
40
40
  return {
41
41
  ...checkUnitReader(c),
@@ -53,7 +53,7 @@ export const FLOOR_IDS = ['lint', 'typecheck', 'test', 'imports:check', 'cycles'
53
53
  * outside them, since each unit has its own `test:<unit>` */
54
54
  export function slotDescription(id: string, withUnits: boolean): string {
55
55
  if (id === 'lint') return 'the linter reports no problem in the repo'
56
- if (id === 'typecheck') return 'tsc finds no type error in the repo'
56
+ if (id === 'typecheck') return 'the type checker finds no type error in the repo'
57
57
  if (id === 'test') return withUnits ? 'every test file outside the units passes' : 'every test file in the repo passes'
58
58
  if (id === 'imports:check') return 'every local import is absolute, carries its extension and resolves'
59
59
  if (id === 'cycles') return 'no import cycle between modules'
@@ -66,7 +66,7 @@ export const unitTestDescription = (u: { id: string; rel: string }): string =>
66
66
 
67
67
  /** what a unit's own typecheck asserts */
68
68
  export const unitTypecheckDescription = (u: { id: string; rel: string }): string =>
69
- describeFirst(`tsc finds no type error under ${u.rel}`, `tsc finds no type error in unit ${u.id}`)
69
+ describeFirst(`the type checker finds no type error under ${u.rel}`, `the type checker finds no type error in unit ${u.id}`)
70
70
 
71
71
  export type FloorSource = 'package.json script' | 'repo.config override' | 'built-in (shipkit)' | 'built-in (tsc)' | 'built-in (bun)' | 'unit'
72
72
  export type FloorResolution = {
@@ -84,7 +84,12 @@ export type FloorResolution = {
84
84
  /** a package.json body for a slot. A plain `bun test` in the test slot runs
85
85
  * through the suite runner (parallel, timed against the budget), anything
86
86
  * else runs as written and the gate says what that costs */
87
- function scriptCmd(c: RepoConfig, id: string, name: string, body: string, notes: string[], subs: TestUnitDecl[]): string[] {
87
+ function scriptCmd(c: RepoConfig, root: string, io: FloorReader, id: string, name: string, body: string, notes: string[], subs: TestUnitDecl[]): string[] {
88
+ if (id === 'typecheck') {
89
+ const project = plainTypecheckProject(body)
90
+ const cmd = project == null || !io.exists(project, 'file') ? null : gateTypecheckCmd(root, io, project, ['node_modules/.bin/tsc'], notes)
91
+ return cmd == null || typeof cmd === 'string' ? ['bun', 'run', name] : cmd
92
+ }
88
93
  if (id !== 'test') return ['bun', 'run', name]
89
94
  const args = parseBunTestScript(body)
90
95
  if (args == null) {
@@ -97,6 +102,43 @@ function scriptCmd(c: RepoConfig, id: string, name: string, body: string, notes:
97
102
  }
98
103
 
99
104
  const SUITE_CLI = fileURLToPath(import.meta.resolve('rvlib-shipkit/src/suite/suite-cli.ts'))
105
+ const TYPECHECK_CLI = fileURLToPath(import.meta.resolve('rvlib-shipkit/src/ts/typecheck-cli.ts'))
106
+
107
+ /** the tsconfig a script that only typechecks one config checks,
108
+ * repo-relative: `tsc --noEmit` or `bun check`, with at most a
109
+ * `-p`/`--project` (and, for bun check, the flags the gate passes itself).
110
+ * null for any other body, which runs as written */
111
+ export function plainTypecheckProject(body: string): string | null {
112
+ const words = body.trim().split(/\s+/)
113
+ const bunCheck = words[0] === 'bun' && words[1] === 'check'
114
+ if (!bunCheck && (words[0] !== 'tsc' || !words.includes('--noEmit'))) return null
115
+ const own = bunCheck ? GATE_CHECK_FLAGS : new Set(['--noEmit'])
116
+ const args = words.slice(bunCheck ? 2 : 1)
117
+ let project = '.'
118
+ for (let i = 0; i < args.length; i++) {
119
+ if (own.has(args[i]!)) continue
120
+ if ((args[i] === '-p' || args[i] === '--project') && args[i + 1] != null) { project = args[++i]!; continue }
121
+ return null
122
+ }
123
+ return project.endsWith('.json') ? posix.normalize(project) : posix.join(project, 'tsconfig.json')
124
+ }
125
+
126
+ const GATE_CHECK_FLAGS = new Set(['-b', '--build', '--all', '--no-pretty', '--no-script'])
127
+
128
+ /** the gate's typecheck over one repo-relative tsconfig, the same for a plain
129
+ * script, the built-in and a unit: `bun check` (ts/gate-typecheck.ts). On a
130
+ * bun without it, the cold tsc runner over the first tsc found (`tscAt`,
131
+ * repo-relative, then PATH), with a note; the reason when no tsc is found */
132
+ function gateTypecheckCmd(root: string, io: FloorReader, rel: string, tscAt: string[], notes: string[]): string[] | string {
133
+ const tsconfig = join(root, rel)
134
+ if (bunHasTools(io.bunVersion)) return gateCheckCmd(tsconfig)
135
+ const local = tscAt.find((p) => io.exists(p))
136
+ const tsc = local != null ? join(root, local) : io.which('tsc')
137
+ if (tsc == null) return `bun ${io.bunVersion ?? Bun.version} has no \`bun check\` and no tsc resolves (${[...tscAt, 'PATH'].join(', ')}): \`bun upgrade --canary\``
138
+ const note = tscFallbackNote(io.bunVersion)
139
+ if (!notes.includes(note)) notes.push(note)
140
+ return ['bun', TYPECHECK_CLI, tsc, tsconfig]
141
+ }
100
142
 
101
143
  /** one test check per declared sub-unit, `test:<unit id>`, a `release: false`
102
144
  * one included, run in the unit's own dir through the suite runner, so its
@@ -124,11 +166,10 @@ function unitTestTasks(root: string, io: FloorReader, subs: TestUnitDecl[], sibl
124
166
  /** one typecheck per declared sub-unit with a tsconfig of its own,
125
167
  * `typecheck:<unit id>`: the root tsconfig excludes a unit's dir (it compiles
126
168
  * standalone), so without this a green root typecheck hides every error only
127
- * the unit's tsconfig sees. It runs the same runner the root slot falls back
128
- * to, so a solution style config is checked project by project and says what
129
- * it checked. tsc comes from the unit's node_modules, else the repo's, else
130
- * PATH. Keyed and ordered like the unit's test check */
131
- function unitTypecheckTasks(root: string, io: FloorReader, subs: TestUnitDecl[], siblings: Map<string, string[]>, unfilled: { id: string; reason: string }[]): TaskDef[] {
169
+ * the unit's tsconfig sees. It runs the root slot's command. The tsc
170
+ * fallback takes the unit's node_modules, else the repo's, else PATH. Keyed
171
+ * and ordered like the unit's test check */
172
+ function unitTypecheckTasks(root: string, io: FloorReader, subs: TestUnitDecl[], siblings: Map<string, string[]>, notes: string[], unfilled: { id: string; reason: string }[]): TaskDef[] {
132
173
  const out: TaskDef[] = []
133
174
  for (const u of subs) {
134
175
  const id = `typecheck:${u.id}`
@@ -137,12 +178,10 @@ function unitTypecheckTasks(root: string, io: FloorReader, subs: TestUnitDecl[],
137
178
  if (u.tsconfig != null) unfilled.push({ id, reason: `units['${u.rel}'].tsconfig names '${u.tsconfig}', which does not exist` })
138
179
  continue
139
180
  }
140
- const local = join(u.rel, 'node_modules/.bin/tsc')
141
- const tsc = io.exists(local) ? join(root, local) : io.exists('node_modules/.bin/tsc') ? join(root, 'node_modules/.bin/tsc') : io.which('tsc')
142
- if (tsc == null) { unfilled.push({ id, reason: `unit '${u.id}' has a tsconfig and no tsc resolves (its node_modules, the repo's, PATH): add typescript` }); continue }
143
- const cli = fileURLToPath(import.meta.resolve('rvlib-shipkit/src/ts/typecheck-cli.ts'))
181
+ const cmd = gateTypecheckCmd(root, io, tsconfig, [join(u.rel, 'node_modules/.bin/tsc'), 'node_modules/.bin/tsc'], notes)
182
+ if (typeof cmd === 'string') { unfilled.push({ id, reason: `unit '${u.id}': ${cmd}` }); continue }
144
183
  const outside = tsconfigChain(tsconfig, io).filter((f) => f !== u.rel && !f.startsWith(`${u.rel}/`))
145
- out.push({ id, description: unitTypecheckDescription(u), cmd: ['bun', cli, tsc, join(root, tsconfig)], cwd: join(root, u.rel), inputs: [u.rel, ...(siblings.get(u.id) ?? []), ...outside], ...(u.deps == null ? {} : { deps: u.deps }) })
184
+ out.push({ id, description: unitTypecheckDescription(u), cmd, cwd: join(root, u.rel), inputs: [u.rel, ...(siblings.get(u.id) ?? []), ...outside], ...(u.deps == null ? {} : { deps: u.deps }) })
146
185
  }
147
186
  return out
148
187
  }
@@ -164,10 +203,10 @@ function tsconfigChain(rel: string, io: FloorReader): string[] {
164
203
  }
165
204
 
166
205
  // zero-config floor (O6): with no script, imports:check/cycles resolve to
167
- // shipkit's own rvlib-ts-tools dep, typecheck to the repo's tsc, lint to
206
+ // shipkit's own rvlib-ts-tools dep, typecheck to `bun check`, lint to
168
207
  // `bun lint` once bunfig.toml declares [lint]. Returns the task, or the
169
208
  // reason the slot stays empty.
170
- function builtinFloorTask(id: string, root: string, io: FloorReader, vendored: readonly string[]): { task: TaskDef; source: FloorSource } | string {
209
+ function builtinFloorTask(id: string, root: string, io: FloorReader, vendored: readonly string[], notes: string[]): { task: TaskDef; source: FloorSource } | string {
171
210
  if (id === 'lint') {
172
211
  if (!bunfigDeclares(io.text('bunfig.toml'), 'lint')) return `no 'lint' script and no [lint] section in bunfig.toml`
173
212
  return { task: { id, cmd: bunLintCmd(vendored) }, source: 'built-in (bun)' }
@@ -183,29 +222,10 @@ function builtinFloorTask(id: string, root: string, io: FloorReader, vendored: r
183
222
  }
184
223
  }
185
224
  if (id === 'typecheck') {
186
- const tsconfig = join(root, 'tsconfig.json')
187
225
  if (!io.exists('tsconfig.json')) return `no 'typecheck' script and no tsconfig.json`
188
- const local = join(root, 'node_modules/.bin/tsc')
189
- const tsc = io.exists('node_modules/.bin/tsc') ? local : io.which('tsc')
190
- if (tsc == null) return `no 'typecheck' script and tsc not found — add typescript or a typecheck script`
191
- // `tsc --noEmit` over a solution-style config (`files: []` plus
192
- // `references`) compiles ZERO files and exits 0, so the slot reports a
193
- // green nobody measured. only a config that is its OWN single project
194
- // keeps the plain command; everything else goes through the runner,
195
- // which resolves and REPORTS what it checked.
196
- //
197
- // a config that compiles nothing, or references a path that is gone,
198
- // registers the runner too rather than leaving the slot unfilled: an
199
- // unfilled slot is a skip, `shipkit ci` still exits 0, and a repo with
200
- // no typecheck coverage would look the same as a repo that passed.
201
- let plain = false
202
- try {
203
- const projects = resolveTypecheckProjects(tsconfig, io, root)
204
- plain = projects.projects.length === 1 && projects.projects[0] === tsconfig && projects.missing.length === 0
205
- } catch { plain = false }
206
- if (plain) return { task: { id, cmd: [tsc, '--noEmit', ...gateBuildInfoArgs(tsconfig)] }, source: 'built-in (tsc)' }
207
- const cli = fileURLToPath(import.meta.resolve('rvlib-shipkit/src/ts/typecheck-cli.ts'))
208
- return { task: { id, cmd: ['bun', cli, tsc, tsconfig] }, source: 'built-in (tsc)' }
226
+ const cmd = gateTypecheckCmd(root, io, 'tsconfig.json', ['node_modules/.bin/tsc'], notes)
227
+ if (typeof cmd === 'string') return `no 'typecheck' script, and ${cmd}`
228
+ return { task: { id, cmd }, source: bunHasTools(io.bunVersion) ? 'built-in (bun)' : 'built-in (tsc)' }
209
229
  }
210
230
  return `no package.json '${id}' script`
211
231
  }
@@ -258,8 +278,8 @@ export function resolveFloor(c: RepoConfig, root: string, io: FloorReader): Floo
258
278
  const t = { description, ...b }
259
279
  return override == null || override === false ? t : { ...t, ...override, id }
260
280
  }
261
- if (slot.kind === 'script') { tasks.push(decorate({ id, cmd: scriptCmd(c, id, slot.name, slot.body, notes, subs) })); sources[id] = 'package.json script'; continue }
262
- const b = builtinFloorTask(id, root, io, (c.vendored ?? []).map(normalizeVendored))
281
+ if (slot.kind === 'script') { tasks.push(decorate({ id, cmd: scriptCmd(c, root, io, id, slot.name, slot.body, notes, subs) })); sources[id] = 'package.json script'; continue }
282
+ const b = builtinFloorTask(id, root, io, (c.vendored ?? []).map(normalizeVendored), notes)
263
283
  // a routed script with nothing behind it measures NOTHING, and the
264
284
  // reason must say that rather than `no '<id>' script`, which is false
265
285
  if (typeof b === 'string') unfilled.push({ id, reason: slot.kind === 'routed-empty' ? `script '${id}' routes to shipkit and there is no '${rawName(id)}' body to run` : b })
@@ -267,6 +287,6 @@ export function resolveFloor(c: RepoConfig, root: string, io: FloorReader): Floo
267
287
  }
268
288
  const siblings = siblingUnits(subs, io.text)
269
289
  for (const t of unitTestTasks(root, io, subs, siblings, notes, unfilled)) { tasks.push(t); sources[t.id] = 'unit' }
270
- for (const t of unitTypecheckTasks(root, io, subs, siblings, unfilled)) { tasks.push(t); sources[t.id] = 'unit' }
290
+ for (const t of unitTypecheckTasks(root, io, subs, siblings, notes, unfilled)) { tasks.push(t); sources[t.id] = 'unit' }
271
291
  return { tasks, disabled, unfilled, sources, notes }
272
292
  }