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
@@ -0,0 +1,334 @@
1
+ // the identities, who speaks (wiki build/shipkit/social.md, Identities): one folder an identity in the house repo,
2
+ // `.shipkit/identities/<id>/`, its profile, brand, accounts and their places, and a company's legal rows. Read from
3
+ // the disk as it is on every call; the one constraint: never in the npm package, a project names its identity
4
+ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
5
+ import { homedir } from 'node:os'
6
+ import { isAbsolute, join } from 'node:path'
7
+ import { LAYOUT } from '../core/layout.ts'
8
+ import { parseFrontmatter, rows, section, table, type ProfileRow } from '../social/md.ts'
9
+
10
+ const SLUG = /^[a-z0-9-]+$/
11
+
12
+ /** the place `me` is the account's own profile, never a file */
13
+ export const ME = 'me'
14
+
15
+ export type Place = {
16
+ id: string
17
+ name: string
18
+ order: number
19
+ kind: string
20
+ url: string
21
+ write: string
22
+ /** the day or the thread it is for */
23
+ when: string
24
+ /** the label a post there must carry */
25
+ flair: string
26
+ /** absolute */
27
+ file: string
28
+ rules: string
29
+ notes: string
30
+ }
31
+
32
+ /** a `## Setup` step: one bullet of the checklist */
33
+ export type Step = { text: string; done: boolean }
34
+
35
+ export type Account = {
36
+ id: string
37
+ /** the identity it belongs to */
38
+ identity: string
39
+ name: string
40
+ order: number
41
+ handle: string
42
+ profile: string
43
+ /** the profile URL he pasted: the account exists; empty, it is still to create */
44
+ live: string
45
+ write: string
46
+ inbox: string
47
+ stats: string
48
+ max: number | null
49
+ /** the field a message's text goes in: description, comment; empty, the post's own text */
50
+ text: string
51
+ /** the word the accounts that take the same messages share, or empty */
52
+ group: string
53
+ /** where a group's message lands on it, a place id; empty, its own profile */
54
+ place: string
55
+ /** its line's label in the vertical's footer of links; empty, not in it */
56
+ footer: string
57
+ /** live, free, paid, limited or none */
58
+ automation: string
59
+ /** with `automation: live`, the secret name of its token, read through the house's `credsReadCommand` */
60
+ secret: string
61
+ /** Discord: the server's id, its messages' links and the bot's posts */
62
+ guild: string
63
+ /** absolute */
64
+ file: string
65
+ dir: string
66
+ /** the identity's rows with the account's own over them */
67
+ rows: ProfileRow[]
68
+ automationText: string
69
+ steps: Step[]
70
+ notes: string
71
+ places: Place[]
72
+ }
73
+
74
+ export type Picture = { file: string; w: number | null; h: number | null }
75
+
76
+ /** a company as the forms ask it: `legal.md`, and the private rows of the gitignored `legal.local.md` */
77
+ export type Legal = {
78
+ rows: (ProfileRow & { private: boolean })[]
79
+ platforms: { platform: string; payout: string; tax: string }[]
80
+ open: string
81
+ }
82
+
83
+ export type Identity = {
84
+ id: string
85
+ name: string
86
+ order: number
87
+ /** it speaks for a repo that names none */
88
+ default: boolean
89
+ site: string
90
+ siteRepo: string
91
+ /** the folder its picture paths are relative to, absolute: its `files`, else its own folder */
92
+ files: string | null
93
+ dir: string
94
+ /** `identity.md`, absolute */
95
+ file: string
96
+ rows: ProfileRow[]
97
+ brand: ProfileRow[]
98
+ pictures: Picture[]
99
+ legal: Legal | null
100
+ accounts: Account[]
101
+ }
102
+
103
+ export type Identities = { dir: string | null; identities: Identity[]; errors: string[] }
104
+
105
+ const read = (abs: string): string => readFileSync(abs, 'utf8')
106
+ const home = (p: string): string => (p.startsWith('~/') ? join(homedir(), p.slice(2)) : p)
107
+
108
+ /** the folder of every identity: `SHIPKIT_IDENTITIES_DIR`, else the house repo's; null when this machine has no house */
109
+ export async function identitiesDir(cwd = process.cwd()): Promise<string | null> {
110
+ const env = process.env['SHIPKIT_IDENTITIES_DIR']
111
+ if (env) return env
112
+ const { houseRootOf } = await import('../home/home-start.ts')
113
+ const house = houseRootOf(cwd)
114
+ return house == null ? null : join(house, LAYOUT.identities)
115
+ }
116
+
117
+ /** the words a `write` link fills from a message (`fillLink`) */
118
+ const FILLED = ['text', 'url', 'title']
119
+
120
+ /** a page that is set and no https address, a `write` that fills a word no message gives: one error line each */
121
+ function linkErrors(file: string, meta: Record<string, string>, keys: readonly string[], errors: string[]): void {
122
+ for (const k of keys) {
123
+ const v = meta[k] ?? ''
124
+ if (v === '' || (k === 'write' && v === '{url}')) continue
125
+ if (!/^https:\/\/\S+$/.test(v)) errors.push(`${file}: ${k} "${v}" is no https address`)
126
+ else if (k === 'write')
127
+ for (const [, w] of v.matchAll(/\{([^}]*)\}/g))
128
+ if (!FILLED.includes(w!)) errors.push(`${file}: write "${v}" fills {${w}}, never one of ${FILLED.map((f) => `{${f}}`).join(', ')}`)
129
+ }
130
+ }
131
+
132
+ function merged(shared: ProfileRow[], own: ProfileRow[]): ProfileRow[] {
133
+ const mine = new Map(own.map((r) => [r.field, r]))
134
+ return [...shared.map((r) => mine.get(r.field) ?? r), ...own.filter((r) => !shared.some((s) => s.field === r.field))]
135
+ }
136
+
137
+ function places(dir: string, errors: string[]): Place[] {
138
+ const at = join(dir, 'places')
139
+ if (!existsSync(at)) return []
140
+ const out: Place[] = []
141
+ for (const f of readdirSync(at).sort()) {
142
+ if (!f.endsWith('.md')) continue
143
+ const id = f.slice(0, -3)
144
+ const abs = join(at, f)
145
+ if (!SLUG.test(id) || id === ME) {
146
+ errors.push(`${abs}: name must be <place>.md, kebab case, never ${ME}`)
147
+ continue
148
+ }
149
+ const { meta, body } = parseFrontmatter(read(abs))
150
+ linkErrors(abs, meta, ['url', 'write'], errors)
151
+ out.push({
152
+ id,
153
+ name: meta.name ?? id,
154
+ order: Number(meta.order ?? 99),
155
+ kind: meta.kind ?? '',
156
+ url: meta.url ?? '',
157
+ write: meta.write ?? '',
158
+ when: meta.when ?? '',
159
+ flair: meta.flair ?? '',
160
+ file: abs,
161
+ rules: section(body, 'Rules') ?? '',
162
+ notes: section(body, 'Notes') ?? '',
163
+ })
164
+ }
165
+ return out.sort((a, b) => a.order - b.order || a.id.localeCompare(b.id))
166
+ }
167
+
168
+ export const STEP = /^- (?:\[( |x)\] )?(.*)$/
169
+
170
+ /** the bullets of `## Setup`, an indented line joining the step above it */
171
+ function steps(body: string): Step[] {
172
+ const out: Step[] = []
173
+ for (const line of (section(body, 'Setup') ?? '').split('\n')) {
174
+ const m = STEP.exec(line)
175
+ if (m) out.push({ text: m[2]!, done: m[1] === 'x' })
176
+ else if (line.trim() !== '' && out.length > 0) out[out.length - 1]!.text += ` ${line.trim()}`
177
+ }
178
+ return out
179
+ }
180
+
181
+ /** a png's or a jpg's size from its header (a jpg's first frame marker); null for any other file */
182
+ function imageSize(abs: string): { w: number | null; h: number | null } {
183
+ try {
184
+ if (abs.endsWith('.png')) {
185
+ const b = readFileSync(abs).subarray(16, 24)
186
+ return { w: b.readUInt32BE(0), h: b.readUInt32BE(4) }
187
+ }
188
+ if (!abs.endsWith('.jpg')) return { w: null, h: null }
189
+ const b = readFileSync(abs)
190
+ for (let i = 2; i + 9 < b.length; i += 2 + b.readUInt16BE(i + 2)) {
191
+ const m = b[i + 1] ?? 0
192
+ if (b[i] !== 0xff) break
193
+ // SOF0 to SOF15, past DHT (c4), JPG (c8) and DAC (cc)
194
+ if (m >= 0xc0 && m <= 0xcf && m !== 0xc4 && m !== 0xc8 && m !== 0xcc) return { w: b.readUInt16BE(i + 7), h: b.readUInt16BE(i + 5) }
195
+ }
196
+ } catch {
197
+ // an unreadable picture shows with no size
198
+ }
199
+ return { w: null, h: null }
200
+ }
201
+
202
+ /** the pictures of each `pictures` folder, each folder the largest first: a folder under `files`, or a `~/…` or
203
+ * absolute one elsewhere on the disk (a repo's own files the identity names), its pictures named by that path */
204
+ function pictures(files: string | null, dirs: string, file: string, errors: string[]): Picture[] {
205
+ if (files == null) return []
206
+ const out: Picture[] = []
207
+ for (const dir of dirs.split(',').map((d) => d.trim()).filter(Boolean)) {
208
+ const abs = dir.startsWith('~/') || isAbsolute(dir) ? home(dir) : join(files, dir)
209
+ if (!existsSync(abs)) {
210
+ errors.push(`${file}: pictures "${dir}" is no folder on this disk`)
211
+ continue
212
+ }
213
+ const here: Picture[] = []
214
+ for (const f of readdirSync(abs).sort()) if (/\.(png|jpg|webp|mp4)$/.test(f)) here.push({ file: `${dir}/${f}`, ...imageSize(join(abs, f)) })
215
+ out.push(...here.sort((x, y) => (y.w ?? 0) * (y.h ?? 0) - (x.w ?? 0) * (x.h ?? 0)))
216
+ }
217
+ return out
218
+ }
219
+
220
+ function legal(dir: string, files: string | null): Legal | null {
221
+ const at = (f: string): string | null => (existsSync(join(dir, f)) ? parseFrontmatter(read(join(dir, f))).body : null)
222
+ const pub = at('legal.md')
223
+ if (pub == null) return null
224
+ return {
225
+ rows: [...rows(pub, 'Legal', files).map((r) => ({ ...r, private: false })), ...rows(at('legal.local.md') ?? '', 'Legal', files).map((r) => ({ ...r, private: true }))],
226
+ platforms: table(pub, 'Platforms').map(([platform = '', payout = '', tax = '']) => ({ platform, payout, tax })),
227
+ open: section(pub, 'Open') ?? '',
228
+ }
229
+ }
230
+
231
+ function account(identity: string, id: string, dir: string, shared: ProfileRow[], files: string | null, errors: string[]): Account {
232
+ const file = join(dir, 'account.md')
233
+ const { meta, body } = parseFrontmatter(read(file))
234
+ linkErrors(file, meta, ['profile', 'live', 'write', 'inbox', 'stats'], errors)
235
+ return {
236
+ id,
237
+ identity,
238
+ name: meta.name ?? id,
239
+ order: Number(meta.order ?? 99),
240
+ handle: meta.handle ?? '',
241
+ profile: meta.profile ?? '',
242
+ live: meta.live ?? '',
243
+ write: meta.write ?? '',
244
+ inbox: meta.inbox ?? '',
245
+ stats: meta.stats ?? '',
246
+ max: meta.max ? Number(meta.max) : null,
247
+ text: meta.text ?? '',
248
+ group: meta.group ?? '',
249
+ place: meta.place ?? '',
250
+ footer: meta.footer ?? '',
251
+ automation: meta.automation ?? 'none',
252
+ secret: meta.secret ?? '',
253
+ guild: meta.guild ?? '',
254
+ file,
255
+ dir,
256
+ rows: merged(shared, rows(body, 'Profile', files)),
257
+ automationText: section(body, 'Automation') ?? '',
258
+ steps: steps(body),
259
+ notes: section(body, 'Notes') ?? '',
260
+ places: places(dir, errors),
261
+ }
262
+ }
263
+
264
+ function identity(id: string, dir: string, errors: string[]): Identity {
265
+ const file = join(dir, 'identity.md')
266
+ const { meta, body } = parseFrontmatter(read(file))
267
+ const files = meta.files ? home(meta.files) : dir
268
+ if (!isAbsolute(files) || !existsSync(files)) errors.push(`${file}: files "${meta.files}" is no folder on this disk`)
269
+ const shared = rows(body, 'Profile', files)
270
+ const at = join(dir, 'accounts')
271
+ const accounts: Account[] = []
272
+ if (existsSync(at))
273
+ for (const a of readdirSync(at).sort()) {
274
+ const adir = join(at, a)
275
+ if (!statSync(adir).isDirectory()) continue
276
+ if (!SLUG.test(a)) errors.push(`${adir}: an account folder is kebab case`)
277
+ else if (!existsSync(join(adir, 'account.md'))) errors.push(`${adir}: no account.md`)
278
+ else accounts.push(account(id, a, adir, shared, files, errors))
279
+ }
280
+ accounts.sort((a, b) => a.order - b.order || a.id.localeCompare(b.id))
281
+ for (const a of accounts) if (a.automation === 'live' && a.secret === '') errors.push(`${a.file}: automation live names no secret (its token name)`)
282
+ return {
283
+ id,
284
+ name: meta.name ?? id,
285
+ order: Number(meta.order ?? 99),
286
+ default: meta.default === 'true',
287
+ site: meta.site ?? '',
288
+ siteRepo: meta.siteRepo ?? '',
289
+ files,
290
+ dir,
291
+ file,
292
+ rows: shared,
293
+ brand: rows(body, 'Brand', files),
294
+ pictures: pictures(files, meta.pictures ?? '', file, errors),
295
+ legal: legal(dir, files),
296
+ accounts,
297
+ }
298
+ }
299
+
300
+ /** every identity in its order; a broken folder is an error line, never a silence */
301
+ export function readIdentities(dir: string | null): Identities {
302
+ const errors: string[] = []
303
+ if (dir == null) return { dir, identities: [], errors: ['no house repo on this machine: the identities live in its .shipkit/identities/'] }
304
+ if (!existsSync(dir)) return { dir, identities: [], errors: [`${dir}: no identities folder`] }
305
+ const out: Identity[] = []
306
+ for (const id of readdirSync(dir).sort()) {
307
+ const idir = join(dir, id)
308
+ if (!statSync(idir).isDirectory()) continue
309
+ if (!SLUG.test(id)) errors.push(`${idir}: an identity id is kebab case`)
310
+ else if (!existsSync(join(idir, 'identity.md'))) errors.push(`${idir}: no identity.md`)
311
+ else out.push(identity(id, idir, errors))
312
+ }
313
+ out.sort((a, b) => a.order - b.order || a.id.localeCompare(b.id))
314
+ const defaults = out.filter((i) => i.default)
315
+ if (out.length > 0 && defaults.length !== 1) errors.push(`${dir}: ${defaults.length === 0 ? 'no identity is' : `${defaults.map((i) => i.id).join(' and ')} are each`} marked default: true; one speaks for a repo that names none`)
316
+ return { dir, identities: out, errors }
317
+ }
318
+
319
+ export async function loadIdentities(o: { dir?: string | null; cwd?: string } = {}): Promise<Identities> {
320
+ return readIdentities(o.dir !== undefined ? o.dir : await identitiesDir(o.cwd))
321
+ }
322
+
323
+ /** the identity a repo speaks as: its `speaksAs`, else the default one; null with no identity at all */
324
+ export function speakerOf(speaksAs: string | undefined, ids: Identities): Identity | null {
325
+ if (speaksAs != null) return ids.identities.find((i) => i.id === speaksAs) ?? null
326
+ return ids.identities.find((i) => i.default) ?? ids.identities[0] ?? null
327
+ }
328
+
329
+ /** one identity by id, or a loud error naming the ones there are */
330
+ export function identityOf(id: string, ids: Identities): Identity {
331
+ const i = ids.identities.find((x) => x.id === id)
332
+ if (i == null) throw new Error(`no identity "${id}" (${ids.identities.map((x) => x.id).join(', ') || 'none'}) in ${ids.dir ?? 'no house repo'}`)
333
+ return i
334
+ }
@@ -0,0 +1,126 @@
1
+ // the home's identities page (wiki build/shipkit/home.md, Identities): every identity, its accounts, the repos that
2
+ // speak as it, and where its data lives on disk. `POST /api/home/identities/open` opens one of those places in VS Code
3
+ // or the Finder; it names an identity, a place and a repo, never a path
4
+ import { existsSync, readdirSync } from 'node:fs'
5
+ import { homedir } from 'node:os'
6
+ import { openInCode } from '../serve/project-gutter-route.ts'
7
+ import { houseRepoRoots } from '../social/house.ts'
8
+ import { draftsDir } from '../social/load.ts'
9
+ import { veilleLogDir } from '../veille/identity.ts'
10
+ import { identitiesDir, readIdentities, type Identities, type Identity } from './identities.ts'
11
+ import { railOf, speakerIdOf, type RailIdentity } from './machine.ts'
12
+
13
+ /** a place on disk that holds an identity's data */
14
+ export type DataPlace = {
15
+ place: 'folder' | 'pictures' | 'veille' | 'drafts'
16
+ /** the repo, for a drafts folder */
17
+ repo: string | null
18
+ /** what it holds, in words */
19
+ label: string
20
+ /** the path, `~` for the home */
21
+ shown: string
22
+ exists: boolean
23
+ /** the drafts in it, the days of the Veille log; null where nothing is counted */
24
+ count: number | null
25
+ }
26
+
27
+ export type MachineAccount = { id: string; name: string; handle: string; live: string; profile: string; automation: string }
28
+
29
+ export type MachineIdentity = RailIdentity & {
30
+ bio: string
31
+ site: string
32
+ siteRepo: string
33
+ accounts: MachineAccount[]
34
+ repos: string[]
35
+ data: DataPlace[]
36
+ }
37
+
38
+ export type IdentitiesAnswer = {
39
+ dir: string | null
40
+ identities: MachineIdentity[]
41
+ /** repos whose `speaksAs` no folder holds */
42
+ strays: { repo: string; speaksAs: string }[]
43
+ errors: string[]
44
+ }
45
+
46
+ const tilde = (abs: string): string => (abs.startsWith(homedir() + '/') ? `~${abs.slice(homedir().length)}` : abs)
47
+
48
+ const count = (dir: string, keep: (name: string) => boolean): number | null => {
49
+ try {
50
+ return readdirSync(dir).filter(keep).length
51
+ } catch {
52
+ return null
53
+ }
54
+ }
55
+
56
+ type Repo = { name: string; path: string; speaksAs: string | undefined }
57
+
58
+ /** each place of an identity's data, with its absolute path */
59
+ function placesOf(i: Identity, repos: Repo[], ids: Identities): (DataPlace & { abs: string })[] {
60
+ const mine = repos.filter((r) => speakerIdOf(r.speaksAs, ids) === i.id)
61
+ const out: (DataPlace & { abs: string })[] = [
62
+ { place: 'folder', repo: null, label: 'its profile, accounts and places (identity.md, accounts/)', abs: i.dir, shown: '', exists: true, count: null },
63
+ ]
64
+ if (i.files != null && i.files !== i.dir) out.push({ place: 'pictures', repo: null, label: 'its pictures (files: in identity.md)', abs: i.files, shown: '', exists: existsSync(i.files), count: null })
65
+ const log = veilleLogDir(i.id)
66
+ out.push({ place: 'veille', repo: null, label: 'its Veille log, this machine only', abs: log, shown: '', exists: existsSync(log), count: count(log, (n) => n.endsWith('.jsonl')) })
67
+ for (const r of mine) {
68
+ const d = draftsDir(r.path)
69
+ out.push({ place: 'drafts', repo: r.name, label: `the drafts of ${r.name}`, abs: d, shown: '', exists: existsSync(d), count: count(d, (n) => !n.startsWith('.')) })
70
+ }
71
+ return out.map((p) => ({ ...p, shown: tilde(p.abs) }))
72
+ }
73
+
74
+ async function read(root: string): Promise<{ ids: Identities; repos: Repo[] }> {
75
+ return { ids: readIdentities(await identitiesDir(root)), repos: await houseRepoRoots(root) }
76
+ }
77
+
78
+ export async function identitiesAnswer(root: string): Promise<IdentitiesAnswer> {
79
+ const { ids, repos } = await read(root)
80
+ const known = new Set(ids.identities.map((i) => i.id))
81
+ return {
82
+ dir: ids.dir == null ? null : tilde(ids.dir),
83
+ identities: ids.identities.map((i) => ({
84
+ ...railOf(i),
85
+ bio: i.rows.find((r) => r.field === 'bio')?.value ?? '',
86
+ site: i.site,
87
+ siteRepo: i.siteRepo,
88
+ accounts: i.accounts.map((a) => ({ id: a.id, name: a.name, handle: a.handle, live: a.live, profile: a.profile, automation: a.automation })),
89
+ repos: repos.filter((r) => speakerIdOf(r.speaksAs, ids) === i.id).map((r) => r.name),
90
+ data: placesOf(i, repos, ids).map(({ abs: _abs, ...p }) => p),
91
+ })),
92
+ strays: repos.filter((r) => r.speaksAs != null && !known.has(r.speaksAs)).map((r) => ({ repo: r.name, speaksAs: r.speaksAs! })),
93
+ errors: ids.errors,
94
+ }
95
+ }
96
+
97
+ /** what opens a place: VS Code, or the Finder */
98
+ export type Opener = { code: (abs: string) => void; finder: (abs: string) => void }
99
+
100
+ const OPEN: Opener = {
101
+ code: openInCode,
102
+ finder: (abs) => {
103
+ if (process.platform !== 'darwin') throw new Error('the Finder is macOS only')
104
+ Bun.spawn(['open', abs], { stdio: ['ignore', 'ignore', 'ignore'] }).unref()
105
+ },
106
+ }
107
+
108
+ /** null when the path is not this route's */
109
+ export async function identitiesRoute(req: Request, path: string, root: string, open: Opener = OPEN): Promise<Response | null> {
110
+ if (path === '/api/home/identities.json') return Response.json(await identitiesAnswer(root), { headers: { 'cache-control': 'no-store' } })
111
+ if (path !== '/api/home/identities/open' || req.method !== 'POST') return null
112
+ const b = (await req.json().catch(() => ({}))) as { id?: unknown; place?: unknown; repo?: unknown; app?: unknown }
113
+ if (b.app !== 'code' && b.app !== 'finder') return new Response('app must be code or finder', { status: 400 })
114
+ const { ids, repos } = await read(root)
115
+ const i = ids.identities.find((x) => x.id === b.id)
116
+ if (i == null) return new Response(`no identity ${JSON.stringify(b.id)} (${ids.identities.map((x) => x.id).join(', ') || 'none'})`, { status: 404 })
117
+ const hit = placesOf(i, repos, ids).find((p) => p.place === b.place && (p.repo ?? null) === (b.repo ?? null))
118
+ if (hit == null) return new Response(`${i.id} has no place ${JSON.stringify(b.place)}${b.repo == null ? '' : ` in ${JSON.stringify(b.repo)}`}`, { status: 404 })
119
+ if (!existsSync(hit.abs)) return new Response(`${hit.shown} does not exist yet`, { status: 404 })
120
+ try {
121
+ open[b.app](hit.abs)
122
+ } catch (e) {
123
+ return new Response((e as Error).message, { status: 400 })
124
+ }
125
+ return Response.json({ ok: true, opened: hit.shown })
126
+ }
@@ -0,0 +1,62 @@
1
+ // the identities as the machine's surfaces show them (wiki build/shipkit/social.md, Identities): the project list's
2
+ // headers (`railIdentities`: a name, a colour, a mark) and the repo each row speaks as. Read again only when an
3
+ // `identity.md` of the folder moves, so the list's 5 s poll costs a few stats
4
+ import { existsSync, readdirSync, statSync } from 'node:fs'
5
+ import { join } from 'node:path'
6
+ import { readIdentities, speakerOf, type Identities, type Identity } from './identities.ts'
7
+
8
+ /** one identity as a header of the project list draws it */
9
+ export type RailIdentity = {
10
+ id: string
11
+ name: string
12
+ default: boolean
13
+ /** its first brand colour, a hex; null when its brand names none */
14
+ colour: string | null
15
+ /** the url of its mark (the first file of its profile's avatar row), null with none: the initial on its colour */
16
+ mark: string | null
17
+ }
18
+
19
+ const HEX = /^#[0-9a-f]{6}$/i
20
+
21
+ export const colourOf = (i: Identity): string | null => i.brand.find((r) => HEX.test(r.value))?.value ?? null
22
+
23
+ /** the avatar's file, absolute: the first file its profile's avatar row names */
24
+ export function markFile(i: Identity): string | null {
25
+ const f = i.rows.find((r) => r.field === 'avatar')?.files[0]
26
+ return f == null || i.files == null ? null : join(i.files, f)
27
+ }
28
+
29
+ const stampOf = (abs: string): number => {
30
+ try {
31
+ return Math.round(statSync(abs).mtimeMs)
32
+ } catch {
33
+ return 0
34
+ }
35
+ }
36
+
37
+ /** the folder's listing and each identity.md's mtime: what moves when an identity is added, renamed or edited */
38
+ function folderStamp(dir: string | null): string {
39
+ if (dir == null || !existsSync(dir)) return `${dir}:none`
40
+ return readdirSync(dir).sort().map((id) => `${id}:${stampOf(join(dir, id, 'identity.md'))}`).join('|')
41
+ }
42
+
43
+ /** the url the gutter serves an identity's mark at (project-gutter-route.ts), its stamp in it */
44
+ export const markUrl = (i: Identity): string | null => {
45
+ const f = markFile(i)
46
+ return f == null ? null : `/api/projects/identity-mark/${encodeURIComponent(i.id)}?v=${stampOf(f)}`
47
+ }
48
+
49
+ export const railOf = (i: Identity): RailIdentity => ({ id: i.id, name: i.name, default: i.default, colour: colourOf(i), mark: markUrl(i) })
50
+
51
+ /** the identities of a folder, read once per change of an identity.md; one cache per caller */
52
+ export function identityCache(): (dir: string | null) => Identities {
53
+ let held: { dir: string | null; stamp: string; ids: Identities } | null = null
54
+ return (dir) => {
55
+ const stamp = folderStamp(dir)
56
+ if (held == null || held.dir !== dir || held.stamp !== stamp) held = { dir, stamp, ids: readIdentities(dir) }
57
+ return held.ids
58
+ }
59
+ }
60
+
61
+ /** the id a repo speaks as: its own `speaksAs`, else the default; null on a machine with no identity, or an id no folder holds */
62
+ export const speakerIdOf = (speaksAs: string | undefined, ids: Identities): string | null => speakerOf(speaksAs, ids)?.id ?? null
package/src/init-repo.ts CHANGED
@@ -27,7 +27,7 @@ const CONFIG_TEMPLATE = (name: string): string => `import { defineRepo } from 'r
27
27
  export default defineRepo({
28
28
  name: '${name}',
29
29
  venues: [], // e.g. ['itch', 'steam'], selects which .shipkit/<venue>/ contracts are REQUIRED
30
- social: [], // e.g. ['x', 'discord'], the .shipkit/social/<channel>/ post folders (+ .shipkit/discord/)
30
+ // speaksAs: 'me', // the identity that speaks for this repo (sk identities); unset, the default one
31
31
  tasks: [], // repo commit-gate tasks; deps double as race guards
32
32
  // lint, typecheck, imports:check and cycles are cached on the tracked tree.
33
33
  // \`test\` runs every time until you say what it reads, because an
@@ -16,7 +16,7 @@
16
16
  // measures a check, and the store is only ever the history of the other two.
17
17
  import type { RunRow, RunStatus } from './run-log.ts'
18
18
  import { readRuns, runsPath, runsStamp } from './run-log.ts'
19
- import { answersDb, answersStamp, listAnswers } from './store.ts'
19
+ import { answerMeasures, answersDb, answersStamp } from './store.ts'
20
20
 
21
21
  /** one measurement read back off the store */
22
22
  export type StoreSample = { key: string; at: number; ms: number; status: RunStatus }
@@ -99,19 +99,16 @@ export function mergeCheckStats(o: { runs: RunRow[]; store: StoreSample[] }): Ma
99
99
  export function scanCheckStore(db: string, checks: { id: string }[]): StoreSample[] {
100
100
  const ids = new Set(checks.map((c) => c.id))
101
101
  const out: StoreSample[] = []
102
- for (const r of listAnswers(db, 'checks')) {
103
- if (!ids.has(r.name)) continue
104
- try {
105
- const p = JSON.parse(r.payload) as { measuredMs?: number; status?: RunStatus }
106
- if (typeof p.measuredMs !== 'number') continue
107
- out.push({ key: r.name, at: r.at, ms: p.measuredMs, status: p.status === 'warn' ? 'warn' : 'pass' })
108
- } catch { /* a row that does not parse is no sample */ }
102
+ for (const r of answerMeasures(db, 'checks')) {
103
+ if (!ids.has(r.name) || typeof r.ms !== 'number') continue
104
+ out.push({ key: r.name, at: r.at, ms: r.ms, status: r.status === 'warn' ? 'warn' : 'pass' })
109
105
  }
110
106
  return out
111
107
  }
112
108
 
113
109
  type Cached = { stamp: string; stats: Map<string, CheckStat> }
114
110
  const cache = new Map<string, Cached>()
111
+ const stores = new Map<string, { key: string; samples: StoreSample[] }>()
115
112
 
116
113
  /** the per check numbers for a repo, cached on what the two sources look like
117
114
  * from the outside: a count and newest stamp of each, since the hub asks on
@@ -123,7 +120,11 @@ export function checkStatsFor(root: string, checks: { id: string }[], o?: { fres
123
120
  const stamp = `${checks.length}:${answersStamp(db, 'checks')}:${runsStamp(record)}`
124
121
  const hit = cache.get(root)
125
122
  if (o?.fresh !== true && hit != null && hit.stamp === stamp) return hit.stats
126
- const stats = mergeCheckStats({ runs: readRuns(record), store: scanCheckStore(db, checks) })
123
+ // the store moves only when a check writes an answer; a run moves only the record
124
+ const storeKey = `${checks.map((c) => c.id).join(',')}:${answersStamp(db, 'checks')}`
125
+ let store = stores.get(root)
126
+ if (store?.key !== storeKey) stores.set(root, (store = { key: storeKey, samples: scanCheckStore(db, checks) }))
127
+ const stats = mergeCheckStats({ runs: readRuns(record), store: store.samples })
127
128
  cache.set(root, { stamp, stats })
128
129
  return stats
129
130
  }
@@ -17,6 +17,8 @@ import type { CheckCtx } from '../core/check-ctx.ts'
17
17
  import { type RepoConfig } from '../repo-config.ts'
18
18
  import { auditedExtras, ignoredFor, readAuditReport } from '../core/audit-report.ts'
19
19
  import { listRepoFiles, resolveFloor, slotDescription, type FloorResolution } from '../core/floor.ts'
20
+ import { treeRev } from '../core/tree-rev.ts'
21
+ import { yieldLoop } from '../core/loop-watch.ts'
20
22
  import { discoverLegacyChecks } from '../core/discover-legacy-checks.ts'
21
23
  import { checkFileRunBy } from '../core/legacy-shapes.ts'
22
24
  import { ruleCacheExtra } from '../rules/rule.ts'
@@ -258,6 +260,9 @@ function fileRuns(def: CheckDef, id: string, c: RepoConfig, env: CheckEnv): Reso
258
260
  return withRepoOff(base, repoOff(c, id))
259
261
  }
260
262
 
263
+ /** check files a compose reads (their key, their code) before it gives the loop back */
264
+ const COMPOSE_STEP = 8
265
+
261
266
  /** THE enumeration. Everything below reads it, nothing else walks. */
262
267
  export async function composeChecks(root: string, c: RepoConfig, o: ComposeOpts = {}): Promise<GateCheck[]> {
263
268
  const out: GateCheck[] = []
@@ -295,7 +300,11 @@ export async function composeChecks(root: string, c: RepoConfig, o: ComposeOpts
295
300
  // carries the tier flag rather than one task id: a repo names its suites
296
301
  // what it likes, and a gate that guesses which one is the tests will miss
297
302
  // one.
303
+ // a compose is seconds of sync work on a large repo: the loop goes back to the pages between its parts (wiki
304
+ // build/shipkit/home.md, Nothing heavy on the daemon's loop)
305
+ await yieldLoop()
298
306
  const rootTest = rootTestKey(root, c, floor)
307
+ await yieldLoop()
299
308
  // a task that declares nothing is keyed on the whole work tree, plus the
300
309
  // gitignored paths it reads. The work tree sees no ignored file, so those
301
310
  // are named: by the config, and by the kept traced audit (SK031), whose
@@ -387,7 +396,9 @@ export async function composeChecks(root: string, c: RepoConfig, o: ComposeOpts
387
396
  // every `*.check.ts` this repo and the toolkit declare
388
397
  const configs = new Map<string, RvtConfig>()
389
398
  const texts = new Map<string, string>()
399
+ let n = 0
390
400
  for (const u of checks) {
401
+ if (++n % COMPOSE_STEP === 0) await yieldLoop()
391
402
  const runs = fileRuns(u.def, u.id, c, env)
392
403
  const cache = declOfCache(u.def.cache, env)
393
404
  // a body keyed on what it reads through its context (git-key.ts
@@ -559,9 +570,29 @@ export async function composeChecks(root: string, c: RepoConfig, o: ComposeOpts
559
570
 
560
571
  /** every check the gate knows, with its metadata. */
561
572
  export async function gateInventory(root: string, c: RepoConfig, o: ComposeOpts = {}): Promise<CheckRow[]> {
562
- return (await composeChecks(root, c, o)).map((g) => g.row)
573
+ const rev = treeRev(root)
574
+ if (rev == null) return (await composeChecks(root, c, o)).map((g) => g.row)
575
+ const tier = o.tier ?? 'quick'
576
+ const byTier = inventories.get(c) ?? new Map<string, KeptInventory>()
577
+ inventories.set(c, byTier)
578
+ const key = `${root}\0${tier}`
579
+ const held = byTier.get(key)
580
+ if (held != null && held.rev === rev && Date.now() - held.at < INVENTORY_KEEP_MS) return (await held.rows).slice()
581
+ const rows = composeChecks(root, c, o).then((all) => all.map((g) => g.row))
582
+ byTier.set(key, { rev, at: Date.now(), rows })
583
+ rows.catch(() => { if (byTier.get(key)?.rows === rows) byTier.delete(key) })
584
+ return (await rows).slice()
563
585
  }
564
586
 
587
+ /** how long a kept inventory stands for what no save moves: the cache keys of its checks read a few things outside the
588
+ * tree (the house repos, the hooks path, the keyword files) */
589
+ export const INVENTORY_KEEP_MS = 60_000
590
+ type KeptInventory = { rev: number; at: number; rows: Promise<CheckRow[]> }
591
+ /** the read side's inventory (the pages, the plan, the timeline), by config and tier, kept while the tree's revision
592
+ * holds (core/tree-rev.ts): a compose costs a repo listing and every check's key, and the warm answers ask it several
593
+ * times a refresh. A gate composes its own, never from here */
594
+ const inventories = new WeakMap<RepoConfig, Map<string, KeptInventory>>()
595
+
565
596
  /** the same list, as the runner takes it */
566
597
  export async function gateRunnables(root: string, c: RepoConfig, o: ComposeOpts = {}): Promise<RunnableCheck[]> {
567
598
  return (await composeChecks(root, c, o)).map((g) => g.runnable)