rvlib-shipkit 2.12.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 (290) hide show
  1. package/CHANGELOG.md +48 -13
  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 +7 -5
  20. package/src/cli/cmd_Review.ts +4 -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 +5 -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 +53 -4
  68. package/src/home/inbox.ts +16 -1
  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 +104 -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 +2 -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/daemon.ts +56 -70
  100. package/src/media-store/put.ts +4 -2
  101. package/src/media-store/space.ts +23 -4
  102. package/src/pages/forward.ts +35 -0
  103. package/src/pages/frame-client.ts +118 -0
  104. package/src/pages/routes.ts +29 -0
  105. package/src/pages/unit.ts +92 -0
  106. package/src/plan/planner.ts +12 -0
  107. package/src/plan/repo-source.ts +19 -5
  108. package/src/reflect/transcript.ts +35 -10
  109. package/src/release/public-clean.ts +301 -0
  110. package/src/release/published-here.ts +22 -0
  111. package/src/release/run-bump.ts +2 -1
  112. package/src/release/run-release.ts +4 -1
  113. package/src/repo-config.ts +53 -2
  114. package/src/review/http.ts +16 -2
  115. package/src/review/model.ts +15 -4
  116. package/src/review/notes.ts +77 -0
  117. package/src/review/project.ts +6 -38
  118. package/src/review/routes.ts +4 -12
  119. package/src/review/store.ts +41 -1
  120. package/src/review/trailer-media.ts +7 -4
  121. package/src/review/trailer-shots.ts +21 -4
  122. package/src/review/unit.ts +1 -1
  123. package/src/scaffold/files/agent-handoff.md +3 -0
  124. package/src/scaffold/files/agent-index.md +4 -12
  125. package/src/scaffold/project-scaffold.ts +5 -4
  126. package/src/serve/embed.ts +1 -1
  127. package/src/serve/hub-app/col-card.tsx +3 -17
  128. package/src/serve/hub-app/col-tables-view.tsx +2 -1
  129. package/src/serve/hub-app/cols-svc.ts +0 -13
  130. package/src/serve/hub-app/dock-st.ts +4 -2
  131. package/src/serve/hub-app/dock-view.tsx +2 -0
  132. package/src/serve/hub-app/frames-st.ts +35 -0
  133. package/src/serve/hub-app/hash-route.ts +64 -1
  134. package/src/serve/hub-app/home-st.ts +31 -7
  135. package/src/serve/hub-app/home-strip.css +9 -1
  136. package/src/serve/hub-app/home-strip.tsx +7 -6
  137. package/src/serve/hub-app/home.html +5 -0
  138. package/src/serve/hub-app/hub-app.tsx +49 -5
  139. package/src/serve/hub-app/hub.css +29 -11
  140. package/src/serve/hub-app/icons.tsx +16 -1
  141. package/src/serve/hub-app/identities-st.ts +210 -0
  142. package/src/serve/hub-app/identities-view.tsx +352 -0
  143. package/src/serve/hub-app/identities.css +48 -0
  144. package/src/serve/hub-app/identity-address.ts +52 -0
  145. package/src/serve/hub-app/inbox-st.ts +59 -6
  146. package/src/serve/hub-app/inbox-view.tsx +48 -6
  147. package/src/serve/hub-app/inbox.css +12 -1
  148. package/src/serve/hub-app/index.html +3 -0
  149. package/src/serve/hub-app/keys.ts +10 -2
  150. package/src/serve/hub-app/list-walk.ts +89 -0
  151. package/src/serve/hub-app/machine-st.ts +12 -0
  152. package/src/serve/hub-app/media-view.tsx +2 -1
  153. package/src/serve/hub-app/pages-frames.tsx +134 -0
  154. package/src/serve/hub-app/pages-svc.ts +111 -0
  155. package/src/serve/hub-app/palette-st.ts +18 -3
  156. package/src/serve/hub-app/palette-view.tsx +9 -2
  157. package/src/serve/hub-app/planned-view.tsx +2 -1
  158. package/src/serve/hub-app/project-list.css +18 -14
  159. package/src/serve/hub-app/project-list.tsx +88 -49
  160. package/src/serve/hub-app/projects-svc.ts +33 -3
  161. package/src/serve/hub-app/repo-sections.ts +19 -2
  162. package/src/serve/hub-app/repo-st.ts +75 -19
  163. package/src/serve/hub-app/review/review-cells.tsx +3 -3
  164. package/src/serve/hub-app/review/review-kit.ts +30 -7
  165. package/src/serve/hub-app/review/review-page.tsx +1 -1
  166. package/src/serve/hub-app/review/review-st.ts +19 -8
  167. package/src/serve/hub-app/review/review-thread.tsx +11 -9
  168. package/src/serve/hub-app/review/review-views.tsx +84 -19
  169. package/src/serve/hub-app/review/thread-st.ts +1 -10
  170. package/src/serve/hub-app/review/trailer-page.tsx +2 -1
  171. package/src/serve/hub-app/review.css +17 -8
  172. package/src/serve/hub-app/site/site-part.tsx +173 -0
  173. package/src/serve/hub-app/site/site-st.ts +157 -0
  174. package/src/serve/hub-app/site.css +35 -0
  175. package/src/serve/hub-app/social/calendar.tsx +182 -0
  176. package/src/serve/hub-app/social/comms-page.tsx +306 -0
  177. package/src/serve/hub-app/social/kit.tsx +244 -0
  178. package/src/serve/hub-app/social/post-card.tsx +456 -0
  179. package/src/serve/hub-app/social/problems.tsx +60 -0
  180. package/src/serve/hub-app/social/social-model.ts +154 -0
  181. package/src/serve/hub-app/social/social-page.tsx +674 -0
  182. package/src/serve/hub-app/social/social-st.ts +986 -0
  183. package/src/serve/hub-app/social.css +289 -0
  184. package/src/serve/hub-app/stores/stores-page.tsx +311 -0
  185. package/src/serve/hub-app/stores/stores-st.ts +286 -0
  186. package/src/serve/hub-app/stores.css +54 -0
  187. package/src/serve/hub-app/timeline-geometry.ts +1 -1
  188. package/src/serve/hub-app/timeline-view.tsx +3 -2
  189. package/src/serve/hub-app/tree-build.ts +6 -0
  190. package/src/serve/hub-app/tree-row.tsx +27 -4
  191. package/src/serve/hub-app/tree-svc.ts +18 -49
  192. package/src/serve/hub-app/veille/veille-page.tsx +514 -0
  193. package/src/serve/hub-app/veille/veille-st.ts +443 -0
  194. package/src/serve/hub-app/veille.css +84 -0
  195. package/src/serve/hub-runtime.ts +14 -9
  196. package/src/serve/project-gutter-route.ts +44 -12
  197. package/src/serve/run-lanes.ts +7 -4
  198. package/src/serve/same-origin.ts +1 -1
  199. package/src/serve/serve-hub.ts +20 -12
  200. package/src/serve/tracked-watch.ts +24 -3
  201. package/src/serve/warm-cell.ts +5 -1
  202. package/src/shipkit-files.ts +15 -4
  203. package/src/shipkit.ts +0 -1
  204. package/src/shot/box.ts +162 -0
  205. package/src/shot/browser-slot.ts +62 -0
  206. package/src/shot/client.ts +43 -7
  207. package/src/shot/clip-encoder.ts +93 -12
  208. package/src/shot/film-box.ts +188 -0
  209. package/src/shot/shooter.ts +50 -15
  210. package/src/shot/shot-ask.ts +10 -2
  211. package/src/shot/stepped-clip.ts +5 -4
  212. package/src/site/desk.ts +242 -0
  213. package/src/site/routes.ts +66 -0
  214. package/src/site/unit.ts +62 -0
  215. package/src/social/brands.ts +22 -0
  216. package/src/social/compose.ts +97 -0
  217. package/src/social/desk-index.ts +123 -0
  218. package/src/social/desk-wire.ts +64 -0
  219. package/src/social/drafts.ts +183 -0
  220. package/src/social/house.ts +24 -0
  221. package/src/social/load.ts +319 -0
  222. package/src/social/md.ts +70 -0
  223. package/src/social/media-facts.ts +53 -0
  224. package/src/social/media-kind.ts +189 -0
  225. package/src/social/media-limit.ts +42 -0
  226. package/src/social/media-of.ts +30 -0
  227. package/src/social/migrate.ts +123 -0
  228. package/src/social/open.ts +17 -0
  229. package/src/social/post-url.ts +158 -0
  230. package/src/social/presence.ts +332 -0
  231. package/src/social/public-read.ts +53 -0
  232. package/src/social/publish/bluesky.ts +168 -0
  233. package/src/social/publish/discord.ts +76 -0
  234. package/src/social/publish/index.ts +24 -0
  235. package/src/social/publish/secret.ts +13 -0
  236. package/src/social/push.ts +31 -0
  237. package/src/social/richtext.ts +37 -0
  238. package/src/social/routes.ts +180 -0
  239. package/src/social/stats.ts +134 -0
  240. package/src/social/text.ts +267 -0
  241. package/src/social/tracker-route.ts +39 -0
  242. package/src/social/tracker.ts +255 -0
  243. package/src/social/unit.ts +53 -0
  244. package/src/social/writes.ts +130 -0
  245. package/src/start-repo.ts +14 -9
  246. package/src/stores/collection.ts +27 -0
  247. package/src/stores/desk.ts +336 -0
  248. package/src/stores/model.ts +187 -0
  249. package/src/stores/routes.ts +126 -0
  250. package/src/stores/unit.ts +57 -0
  251. package/src/suite/calibrate.ts +127 -0
  252. package/src/suite/core-counters.ts +91 -0
  253. package/src/suite/judge-suites.ts +94 -34
  254. package/src/suite/suite-cli.ts +44 -10
  255. package/src/suite/suite-cpu-preload.ts +34 -9
  256. package/src/trailer/adapter.ts +4 -0
  257. package/src/trailer/build.ts +42 -11
  258. package/src/trailer/ffmpeg.ts +11 -0
  259. package/src/trailer/footage.ts +30 -13
  260. package/src/trailer/grammar.ts +18 -2
  261. package/src/trailer/graph.ts +28 -6
  262. package/src/trailer/passage.ts +17 -5
  263. package/src/trailer/plan.ts +74 -3
  264. package/src/trailer/stitch.ts +67 -26
  265. package/src/trailer/url.ts +1 -1
  266. package/src/trailer/versions.ts +24 -0
  267. package/src/ts/gate-typecheck.ts +32 -0
  268. package/src/ts/typecheck-cli.ts +9 -11
  269. package/src/tui/tui-app.tsx +0 -1
  270. package/src/veille/asks.ts +155 -0
  271. package/src/veille/auto.ts +31 -0
  272. package/src/veille/batch.ts +27 -0
  273. package/src/veille/chrome.ts +127 -0
  274. package/src/veille/collection.ts +28 -0
  275. package/src/veille/desk.ts +242 -0
  276. package/src/veille/identity.ts +80 -0
  277. package/src/veille/import.ts +68 -0
  278. package/src/veille/log.ts +183 -0
  279. package/src/veille/platforms.ts +118 -0
  280. package/src/veille/reads.ts +66 -0
  281. package/src/veille/replied.ts +110 -0
  282. package/src/veille/routes.ts +185 -0
  283. package/src/veille/service.ts +81 -0
  284. package/src/veille/watch.ts +116 -0
  285. package/src/veille/worth.ts +46 -0
  286. package/src/wiki/scan-md.ts +18 -0
  287. package/src/collections/posts.ts +0 -142
  288. package/src/contracts/manifests/social.contract.ts +0 -20
  289. package/src/scaffold/files/agent-coding.md +0 -35
  290. package/src/ts/typecheck-cache.ts +0 -11
@@ -85,7 +85,7 @@ export type RawEntry = {
85
85
  /** queue-operation entries only */
86
86
  operation?: unknown
87
87
  content?: unknown
88
- message?: { role?: unknown; content?: unknown }
88
+ message?: { role?: unknown; content?: unknown; id?: unknown; model?: unknown; usage?: { input_tokens?: unknown; output_tokens?: unknown; cache_read_input_tokens?: unknown; cache_creation_input_tokens?: unknown } }
89
89
  toolUseResult?: unknown
90
90
  /** on a tool_result entry: who allowed the call (`config`, `user_temporary`, …) */
91
91
  permissionDecision?: { source?: unknown; reasonType?: unknown }
@@ -179,9 +179,41 @@ export function detailOf(name: string, input: unknown): string {
179
179
  if (name === 'Skill') return clip(str('skill'))
180
180
  if (name === 'WebFetch') return clip(str('url'))
181
181
  if (name === 'Monitor' || name === 'TaskOutput' || name === 'TaskStop') return clip(str('description') || str('task_id'))
182
+ if (name === 'Read' || name === 'Edit' || name === 'Write' || name === 'MultiEdit' || name === 'NotebookEdit') return clip(str('file_path') || str('notebook_path'))
183
+ if (name === 'Grep' || name === 'Glob') return clip([str('pattern'), str('path')].filter((s) => s !== '').join(' '))
182
184
  return ''
183
185
  }
184
186
 
187
+ /** one transcript line as an entry, or null for a line no reader wants (the
188
+ * same skip as readTranscriptLine): for a reader that needs more than events */
189
+ export function parseEntry(line: string): RawEntry | null {
190
+ if (line.startsWith('{"type":"') && !KEPT_TYPE_PREFIXES.some((p) => line.startsWith(p))) return null
191
+ try {
192
+ const parsed: unknown = JSON.parse(line)
193
+ return parsed != null && typeof parsed === 'object' ? (parsed as RawEntry) : null
194
+ } catch {
195
+ return null
196
+ }
197
+ }
198
+
199
+ export type Usage = { messageId: string; input: number; output: number; cacheRead: number; cacheWrite: number; model: string }
200
+
201
+ /** the token usage an assistant entry carries. The harness writes one entry per
202
+ * content block, each with the same message id and usage, so a reader counts
203
+ * each message id once */
204
+ export function usageOf(entry: RawEntry): Usage | null {
205
+ if (entry.type !== 'assistant') return null
206
+ const m = entry.message
207
+ const u = m?.usage
208
+ if (m == null || u == null || typeof m.id !== 'string') return null
209
+ const n = (v: unknown): number => (typeof v === 'number' ? v : 0)
210
+ return { messageId: m.id, input: n(u.input_tokens), output: n(u.output_tokens), cacheRead: n(u.cache_read_input_tokens), cacheWrite: n(u.cache_creation_input_tokens), model: typeof m.model === 'string' ? m.model : '' }
211
+ }
212
+
213
+ /** the text of a user entry, typed or not (a sub-agent's task prompt is a
214
+ * sidechain entry nobody typed), reminders stripped */
215
+ export const userTextOf = (entry: RawEntry): string | null => (entry.type === 'user' && entry.message?.role === 'user' ? userText(entry) : null)
216
+
185
217
  const resultText = (content: unknown): string => {
186
218
  if (typeof content === 'string') return content
187
219
  if (Array.isArray(content)) {
@@ -199,15 +231,8 @@ const KEPT_TYPE_PREFIXES = ['{"type":"user"', '{"type":"assistant"', '{"type":"q
199
231
  /** every event one transcript line holds; [] for anything else, a truncated
200
232
  * tail line of a live session included */
201
233
  export function readTranscriptLine(line: string): TranscriptEvent[] {
202
- if (line.startsWith('{"type":"') && !KEPT_TYPE_PREFIXES.some((p) => line.startsWith(p))) return []
203
- let parsed: unknown
204
- try {
205
- parsed = JSON.parse(line)
206
- } catch {
207
- return []
208
- }
209
- if (parsed == null || typeof parsed !== 'object') return []
210
- return eventsOf(parsed as RawEntry)
234
+ const entry = parseEntry(line)
235
+ return entry == null ? [] : eventsOf(entry)
211
236
  }
212
237
 
213
238
  export function eventsOf(entry: RawEntry): TranscriptEvent[] {
@@ -0,0 +1,301 @@
1
+ // what an npm unit publishes names nothing of the house (wiki build/shipkit/units.md): the file list is npm's own
2
+ // pack list, the words come from the data (house repos, identities, the keyword file), so a new repo or identity is
3
+ // covered the day it exists. A hit reports file:line and the masked word, never the word
4
+ import { createHash } from 'crypto'
5
+ import { existsSync, readdirSync, readFileSync, statSync } from 'fs'
6
+ import { homedir } from 'os'
7
+ import { dirname, join, relative } from 'path'
8
+ import { scanFleet } from '../fleet/scan-fleet.ts'
9
+ import { evaluateLeak, globalAllowFile, globalKeywordFile, leakAllowProblem, loadAllowFile, maskPattern, occurrences, parsePatterns, patternFingerprint, type LoadedAllow } from '../hooks/leak-guard.ts'
10
+ import { readIdentities, type Identities } from '../identities/identities.ts'
11
+ import { KEYWORD_FILE, LAYOUT } from '../core/layout.ts'
12
+ import { parseDirectives, reaches } from '../core/waivers.ts'
13
+ import { fileStamp } from '../core/file-stamp.ts'
14
+ import { gitRoot } from '../core/git-root.ts'
15
+ import { houseIndex, houseRepos } from '../serve/project-gutter.ts'
16
+ import type { RepoConfig } from '../repo-config.ts'
17
+
18
+ /** a word the tarball may not carry, and what it is (never the word itself) */
19
+ export type HouseWord = { word: string; what: string }
20
+
21
+ /** a word the tarball may carry, with why: printed every time it applies */
22
+ export type AllowedWord = { word: string; reason: string }
23
+
24
+ /** reads a file by absolute path, null when absent: the check records each read for its cache, the release reads plainly */
25
+ export type Read = (abs: string) => string | null
26
+
27
+ export const readPlain: Read = (abs) => {
28
+ try {
29
+ return readFileSync(abs, 'utf8')
30
+ } catch {
31
+ return null
32
+ }
33
+ }
34
+
35
+ /** what npm would put in the tarball, unit-relative and sorted: its own pack list, never a guess of it */
36
+ export async function packList(unitDir: string): Promise<{ files: string[] } | { error: string }> {
37
+ const npm = Bun.which('npm')
38
+ if (npm == null) return { error: 'npm is not installed: the pack list is npm\'s own, nothing else can say what ships' }
39
+ const p = Bun.spawn([npm, 'pack', '--dry-run', '--json', '--ignore-scripts'], { cwd: unitDir, stdout: 'pipe', stderr: 'pipe' })
40
+ const [out, err, code] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text(), p.exited])
41
+ if (code !== 0) return { error: `npm pack --dry-run exited ${code}: ${err.trim().split('\n').slice(-2).join(' ')}` }
42
+ try {
43
+ const [packed] = JSON.parse(out) as { files: { path: string }[] }[]
44
+ return { files: (packed?.files ?? []).map((f) => f.path).sort() }
45
+ } catch (e) {
46
+ return { error: `npm pack --dry-run --json printed no pack list (${String(e).slice(0, 120)})` }
47
+ }
48
+ }
49
+
50
+ /** every house repo on this disk by name: the house discovery (archived ones too) and the fleet */
51
+ export function houseRepoWords(root: string, home = homedir()): HouseWord[] {
52
+ const house = houseRepos(root, home)
53
+ const names = new Set([...house.repos, ...house.archived].map((r) => r.name))
54
+ for (const r of scanFleet(dirname(house.home))) names.add(r.name)
55
+ return [...names].sort().map((word) => ({ word, what: 'a house repo' }))
56
+ }
57
+
58
+ /** the identities folder of the house this repo belongs to, null with no house */
59
+ export function houseIdentitiesDir(root: string, home = homedir()): string | null {
60
+ const env = process.env['SHIPKIT_IDENTITIES_DIR']
61
+ if (env) return env
62
+ const index = houseIndex(houseRepos(root, home).home, home)
63
+ const top = index == null ? null : gitRoot(dirname(index))?.top
64
+ return top == null ? null : join(top, LAYOUT.identities)
65
+ }
66
+
67
+ const host = (url: string): string => {
68
+ try {
69
+ return new URL(url).hostname.replace(/^www\./, '')
70
+ } catch {
71
+ return ''
72
+ }
73
+ }
74
+
75
+ /** a handle's own part: `@x`, `u/x`, `@x@instance` and `x.bsky.social` are all `x`; a platform host is never a word */
76
+ export function handleWord(handle: string): string {
77
+ const h = handle.trim().replace(/^u\//, '').replace(/^@/, '')
78
+ const user = h.split('@')[0] ?? ''
79
+ return (user.includes('.') ? (user.replace(/^www\./, '').split('.')[0] ?? '') : user).trim()
80
+ }
81
+
82
+ /** every word that names an identity: id, name, site domain, site repo, email, each account's handle */
83
+ export function identityWords(ids: Identities): HouseWord[] {
84
+ const out: HouseWord[] = []
85
+ const add = (word: string, what: string): void => {
86
+ const w = word.trim()
87
+ if (w.length >= 3 && !out.some((x) => x.word.toLowerCase() === w.toLowerCase())) out.push({ word: w, what })
88
+ }
89
+ for (const i of ids.identities) {
90
+ add(i.id, 'an identity id')
91
+ add(i.name, 'an identity name')
92
+ add(host(i.site), 'an identity site domain')
93
+ add(i.siteRepo, 'an identity site repo')
94
+ for (const r of i.rows) if (r.field === 'email') add(r.value, 'an identity email')
95
+ for (const a of i.accounts) {
96
+ add(handleWord(a.handle), 'an identity handle')
97
+ for (const r of a.rows) if (r.field === 'email') add(r.value, 'an identity email')
98
+ }
99
+ }
100
+ return out
101
+ }
102
+
103
+ type Pkg = { name?: string; author?: string | { name?: string }; funding?: string | { url?: string }; repository?: string | { url?: string } } & Partial<Record<'dependencies' | 'devDependencies' | 'peerDependencies' | 'optionalDependencies', Record<string, string>>>
104
+
105
+ const githubOwner = (v: string | { url?: string } | undefined): string | null => /github\.com\/(?:sponsors\/)?([A-Za-z0-9-]+)/.exec(typeof v === 'string' ? v : (v?.url ?? ''))?.[1] ?? null
106
+
107
+ /** what the package itself makes public: its name, its declared author, the packages it names as dependencies */
108
+ export function allowedWords(pkg: Pkg): AllowedWord[] {
109
+ const out: AllowedWord[] = []
110
+ if (pkg.name) out.push({ word: pkg.name, reason: "the package's own name" })
111
+ const author = typeof pkg.author === 'string' ? pkg.author.replace(/\s*[<(].*$/, '') : pkg.author?.name
112
+ for (const a of [author, githubOwner(pkg.funding), githubOwner(pkg.repository)]) if (a) out.push({ word: a, reason: 'the declared author (package.json author, funding, repository)' })
113
+ for (const block of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'] as const)
114
+ for (const d of Object.keys(pkg[block] ?? {})) out.push({ word: d, reason: `a declared dependency (${block}), a public package` })
115
+ const seen = new Set<string>()
116
+ return out.filter((a) => !seen.has(a.word.toLowerCase()) && (seen.add(a.word.toLowerCase()), true))
117
+ }
118
+
119
+ const BINARY = /\.(png|jpe?g|gif|webp|ico|woff2?|ttf|eot|otf|zip|gz|wasm|mp3|mp4|ogg|wav|flac|node)$/i
120
+
121
+ /** `directive`: the reason of the in-file `sk-disable-… SK035` that waives the site, null when none does */
122
+ export type PublicSite = { file: string; line: number; masked: string; fingerprint: string; what: string; directive: string | null }
123
+
124
+ export const PUBLIC_CLEAN_ID = 'SK035'
125
+
126
+ export type PublicCleanResult = {
127
+ files: string[]
128
+ hits: PublicSite[]
129
+ /** a file npm would pack that must never ship whatever it says (a browser extension) */
130
+ refused: { file: string; why: string }[]
131
+ allowed: { word: string; reason: string }[]
132
+ waived: { file: string; masked: string; reason: string; source: string }[]
133
+ notes: string[]
134
+ }
135
+
136
+ export type PublicCleanInput = {
137
+ /** repo-relative unit dir, '' for the root */
138
+ rel: string
139
+ files: { file: string; content: string }[]
140
+ words: HouseWord[]
141
+ keywordText: string
142
+ allowedWords: AllowedWord[]
143
+ allow: LoadedAllow[]
144
+ }
145
+
146
+ const lineAt = (text: string, at: number): number => {
147
+ let n = 1
148
+ for (let i = text.indexOf('\n'); i !== -1 && i < at; i = text.indexOf('\n', i + 1)) n++
149
+ return n
150
+ }
151
+
152
+ /** the whole decision, with no disk in it */
153
+ export function scanPublic(o: PublicCleanInput): Omit<PublicCleanResult, 'files' | 'notes'> {
154
+ const allowedSet = new Map(o.allowedWords.map((a) => [a.word.toLowerCase(), a.reason]))
155
+ const what = new Map<string, string>()
156
+ const allowed: AllowedWord[] = []
157
+ for (const w of o.words) {
158
+ const k = w.word.toLowerCase()
159
+ if (allowedSet.has(k)) {
160
+ if (!allowed.some((a) => a.word.toLowerCase() === k)) allowed.push({ word: w.word, reason: allowedSet.get(k)! })
161
+ } else if (!what.has(k)) what.set(k, w.what)
162
+ }
163
+ const kw = parsePatterns(o.keywordText)
164
+ // a keyword row the package itself makes public is allowed too, printed masked: the list stays unquotable
165
+ const allowRow = (id: string): boolean => {
166
+ const reason = allowedSet.get(id)
167
+ if (reason != null && !allowed.some((a) => a.word === maskPattern(id))) allowed.push({ word: maskPattern(id), reason: `a keyword row, ${reason}` })
168
+ return reason == null
169
+ }
170
+ const patterns = parsePatterns([...what.keys()].map((w) => `w:${w}`).join('\n'))
171
+ patterns.substrings.push(...kw.substrings.filter(allowRow))
172
+ patterns.words.push(...kw.words.filter((w) => !what.has(w.word) && allowRow(w.word)))
173
+ patterns.regexes.push(...kw.regexes)
174
+
175
+ // an allowed word is one token (a dependency `garden-ui` holds a house word `garden`): blanked to spaces of its
176
+ // length, so lines and offsets stay; a token that goes on as a host (`name.tld`) stays to be scanned
177
+ const tokens = o.allowedWords.map((a) => new RegExp(`(?<![\\p{L}\\p{N}_-]|[\\p{L}\\p{N}]\\.)${a.word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![\\p{L}\\p{N}_-]|\\.[\\p{L}\\p{N}])`, 'giu'))
178
+ const lowerAllowed = o.allowedWords.map((a) => a.word.toLowerCase())
179
+ const blankAllowed = (text: string): string => {
180
+ const lower = text.toLowerCase()
181
+ return tokens.reduce((t, re, i) => (lower.includes(lowerAllowed[i]!) ? t.replace(re, (m) => ' '.repeat(m.length)) : t), text)
182
+ }
183
+ const at = (f: string): string => (o.rel === '' ? f : `${o.rel}/${f}`)
184
+ const refused: PublicCleanResult['refused'] = []
185
+ const targets = []
186
+ for (const f of o.files) {
187
+ if (/(^|\/)manifest\.json$/.test(f.file) && /"manifest_version"\s*:/.test(f.content))
188
+ refused.push({ file: at(f.file), why: 'a browser extension: it is loaded unpacked, never installed from npm' })
189
+ if (!BINARY.test(f.file)) targets.push({ where: 'packed file', file: at(f.file), content: blankAllowed(f.content) })
190
+ }
191
+ const { hits, waived } = evaluateLeak(targets, patterns, o.allow)
192
+ const byFile = new Map(targets.map((t) => [t.file, t.content]))
193
+ const found = new Map<string, Map<string, [number, number][]>>()
194
+ const sites: PublicSite[] = []
195
+ for (const h of hits) {
196
+ const file = h.file!
197
+ const content = byFile.get(file) ?? ''
198
+ if (!found.has(file)) found.set(file, occurrences(content, patterns))
199
+ const lines = new Set((found.get(file)!.get(h.pattern) ?? []).map(([s]) => lineAt(content, s)))
200
+ const label = what.get(h.pattern) ?? 'a keyword row'
201
+ const directives = parseDirectives(file, content).filter((d) => d.reason != null && d.ids.includes(PUBLIC_CLEAN_ID))
202
+ for (const line of [...lines].sort((a, b) => a - b))
203
+ sites.push({ file, line, masked: maskPattern(h.pattern), fingerprint: patternFingerprint(h.pattern), what: label, directive: directives.find((d) => reaches(d, line))?.reason ?? null })
204
+ }
205
+ sites.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line)
206
+ return { hits: sites, refused, allowed, waived: waived.map((w) => ({ file: w.file ?? w.where, masked: maskPattern(w.pattern), reason: w.reason, source: w.source })) }
207
+ }
208
+
209
+ /** the repo's declared waivers and the machine's, as the commit leak guard loads them */
210
+ export function publicAllow(config: RepoConfig, read: Read): { entries: LoadedAllow[]; notes: string[] } {
211
+ const entries: LoadedAllow[] = []
212
+ const notes: string[] = []
213
+ ;(config.hooks?.leakAllow ?? []).forEach((e, i) => {
214
+ const problem = leakAllowProblem(e, `repo.config.ts hooks.leakAllow[${i}]`, true)
215
+ if (problem != null) notes.push(`${problem}, entry IGNORED`)
216
+ else entries.push({ ...e, source: `repo.config.ts hooks.leakAllow[${i}]` })
217
+ })
218
+ const g = globalAllowFile()
219
+ if (g != null && read(g) != null) {
220
+ const loaded = loadAllowFile(g, false)
221
+ entries.push(...loaded.entries)
222
+ notes.push(...loaded.notes)
223
+ }
224
+ return { entries, notes }
225
+ }
226
+
227
+ /** one unit's tarball against every house word. `read` sees every file the answer depends on */
228
+ export async function publicClean(root: string, config: RepoConfig, unit: { dir: string }, read: Read = readPlain): Promise<PublicCleanResult> {
229
+ const rel = relative(root, unit.dir)
230
+ const notes: string[] = []
231
+ const listed = await packList(unit.dir)
232
+ if ('error' in listed) return { files: [], hits: [], refused: [{ file: rel || '.', why: listed.error }], allowed: [], waived: [], notes }
233
+ const files = listed.files.map((f) => ({ file: f, content: read(join(unit.dir, f)) ?? '' }))
234
+ let pkg: Pkg = {}
235
+ try {
236
+ pkg = JSON.parse(read(join(unit.dir, 'package.json')) ?? '{}') as Pkg
237
+ } catch {
238
+ notes.push(`${rel || '.'}/package.json does not parse: nothing is allowed by name`)
239
+ }
240
+ const kwFiles = [join(root, KEYWORD_FILE), globalKeywordFile()].filter((f): f is string => f != null && read(f) != null)
241
+ if (kwFiles.length === 0) notes.push('no keyword file (.shipkit/private/banned-keywords.txt, here or machine global): its rows are not scanned')
242
+ const idsDir = houseIdentitiesDir(root)
243
+ const ids = idsDir != null && existsSync(idsDir) ? readIdentities(idsDir) : null
244
+ if (ids == null) notes.push('no identities folder in this house: no identity word is scanned')
245
+ else for (const i of ids.identities) for (const f of [i.file, ...i.accounts.map((a) => a.file)]) read(f)
246
+ const allow = publicAllow(config, read)
247
+ notes.push(...allow.notes)
248
+ const scanned = scanPublic({
249
+ rel,
250
+ files,
251
+ words: [...houseRepoWords(root), ...(ids == null ? [] : identityWords(ids))],
252
+ keywordText: kwFiles.map((f) => read(f) ?? '').join('\n'),
253
+ allowedWords: allowedWords(pkg),
254
+ allow: allow.entries,
255
+ })
256
+ return { files: listed.files, notes, ...scanned }
257
+ }
258
+
259
+ /** the release preflight's refusals: one line a site, the word masked */
260
+ export async function publicCleanBlockers(root: string, config: RepoConfig, unit: { id: string; dir: string; targets: { npm: boolean } }): Promise<string[]> {
261
+ if (!unit.targets.npm) return []
262
+ const r = await publicClean(root, config, unit)
263
+ const sites = [...r.refused.map((x) => `${x.file}: ${x.why}`), ...r.hits.filter((h) => h.directive == null).map((h) => `${h.file}:${h.line}: names ${h.what} (${h.masked}, ${h.fingerprint})`)]
264
+ if (sites.length === 0) return []
265
+ return [`unit '${unit.id}': its tarball names the house (rule SK035, build/shipkit/units.md), ${sites.length} site${sites.length === 1 ? '' : 's'}:\n${sites.slice(0, 20).join('\n')}${sites.length > 20 ? `\n… ${sites.length - 20} more: sk ci --only SK035` : ''}`]
266
+ }
267
+
268
+ /** every file under `dir` on the disk, ignored ones included (npm packs a gitignored file under `files`), as
269
+ * path, size and mtime; dependency and git folders left out */
270
+ function treeStamp(dir: string, out: string[], base = dir): void {
271
+ let names: string[]
272
+ try {
273
+ names = readdirSync(dir).sort()
274
+ } catch {
275
+ return
276
+ }
277
+ for (const n of names) {
278
+ if (n === 'node_modules' || n === '.git') continue
279
+ const abs = join(dir, n)
280
+ let s
281
+ try {
282
+ s = statSync(abs)
283
+ } catch {
284
+ continue
285
+ }
286
+ if (s.isDirectory()) treeStamp(abs, out, base)
287
+ else out.push(`${relative(base, abs)}:${s.size}:${Math.floor(s.mtimeMs)}`)
288
+ }
289
+ }
290
+
291
+ /** the cache key part no tracked file carries: each unit's tree on disk, the house repos, the identity files, the
292
+ * keyword and allow files. A new house repo moves it, so the answer never outlives the words it was asked with */
293
+ export function publicCleanKey(root: string, units: { dir: string }[]): string {
294
+ const parts: string[] = []
295
+ for (const u of units) treeStamp(u.dir, parts)
296
+ parts.push(houseRepoWords(root).map((w) => w.word).join(','))
297
+ const ids = houseIdentitiesDir(root)
298
+ if (ids != null) treeStamp(ids, parts)
299
+ for (const f of [join(root, KEYWORD_FILE), globalKeywordFile(), globalAllowFile()]) if (f != null) parts.push(fileStamp(f))
300
+ return createHash('sha256').update(parts.join('\n')).digest('hex').slice(0, 16)
301
+ }
@@ -0,0 +1,22 @@
1
+ // the npm versions this machine published, so a fleet run minutes after a
2
+ // release never reads the registry's cached « latest » as the truth: npm's
3
+ // /latest answer lags a publish by minutes, the machine's own record does not
4
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'
5
+ import { homedir } from 'os'
6
+ import { dirname, join } from 'path'
7
+
8
+ const file = (): string => process.env['SHIPKIT_PUBLISHED_FILE'] || join(homedir(), '.cache', 'shipkit', 'published.json')
9
+
10
+ const read = (): Record<string, string> => {
11
+ try { return existsSync(file()) ? (JSON.parse(readFileSync(file(), 'utf8')) as Record<string, string>) : {} }
12
+ catch { return {} }
13
+ }
14
+
15
+ export function recordPublished(name: string, version: string): void {
16
+ const all = { ...read(), [name]: version }
17
+ mkdirSync(dirname(file()), { recursive: true })
18
+ writeFileSync(file(), JSON.stringify(all, null, 2) + '\n')
19
+ }
20
+
21
+ /** the last version of `name` this machine published, or null */
22
+ export const publishedHere = (name: string): string | null => read()[name] ?? null
@@ -32,6 +32,7 @@ import { join, relative } from 'path'
32
32
  import { declaredKind, hasUnreleasedNotes, promoteUnreleased } from './changelog.ts'
33
33
  import { deriveRemote, dirtyPathList, dirtyPaths, git as gitAt, mergeProbe, remoteTags, tagExistsLocally } from './git-facts.ts'
34
34
  import { unitBlockers } from './unit-gate.ts'
35
+ import { publicCleanBlockers } from './public-clean.ts'
35
36
  import { releaseScope } from './release-scope.ts'
36
37
  import { formatUnitError, releaseOrder, renderTag, resolveUnits, unitById, unitPrepublishScripts, unknownUnit, type ReleaseUnit } from './units.ts'
37
38
  import { environmentBlockers, runReleaseGate, releaseUnit } from './run-release.ts'
@@ -412,7 +413,7 @@ export async function runBump(root: string, config: RepoConfig, kind: BumpKind |
412
413
  blockers.push(`unit '${unit.id}': tag ${tag} already exists on '${remote.remote}' — that version number is taken, pick another bump`)
413
414
  continue
414
415
  }
415
- blockers.push(...unitBlockers(root, config, unit))
416
+ blockers.push(...unitBlockers(root, config, unit), ...(await publicCleanBlockers(root, config, unit)))
416
417
  selected.push({ unit, version, changelogRel, kind: unitKind })
417
418
  }
418
419
  // everything the release needs that does not depend on the new version.
@@ -13,6 +13,8 @@ import { extractChangelogSection } from './changelog.ts'
13
13
  import { deriveRemote, dirtyPaths, git, remoteTagState, tagExistsLocally, type RemoteTagState } from './git-facts.ts'
14
14
  import { releaseScope } from './release-scope.ts'
15
15
  import { publishCommand, unitBlockers, type Publisher } from './unit-gate.ts'
16
+ import { recordPublished } from './published-here.ts'
17
+ import { publicCleanBlockers } from './public-clean.ts'
16
18
  import { formatUnitError, resolveUnits, unitById, unknownUnit, type ReleaseUnit } from './units.ts'
17
19
  import type { RepoConfig } from '../repo-config.ts'
18
20
  import { nestedIn, nestedRefusal } from '../core/nesting.ts'
@@ -223,7 +225,7 @@ export async function releaseUnit(root: string, config: RepoConfig, unit: Releas
223
225
  blockers.push(`uncommitted changes in ${scope.describe} (--allow-dirty overrides):\n${dirty.split('\n').slice(0, 10).join('\n')}`)
224
226
  if (scope.specs != null) blockers.push('dirt elsewhere in the worktree is deliberately ignored, it cannot reach this tarball or this tag')
225
227
  }
226
- if (o.skipUnitGate !== true) blockers.push(...unitBlockers(root, config, unit))
228
+ if (o.skipUnitGate !== true) blockers.push(...unitBlockers(root, config, unit), ...(await publicCleanBlockers(root, config, unit)))
227
229
 
228
230
  let alreadyPublished = false
229
231
  if (wantNpm) {
@@ -316,6 +318,7 @@ export async function releaseUnit(root: string, config: RepoConfig, unit: Releas
316
318
  const cmd = publishCommand({ publisher, npmrc, token })
317
319
  const p = Bun.spawnSync(cmd.argv, { cwd: unit.dir, env: { ...env, ...cmd.env }, stdout: 'inherit', stderr: 'inherit' })
318
320
  if (p.exitCode !== 0) { print(`FAIL: ${publisher} publish failed for ${unit.id} (exit ${p.exitCode})`); return 1 }
321
+ recordPublished(name, version)
319
322
  print(`ok: published ${name}@${version}`)
320
323
  }
321
324
 
@@ -21,6 +21,7 @@ import { RETIRED_CHECK_IDS } from './core/retired-checks.ts'
21
21
  import { parseWhen } from './core/when.ts'
22
22
  import { normalizeVendored, vendoredOfText, vendoredProblem } from './core/vendored.ts'
23
23
  import { budgetValueProblem } from './core/budget.ts'
24
+ import { browsersProblem } from './core/slots.ts'
24
25
  import type { Rule } from './check.ts'
25
26
  import { leakAllowProblems } from './hooks/leak-guard.ts'
26
27
  import type { HooksConfig } from './hooks/run-hooks.ts'
@@ -74,6 +75,24 @@ export type ServeConfig = {
74
75
  * media store (review cards, trailer cuts...), read only in the house
75
76
  * config; its key pair read through `credsReadCommand` */
76
77
  mediaSpace?: import('./media-store/space.ts').MediaSpace
78
+ /** the secret whose value is a Cloudflare API token, read through
79
+ * `credsReadCommand`, only in the house config: the site desk asks Pages
80
+ * for a site's last production deployment with it */
81
+ cloudflareToken?: string
82
+ }
83
+
84
+ export type RepoBackup = {
85
+ /** files or folders kept whole, an archive over 50 MB included (each file read once: an unchanged size and time
86
+ * is not read again) */
87
+ paths?: string[]
88
+ /** live sqlite files (a glob: `data/*.db`), each a consistent snapshot; `except` leaves rows out per table (a
89
+ * where clause: `{ sessions: '1' }` keeps no login token) */
90
+ sqlite?: (string | {
91
+ /** the live sqlite file, repo relative (a glob matches several) */
92
+ path: string
93
+ /** rows left out of the snapshot, per table: a where clause naming the rows that go */
94
+ except?: Record<string, string>
95
+ })[]
77
96
  }
78
97
 
79
98
  export type RepoConfig = {
@@ -83,8 +102,15 @@ export type RepoConfig = {
83
102
  name: string
84
103
  /** venue ids this repo ships on — selects which contracts are REQUIRED */
85
104
  venues?: string[]
86
- /** social channels with a .shipkit/social/<channel>/ post folder */
105
+ /** retired with the v2 social contract: read by nothing; delete the line (`sk social migrate` moves the posts) */
87
106
  social?: string[]
107
+ /** the identity that speaks for this repo in public, an id of the house repo's `.shipkit/identities/` (`sk
108
+ * identities`); unset, the one marked `default: true` speaks. A draft may name another (wiki
109
+ * build/shipkit/social.md) */
110
+ speaksAs?: string
111
+ /** machine-only state of this repo the backup keeps beyond its own rule (wiki build/shipkit/media-store.md,
112
+ * Backup, What a repo adds). Paths are repo relative; what git tracks never goes; a secret is refused as always */
113
+ backup?: RepoBackup
88
114
  /** prefix for contract fix: pointers (docs checkout or URL) — written by init, never baked in */
89
115
  docsBase?: string
90
116
  /** a floor slot: a def with a `cmd` or `logic` REPLACES it, and a def
@@ -287,6 +313,21 @@ export type RepoConfig = {
287
313
  * visits after a deploy, and how it logs in. The password is a secret
288
314
  * NAME: the value never sits in config, argv or env. smoke/run-smoke.ts */
289
315
  smoke?: SmokeConfig
316
+ /** what `sk start` does from this repo when it is the house, read only in the house config */
317
+ start?: {
318
+ /** repo names `sk start` never touches: no CLAUDE.md include, no git, no scaffold, no push (a day-job checkout) */
319
+ skip?: string[]
320
+ }
321
+ /** the headless browsers that shoot or record for this repo at once, on any machine (an sk shot ask, a take, a
322
+ * look sheet's tabs, the trailer's films, sk smoke): each holds a slot of the repo's pool for its whole life,
323
+ * and a waiter says whom it waits on. shot/browser-slot.ts */
324
+ browsers?: {
325
+ /** how many at once, a whole number of 1 or more. Default 2 */
326
+ max?: number
327
+ /** the ssh host whose browser films for this repo, like 'wm': on a Mac no browser of the repo starts, every
328
+ * browserSlot there refuses but the box route's own */
329
+ box?: string
330
+ }
290
331
  /** the suite budget for a plain `bun test` floor: per suite time limit, the
291
332
  * slow suites the quick tier leaves out, and the suites that cannot run in
292
333
  * parallel, each with its reason. suite/judge-suites.ts */
@@ -314,11 +355,12 @@ export type RepoConfig = {
314
355
  logDir?: string
315
356
  }
316
357
 
317
- const KNOWN_KEYS = new Set(['name', 'venues', 'social', 'docsBase', 'defaults', 'tasks', 'asks', 'creds', 'credsCommand', 'credsReadCommand', 'notifyCommand', 'contracts', 'gitignore', 'ignoredInputs', 'untrackGenerated', 'nested', 'off', 'when', 'budgets', 'ruleExempt', 'visibility', 'archived', 'reviewer', 'oneWayIn', 'rules', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'checkDefaults', 'tui', 'serve', 'identity', 'logDir', 'smoke', 'tests'])
358
+ const KNOWN_KEYS = new Set(['name', 'venues', 'social', 'speaksAs', 'backup', 'docsBase', 'defaults', 'tasks', 'asks', 'creds', 'credsCommand', 'credsReadCommand', 'notifyCommand', 'contracts', 'gitignore', 'ignoredInputs', 'untrackGenerated', 'nested', 'off', 'when', 'budgets', 'ruleExempt', 'visibility', 'archived', 'reviewer', 'oneWayIn', 'rules', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'checkDefaults', 'tui', 'serve', 'identity', 'logDir', 'smoke', 'tests', 'browsers', 'start'])
318
359
 
319
360
  export function defineRepo(c: RepoConfig): RepoConfig {
320
361
  if (typeof c.name !== 'string' || c.name === '') throw new Error('defineRepo: name is required')
321
362
  for (const v of c.venues ?? []) if (!/^[a-z0-9-]+$/.test(v)) throw new Error(`defineRepo: venue '${v}' must be kebab-case`)
363
+ if (c.speaksAs != null && !/^[a-z0-9][a-z0-9-]*$/.test(c.speaksAs)) throw new Error(`defineRepo: speaksAs '${String(c.speaksAs)}' must be an identity id, kebab-case (sk identities)`)
322
364
  if (c.visibility != null && c.visibility !== 'private' && c.visibility !== 'public')
323
365
  throw new Error(`defineRepo: visibility '${String(c.visibility)}' — 'private' or 'public' only`)
324
366
  // a half-declared reviewer would lint a path like `.claude/agents/.md`
@@ -431,6 +473,15 @@ export function defineRepo(c: RepoConfig): RepoConfig {
431
473
  }
432
474
  // a smoke typo would land as a run that visits nothing and exits 0
433
475
  if (c.smoke != null) validateSmokeConfig(c.smoke)
476
+ const browsers = browsersProblem(c.browsers)
477
+ if (browsers != null) throw new Error(`defineRepo: ${browsers}`)
478
+ // a malformed skip list would let sk start wire the checkout it exists to leave alone
479
+ if (c.start !== undefined) {
480
+ const skip = (c.start as { skip?: unknown }).skip
481
+ const extra = Object.keys(c.start).filter((k) => k !== 'skip')
482
+ if (extra.length > 0 || (skip !== undefined && !(Array.isArray(skip) && skip.every((n) => typeof n === 'string' && /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(n)))))
483
+ throw new Error(`defineRepo: start is { skip?: <repo names> }, got ${JSON.stringify(c.start)}`)
484
+ }
434
485
  // a leak-guard waiver is the one config row that can make a gate quieter,
435
486
  // so a malformed one dies here rather than being dropped at commit time
436
487
  if (c.hooks?.leakAllow != null) {
@@ -1,11 +1,25 @@
1
- // the hub's http helpers the review and trailer routes share: an error answer, the cache headers, a file with byte ranges
1
+ // the hub's http helpers the review, trailer and social routes share: an error answer, the cache headers, a json
2
+ // answer under its ETag, a file with byte ranges
2
3
  import { extname } from 'node:path'
3
4
 
4
- export const TYPES: Record<string, string> = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.webm': 'video/webm', '.mp4': 'video/mp4' }
5
+ export const TYPES: Record<string, string> = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.webm': 'video/webm', '.mp4': 'video/mp4', '.ico': 'image/x-icon' }
5
6
  export const NO_STORE = { 'Cache-Control': 'no-store' }
6
7
  /** an item's files never change once written, nor a kept render under its version: a phone keeps what it fetched */
7
8
  export const KEEP = { 'Cache-Control': 'private, max-age=86400' }
8
9
 
10
+ /** a json answer under its ETag: 304 when the page holds it, gzipped when the page takes it and it is worth it. A
11
+ * caller that keeps the answer passes `held`, the zip made once for every page that asks the same tag */
12
+ export function tagged(req: Request, tag: string, body: () => unknown, held?: { tag: string; text: string; zip?: Uint8Array<ArrayBuffer> }): Response {
13
+ const headers = { 'Content-Type': 'application/json', ETag: tag, 'Cache-Control': 'no-cache', Vary: 'Accept-Encoding' }
14
+ if (req.headers.get('If-None-Match') === tag) return new Response(null, { status: 304, headers: { ETag: tag } })
15
+ const kept = held?.tag === tag ? held : null
16
+ const text = kept?.text ?? JSON.stringify(body())
17
+ if (text.length < 4096 || !/\bgzip\b/.test(req.headers.get('Accept-Encoding') ?? '')) return new Response(text, { headers })
18
+ const zip = kept?.zip ?? Bun.gzipSync(new TextEncoder().encode(text))
19
+ if (kept) kept.zip = zip
20
+ return new Response(zip, { headers: { ...headers, 'Content-Encoding': 'gzip' } })
21
+ }
22
+
9
23
  export const bad = (e: unknown, status = 400): Response => Response.json({ error: e instanceof Error ? e.message : String(e) }, { status, headers: NO_STORE })
10
24
 
11
25
  /** a file with byte ranges: a player seeks through them */
@@ -2,11 +2,11 @@
2
2
  // is an ITEM, a head (`item.json`: a typed subject, who raised it, the views) and an append only thread of messages
3
3
  // (verdicts, replies, ratings, state changes, read marks). The state is derived from the thread, never stored, so the
4
4
  // hub and every CLI write at once with no lost update. Pure and browser safe: the store, the routes and the hub page
5
- // share it. The on disk shape is pkm-multi's (scripts/review/store.ts) verbatim, so either store opens in the other.
5
+ // share it. The on disk shape is the one a project's own review store writes, verbatim, so either store opens in the other.
6
6
  import type { MediaFact } from '../media-store/fact.ts'
7
7
 
8
8
  /** WHAT is judged: `shot` (a plain image or clip), `screen`, `frame` (a frame of a trailer cut), or a kind a repo names
9
- * for itself (pkm-multi's place, creature, song...), read as is */
9
+ * for itself (a game's place, creature, song...), read as is */
10
10
  export interface Subject {
11
11
  kind: string
12
12
  [k: string]: unknown
@@ -28,6 +28,15 @@ export interface FrameSubject extends Subject {
28
28
 
29
29
  export const isFrame = (s: Subject): s is FrameSubject => s.kind === 'frame'
30
30
 
31
+ /** a thing of a store page (wiki build/shipkit/stores.md): a picture by its repo path, or a field as `field:<heading>` */
32
+ export interface StoreSubject extends Subject {
33
+ kind: 'store'
34
+ store: string
35
+ asset: string
36
+ }
37
+
38
+ export const isStoreSubject = (s: Subject): s is StoreSubject => s.kind === 'store' && typeof s.store === 'string' && typeof s.asset === 'string'
39
+
31
40
  /** what a repo's `review({...})` unit says of one subject kind that the pure model reads (review/unit.ts holds the rest):
32
41
  * its words, and on the server its key, its near rule and its problems. The hub gets the words alone */
33
42
  export interface SpecKind {
@@ -57,7 +66,7 @@ export interface Spec {
57
66
  }
58
67
 
59
68
  /** the kinds every repo has, whatever its unit declares */
60
- export const BUILTIN_KINDS: Record<string, SpecKind> = { shot: { label: 'images' }, screen: { label: 'screens' }, frame: { label: 'trailer frames' } }
69
+ export const BUILTIN_KINDS: Record<string, SpecKind> = { shot: { label: 'images' }, screen: { label: 'screens' }, frame: { label: 'trailer frames' }, store: { label: 'store pages', icon: '🏪' } }
61
70
 
62
71
  export const NO_SPEC: Spec = { kinds: {}, topics: {}, dispatcher: false }
63
72
 
@@ -80,6 +89,7 @@ export type Origin =
80
89
  export function subjectKey(s: Subject, spec: Spec = NO_SPEC): string | null {
81
90
  if (isFrame(s)) return `frame:${s.trailer}/${s.cut}/${s.shot}`
82
91
  const kind = spec.kinds[s.kind]
92
+ if (!kind && isStoreSubject(s)) return `store:${s.store}/${s.asset}`
83
93
  if (kind) {
84
94
  const k = kind.key?.(s)
85
95
  return k ? `${s.kind}:${k}` : null
@@ -106,7 +116,7 @@ export interface ReviewAudio {
106
116
  waveBefore?: string
107
117
  }
108
118
 
109
- /** a ring a repo drew over its own shot (pkm-multi's world tiles): its center normalized 0..1, its radius as a share of
119
+ /** a ring a repo drew over its own shot (a game's world tiles): its center normalized 0..1, its radius as a share of
110
120
  * the image width; `side` only on a pair */
111
121
  export interface ReviewMark {
112
122
  tile: [number, number]
@@ -712,6 +722,7 @@ function subjectProblems(s: unknown, spec: Spec): string[] {
712
722
  const declared = Object.keys(spec.kinds)
713
723
  if (!kind && !BUILTIN_KINDS[s.kind] && declared.length > 0) return [`subject: kind « ${s.kind} » is none of ${[...declared, ...Object.keys(BUILTIN_KINDS)].join(', ')}`]
714
724
  if (kind?.problems) return kind.problems(s as Subject).map((p) => `subject: ${p}`)
725
+ if (s.kind === 'store' && !kind) return isStoreSubject(s as Subject) && s.store !== '' && s.asset !== '' ? [] : ['subject: a store thing has its store and asset']
715
726
  if (s.kind !== 'frame') return []
716
727
  const str = (k: string): boolean => typeof s[k] === 'string' && s[k] !== ''
717
728
  const num = (k: string): boolean => typeof s[k] === 'number' && Number.isFinite(s[k])