rvlib-shipkit 2.13.0 → 2.15.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 (270) hide show
  1. package/CHANGELOG.md +38 -13
  2. package/package.json +1 -1
  3. package/src/assets/run-assets.ts +2 -2
  4. package/src/assets/server/studio-server.ts +27 -23
  5. package/src/check.ts +3 -3
  6. package/src/checks/SK001-package-json-shape.check.ts +4 -4
  7. package/src/checks/SK002-contracts-fulfillness.check.ts +2 -2
  8. package/src/checks/SK003-claude-md-shape.check.ts +19 -12
  9. package/src/checks/SK004-gitignore-policy.check.ts +18 -4
  10. package/src/checks/SK005-rvlib-versions.check.ts +1 -1
  11. package/src/checks/SK006-npm-publish-safety.check.ts +3 -3
  12. package/src/checks/SK007-github-visibility.check.ts +2 -2
  13. package/src/checks/SK008-reviewer-agent.check.ts +1 -1
  14. package/src/checks/SK010-undeclared-unit.check.ts +2 -2
  15. package/src/checks/SK011-sibling-unit-ranges.check.ts +2 -2
  16. package/src/checks/SK012-config-barrel-import.check.ts +1 -1
  17. package/src/checks/SK013-one-way-in-policy.check.ts +2 -2
  18. package/src/checks/SK015-nested-repo.check.ts +2 -2
  19. package/src/checks/SK016-legacy-check-shapes.check.ts +2 -2
  20. package/src/checks/SK017-vscode-hub-task.check.ts +2 -2
  21. package/src/checks/SK018-test-files-run.check.ts +2 -2
  22. package/src/checks/SK019-tests-run-in-units.check.ts +2 -2
  23. package/src/checks/SK020-self-spawning-check.check.ts +2 -2
  24. package/src/checks/SK022-machine-runs-the-pin.check.ts +2 -2
  25. package/src/checks/SK024-identity-colors.check.ts +1 -1
  26. package/src/checks/SK025-release-drift.check.ts +2 -2
  27. package/src/checks/SK026-asks-autoclose.check.ts +2 -2
  28. package/src/checks/SK027-agent-wiki-links.check.ts +8 -2
  29. package/src/checks/SK028-readme.check.ts +2 -2
  30. package/src/checks/SK029-explicit-check-files.check.ts +3 -3
  31. package/src/checks/SK030-cache-audit.check.ts +7 -5
  32. package/src/checks/SK031-trace-audit.check.ts +7 -7
  33. package/src/checks/SK032-ignored-inputs.check.ts +3 -3
  34. package/src/checks/SK033-global-contribution.check.ts +11 -4
  35. package/src/checks/SK034-commit-gates-armed.check.ts +2 -2
  36. package/src/checks/SK035-public-clean.check.ts +4 -4
  37. package/src/checks/SK036-draft-media-size.check.ts +2 -2
  38. package/src/checks/SK037-keyword-additions.check.ts +43 -0
  39. package/src/cli/cmd_Backup.ts +2 -2
  40. package/src/cli/cmd_Commands.ts +4 -4
  41. package/src/cli/cmd_ConfigKeys.ts +2 -2
  42. package/src/cli/cmd_Drill.ts +30 -1
  43. package/src/cli/cmd_Home.ts +1 -1
  44. package/src/cli/cmd_Init.ts +1 -1
  45. package/src/cli/cmd_Media.ts +5 -5
  46. package/src/cli/cmd_Mv.ts +14 -7
  47. package/src/cli/cmd_Review.ts +2 -2
  48. package/src/cli/cmd_Smoke.ts +1 -1
  49. package/src/cli/cmd_Social.ts +3 -3
  50. package/src/cli/cmd_Sound.ts +1 -1
  51. package/src/cli/cmd_TraceAudit.ts +6 -6
  52. package/src/cli/cmd_Trailer.ts +2 -2
  53. package/src/cli/cmd_Veille.ts +2 -2
  54. package/src/cli/cmd_When.ts +2 -2
  55. package/src/cli/family-pages.ts +19 -19
  56. package/src/cli/registry.ts +2 -1
  57. package/src/collections/collection-types.ts +2 -2
  58. package/src/collections/review.ts +1 -1
  59. package/src/comfy/comfy-panel.ts +2 -2
  60. package/src/contracts/manifests/discord.contract.ts +1 -1
  61. package/src/contracts/manifests/identity.contract.ts +1 -1
  62. package/src/contracts/manifests/itch.contract.ts +1 -1
  63. package/src/contracts/manifests/steam.contract.ts +1 -1
  64. package/src/core/agent-dir-at.ts +12 -0
  65. package/src/core/agent-dir.ts +28 -0
  66. package/src/core/budget.ts +1 -1
  67. package/src/core/canonical-scripts.ts +2 -2
  68. package/src/core/discover-checks.ts +1 -1
  69. package/src/core/global-contribution.ts +4 -1
  70. package/src/core/ignored-block.ts +1 -1
  71. package/src/core/ignored-inputs.ts +3 -2
  72. package/src/core/layout.ts +3 -3
  73. package/src/core/loop-watch.ts +1 -1
  74. package/src/core/motherhome.ts +2 -2
  75. package/src/core/one-way-in-policy.ts +8 -8
  76. package/src/core/run-ci.ts +3 -3
  77. package/src/core/runs-matrix.ts +1 -1
  78. package/src/core/slots.ts +14 -5
  79. package/src/core/trace-audit.ts +50 -9
  80. package/src/core/tree-rev.ts +1 -1
  81. package/src/drill/clean.ts +54 -0
  82. package/src/drill/run.ts +1 -1
  83. package/src/home/daemon-jobs.ts +1 -1
  84. package/src/home/global-context.ts +11 -8
  85. package/src/home/gui-app/ShipkitGui.swift +91 -2
  86. package/src/home/inbox-shape.ts +1 -1
  87. package/src/home/inbox.ts +1 -1
  88. package/src/home/pm-config.ts +4 -1
  89. package/src/home/pm-inputs.ts +2 -0
  90. package/src/home/resources.ts +7 -2
  91. package/src/home/run-pm.ts +1 -1
  92. package/src/home/serve-web.ts +2 -2
  93. package/src/hooks/commit-message.ts +1 -1
  94. package/src/hooks/hook-gates.ts +1 -1
  95. package/src/hooks/leak-guard.ts +61 -8
  96. package/src/hooks/run-hooks.ts +18 -18
  97. package/src/identities/identities.ts +1 -1
  98. package/src/identities/machine-route.ts +1 -1
  99. package/src/identities/machine.ts +1 -1
  100. package/src/init-repo.ts +2 -2
  101. package/src/ledger/gate-checks.ts +1 -1
  102. package/src/ledger/record-kept.ts +1 -1
  103. package/src/media-kinds.ts +1 -1
  104. package/src/media-store/backup/daemon.ts +1 -1
  105. package/src/media-store/backup/keys.ts +1 -1
  106. package/src/media-store/backup/manifest.ts +1 -1
  107. package/src/media-store/backup/restore.ts +1 -1
  108. package/src/media-store/backup/run.ts +1 -1
  109. package/src/media-store/backup/secret.ts +1 -1
  110. package/src/media-store/backup/snapshot.ts +1 -1
  111. package/src/media-store/backup/sources.ts +1 -1
  112. package/src/media-store/content.ts +1 -1
  113. package/src/media-store/daemon.ts +1 -1
  114. package/src/media-store/db.ts +1 -1
  115. package/src/media-store/fact.ts +1 -1
  116. package/src/media-store/hand.ts +1 -1
  117. package/src/media-store/kind.ts +1 -1
  118. package/src/media-store/purge.ts +1 -1
  119. package/src/media-store/put.ts +1 -1
  120. package/src/media-store/remote.ts +1 -1
  121. package/src/media-store/space.ts +1 -1
  122. package/src/mv/mv-md.ts +63 -22
  123. package/src/pages/forward.ts +1 -1
  124. package/src/pages/frame-client.ts +1 -1
  125. package/src/pages/routes.ts +1 -1
  126. package/src/pages/unit.ts +1 -1
  127. package/src/plan/planner.ts +1 -1
  128. package/src/plan/repo-source.ts +1 -1
  129. package/src/release/public-clean.ts +25 -7
  130. package/src/release/run-bump.ts +1 -1
  131. package/src/release/run-release.ts +3 -3
  132. package/src/repo-config.ts +23 -16
  133. package/src/review/anim.ts +1 -1
  134. package/src/review/auto.ts +1 -1
  135. package/src/review/cells.ts +15 -1
  136. package/src/review/format.ts +2 -2
  137. package/src/review/marks.ts +1 -1
  138. package/src/review/media-kind.ts +1 -1
  139. package/src/review/media-read.ts +1 -1
  140. package/src/review/model.ts +14 -4
  141. package/src/review/notes.ts +52 -4
  142. package/src/review/previews.ts +1 -1
  143. package/src/review/project.ts +1 -1
  144. package/src/review/role.ts +1 -1
  145. package/src/review/routes.ts +14 -2
  146. package/src/review/store.ts +2 -2
  147. package/src/review/threads.ts +1 -1
  148. package/src/review/trailer-desk.ts +3 -3
  149. package/src/review/trailer-media.ts +1 -1
  150. package/src/review/trailer-model.ts +1 -1
  151. package/src/review/trailer-routes.ts +1 -1
  152. package/src/review/trailer-shots.ts +1 -1
  153. package/src/review/unit.ts +1 -1
  154. package/src/scaffold/files/tsconfig.json +1 -1
  155. package/src/scaffold/project-scaffold.ts +1 -1
  156. package/src/serve/embed.ts +1 -1
  157. package/src/serve/hub-app/check-words.ts +1 -1
  158. package/src/serve/hub-app/frames-st.ts +1 -1
  159. package/src/serve/hub-app/hash-route.ts +1 -1
  160. package/src/serve/hub-app/home-st.ts +1 -1
  161. package/src/serve/hub-app/home-strip.css +1 -1
  162. package/src/serve/hub-app/hub-app.tsx +2 -2
  163. package/src/serve/hub-app/identities-st.ts +1 -1
  164. package/src/serve/hub-app/identities-view.tsx +5 -4
  165. package/src/serve/hub-app/identity-address.ts +1 -1
  166. package/src/serve/hub-app/inbox-st.ts +1 -1
  167. package/src/serve/hub-app/inbox-view.tsx +1 -1
  168. package/src/serve/hub-app/kept-cols.tsx +30 -0
  169. package/src/serve/hub-app/keys.ts +1 -1
  170. package/src/serve/hub-app/media-svc.ts +1 -1
  171. package/src/serve/hub-app/pages-frames.tsx +1 -1
  172. package/src/serve/hub-app/pages-svc.ts +1 -1
  173. package/src/serve/hub-app/projects-svc.ts +1 -1
  174. package/src/serve/hub-app/repo-st.ts +1 -1
  175. package/src/serve/hub-app/review/review-board.tsx +1 -1
  176. package/src/serve/hub-app/review/review-cells.tsx +3 -2
  177. package/src/serve/hub-app/review/review-page.tsx +5 -4
  178. package/src/serve/hub-app/review/review-st.ts +15 -7
  179. package/src/serve/hub-app/review/review-thread.tsx +52 -5
  180. package/src/serve/hub-app/review/review-views.tsx +50 -33
  181. package/src/serve/hub-app/review/thread-st.ts +79 -27
  182. package/src/serve/hub-app/review/trailer-page.tsx +5 -4
  183. package/src/serve/hub-app/review/trailer-st.ts +1 -1
  184. package/src/serve/hub-app/review.css +9 -1
  185. package/src/serve/hub-app/site/site-part.tsx +1 -1
  186. package/src/serve/hub-app/site/site-st.ts +1 -1
  187. package/src/serve/hub-app/social/calendar.tsx +1 -1
  188. package/src/serve/hub-app/social/comms-page.tsx +29 -5
  189. package/src/serve/hub-app/social/kit.tsx +1 -1
  190. package/src/serve/hub-app/social/post-card.tsx +1 -1
  191. package/src/serve/hub-app/social/social-model.ts +1 -1
  192. package/src/serve/hub-app/social/social-page.tsx +12 -5
  193. package/src/serve/hub-app/social/social-st.ts +31 -3
  194. package/src/serve/hub-app/social.css +1 -1
  195. package/src/serve/hub-app/stores/stores-page.tsx +5 -4
  196. package/src/serve/hub-app/stores/stores-st.ts +1 -1
  197. package/src/serve/hub-app/stores.css +1 -1
  198. package/src/serve/hub-app/tree-row.tsx +1 -1
  199. package/src/serve/hub-app/veille/veille-page.tsx +5 -4
  200. package/src/serve/hub-app/veille/veille-st.ts +1 -1
  201. package/src/serve/hub-app/veille.css +1 -1
  202. package/src/serve/hub-runtime.ts +6 -2
  203. package/src/serve/project-gutter-route.ts +1 -1
  204. package/src/shot/box.ts +5 -7
  205. package/src/shot/browser-slot.ts +18 -6
  206. package/src/shot/client.ts +1 -2
  207. package/src/shot/clip-encoder.ts +16 -13
  208. package/src/shot/film-box.ts +132 -28
  209. package/src/shot/shooter.ts +21 -2
  210. package/src/shot/stepped-clip.ts +1 -1
  211. package/src/site/desk.ts +2 -2
  212. package/src/site/routes.ts +1 -1
  213. package/src/site/unit.ts +1 -1
  214. package/src/social/card-drafts.ts +24 -0
  215. package/src/social/compose.ts +2 -2
  216. package/src/social/desk-index.ts +1 -1
  217. package/src/social/desk-wire.ts +1 -1
  218. package/src/social/drafts.ts +3 -3
  219. package/src/social/load.ts +14 -1
  220. package/src/social/media-facts.ts +1 -1
  221. package/src/social/media-kind.ts +1 -1
  222. package/src/social/media-limit.ts +1 -1
  223. package/src/social/media-of.ts +1 -1
  224. package/src/social/migrate.ts +1 -1
  225. package/src/social/post-url.ts +1 -1
  226. package/src/social/presence.ts +2 -2
  227. package/src/social/public-read.ts +1 -1
  228. package/src/social/publish/bluesky.ts +1 -1
  229. package/src/social/publish/discord.ts +1 -1
  230. package/src/social/push.ts +10 -4
  231. package/src/social/richtext.ts +1 -1
  232. package/src/social/routes.ts +10 -4
  233. package/src/social/stats.ts +1 -1
  234. package/src/social/text.ts +1 -1
  235. package/src/social/tracker-route.ts +1 -1
  236. package/src/social/tracker.ts +1 -1
  237. package/src/social/unit.ts +1 -1
  238. package/src/social/writes.ts +1 -1
  239. package/src/stores/collection.ts +1 -1
  240. package/src/stores/desk.ts +1 -1
  241. package/src/stores/model.ts +1 -1
  242. package/src/stores/routes.ts +1 -1
  243. package/src/stores/unit.ts +1 -1
  244. package/src/suite/judge-suites.ts +1 -1
  245. package/src/trace/tracer.ts +12 -5
  246. package/src/trailer/adapter.ts +1 -1
  247. package/src/trailer/build.ts +6 -4
  248. package/src/trailer/holes.ts +1 -1
  249. package/src/trailer/passage.ts +1 -1
  250. package/src/trailer/prune.ts +1 -1
  251. package/src/trailer/states.ts +1 -1
  252. package/src/trailer/versions.ts +1 -1
  253. package/src/trailer/words.ts +1 -1
  254. package/src/tui/run-tui.ts +1 -1
  255. package/src/tui/tui-store.ts +1 -1
  256. package/src/veille/asks.ts +1 -1
  257. package/src/veille/auto.ts +1 -1
  258. package/src/veille/batch.ts +1 -1
  259. package/src/veille/chrome.ts +1 -1
  260. package/src/veille/collection.ts +1 -1
  261. package/src/veille/desk.ts +1 -1
  262. package/src/veille/identity.ts +1 -1
  263. package/src/veille/import.ts +1 -1
  264. package/src/veille/log.ts +1 -1
  265. package/src/veille/platforms.ts +1 -1
  266. package/src/veille/reads.ts +1 -1
  267. package/src/veille/replied.ts +1 -1
  268. package/src/veille/routes.ts +2 -2
  269. package/src/veille/watch.ts +1 -1
  270. package/src/veille/worth.ts +2 -2
@@ -5,7 +5,8 @@
5
5
  // (no display). The shell ships without the DirectX shader compiler Dawn's D3D12 loads, so it gets the full
6
6
  // chromium's copy; the full chromium also reads the discrete GPU's LUID off chrome://gpu, which the shell lacks.
7
7
  // up <playwright version> the browser answering (started when down: installed when missing, its GPU's LUID found)
8
- // watch <pid> ends the browser once nothing used it for IDLE_MS (started by up, outside the ssh session)
8
+ // watch <pid> closes a page whose film died, ends the browser once nothing used it for IDLE_MS (started
9
+ // by up, outside the ssh session)
9
10
  // the constraint a reader breaks first: Windows OpenSSH ends every process of its session when it closes, so the
10
11
  // browser and the watcher are created through WMI, outside it
11
12
  import { createHash } from 'node:crypto'
@@ -28,21 +29,45 @@ const say = (s: string) => console.error(`box: ${s}`)
28
29
  /** this script's version: a browser another version started is replaced */
29
30
  const VERSION = createHash('sha1').update(readFileSync(import.meta.path)).digest('hex').slice(0, 12)
30
31
 
32
+ /** playwright's own switches for a launched chromium (chromiumSwitches, headless), so a page films here as it would
33
+ * under a launch: --disable-ipc-flooding-protection above all, without which chromium drops a page's history updates
34
+ * past 200 in 10 s and a take's clock (its hash's stop=) froze at frame 201 */
31
35
  const BROWSER_ARGS = [
32
36
  '--use-angle=d3d11',
33
37
  '--enable-gpu',
34
38
  '--ignore-gpu-blocklist',
35
39
  '--enable-unsafe-webgpu',
36
- '--autoplay-policy=no-user-gesture-required',
37
- '--mute-audio',
38
- '--no-first-run',
39
- '--no-default-browser-check',
40
- '--lang=en-US',
41
- // a headless page is never backgrounded: its frames and timers run at full rate
40
+ '--disable-ipc-flooding-protection',
41
+ '--force-color-profile=srgb',
42
+ '--disable-field-trial-config',
43
+ '--disable-background-networking',
42
44
  '--disable-background-timer-throttling',
43
45
  '--disable-backgrounding-occluded-windows',
44
46
  '--disable-renderer-backgrounding',
45
- '--disable-features=CalculateNativeWinOcclusion',
47
+ '--disable-back-forward-cache',
48
+ '--disable-breakpad',
49
+ '--disable-client-side-phishing-detection',
50
+ '--disable-component-extensions-with-background-pages',
51
+ '--disable-component-update',
52
+ '--disable-default-apps',
53
+ '--disable-extensions',
54
+ '--disable-hang-monitor',
55
+ '--disable-popup-blocking',
56
+ '--disable-prompt-on-repost',
57
+ '--disable-sync',
58
+ '--disable-features=PaintHolding,Translate,OptimizationHints,MediaRouter,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,LensOverlay,ThirdPartyStoragePartitioning,AutoDeElevate,CalculateNativeWinOcclusion',
59
+ '--enable-features=CDPScreenshotNewSurface',
60
+ '--allow-pre-commit-input',
61
+ '--metrics-recording-only',
62
+ '--password-store=basic',
63
+ '--no-service-autorun',
64
+ '--no-first-run',
65
+ '--no-default-browser-check',
66
+ '--autoplay-policy=no-user-gesture-required',
67
+ '--hide-scrollbars',
68
+ '--mute-audio',
69
+ '--blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4',
70
+ '--lang=en-US',
46
71
  ]
47
72
 
48
73
  async function answers(port: number): Promise<boolean> {
@@ -137,52 +162,131 @@ async function discreteLuid(exe: string): Promise<string | null> {
137
162
  }
138
163
  }
139
164
 
165
+ /** the browser up now, as browser.pid holds it: its pid, the script version that started it, its devtools port */
166
+ function current(): { pid: number; version: string; port: number } | null {
167
+ if (!existsSync(PID)) return null
168
+ const [pid, version, port] = readFileSync(PID, 'utf8').trim().split(' ')
169
+ return Number(pid) > 0 ? { pid: Number(pid), version: version ?? '', port: Number(port) || CDP_PORT } : null
170
+ }
171
+
140
172
  async function up(version: string): Promise<void> {
141
173
  const t = performance.now()
142
174
  mkdirSync(DIR, { recursive: true })
143
175
  writeFileSync(USED, String(Date.now()))
144
- const [was, by] = existsSync(PID) ? readFileSync(PID, 'utf8').trim().split(' ') : []
145
- if (by === VERSION && (await answers(CDP_PORT))) {
146
- console.log(`up warm ${Math.round(performance.now() - t)}`)
176
+ const warm = async () => {
177
+ const c = current()
178
+ return c != null && c.version === VERSION && (await answers(c.port)) ? c : null
179
+ }
180
+ const w = await warm()
181
+ if (w) {
182
+ console.log(`up warm ${Math.round(performance.now() - t)} port ${w.port}`)
147
183
  return
148
184
  }
149
- if (Number(was) > 0) kill(Number(was))
185
+ // several films asking at once start one browser: the first starts it, the others wait and find it warm
186
+ const lock = join(DIR, 'up.lock')
187
+ for (;;) {
188
+ try {
189
+ mkdirSync(lock)
190
+ break
191
+ } catch {
192
+ if (Date.now() - (statSync(lock, { throwIfNoEntry: false })?.mtimeMs ?? Date.now()) > 60_000) rmSync(lock, { recursive: true, force: true })
193
+ await Bun.sleep(200)
194
+ }
195
+ }
196
+ try {
197
+ const again = await warm()
198
+ if (again) console.log(`up warm ${Math.round(performance.now() - t)} port ${again.port}`)
199
+ else await start(version, t)
200
+ } finally {
201
+ rmSync(lock, { recursive: true, force: true })
202
+ }
203
+ }
204
+
205
+ /** a new browser on the port the old one does not hold, with its own profile (chromium locks one per process): the
206
+ * old one, if a film still runs in it, drains (its watcher ends it once no film drives a page), never killed mid take */
207
+ async function start(version: string, t: number): Promise<void> {
208
+ const old = current()
209
+ const oldUp = old != null && alive(old.pid) && (await answers(old.port))
210
+ const port = oldUp && old.port === CDP_PORT ? CDP_PORT + 3 : CDP_PORT
211
+ if (old != null && !oldUp) kill(old.pid)
212
+ if (oldUp) {
213
+ if ((await filming(old.port).catch(() => 0)) === 0) kill(old.pid)
214
+ else detached([process.execPath, import.meta.path, 'watch', String(old.pid), String(old.port), 'drain'].map(quote).join(' '))
215
+ }
150
216
  const exe = chromium(version)
151
217
  const luid = await discreteLuid(exe.full)
152
218
  if (luid == null) say('no discrete GPU named in chrome://gpu: the browser draws on the default adapter')
153
- const args = [`--remote-debugging-port=${CDP_PORT}`, `--user-data-dir=${join(DIR, 'profile')}`, ...BROWSER_ARGS, ...(luid ? [`--use-adapter-luid=${luid}`] : []), 'about:blank']
219
+ const args = [`--remote-debugging-port=${port}`, `--user-data-dir=${join(DIR, `profile-${port}`)}`, ...BROWSER_ARGS, ...(luid ? [`--use-adapter-luid=${luid}`] : []), 'about:blank']
154
220
  const pid = detached([exe.shell, ...args].map(quote).join(' '))
155
- writeFileSync(PID, `${pid} ${VERSION}`)
156
- for (let i = 0; i < 150 && !(await answers(CDP_PORT)); i++) await Bun.sleep(100)
157
- if (!(await answers(CDP_PORT))) throw new Error(`the browser (pid ${pid}) did not answer on 127.0.0.1:${CDP_PORT} in 15 s`)
158
- detached([process.execPath, import.meta.path, 'watch', String(pid)].map(quote).join(' '))
159
- console.log(`up started ${Math.round(performance.now() - t)} pid ${pid}${luid ? ` luid ${luid}` : ''}`)
221
+ writeFileSync(PID, `${pid} ${VERSION} ${port}`)
222
+ for (let i = 0; i < 150 && !(await answers(port)); i++) await Bun.sleep(100)
223
+ if (!(await answers(port))) throw new Error(`the browser (pid ${pid}) did not answer on 127.0.0.1:${port} in 15 s`)
224
+ detached([process.execPath, import.meta.path, 'watch', String(pid), String(port)].map(quote).join(' '))
225
+ console.log(`up started ${Math.round(performance.now() - t)} port ${port} pid ${pid}${luid ? ` luid ${luid}` : ''}${oldUp ? `, the old one on ${old.port} draining` : ''}`)
160
226
  }
161
227
 
162
- async function watch(pid: number): Promise<void> {
163
- for (;;) {
164
- await Bun.sleep(30_000)
228
+ /** one devtools call on the browser's own socket */
229
+ async function browserCall<T>(port: number, method: string, params: Record<string, unknown> = {}): Promise<T> {
230
+ const { webSocketDebuggerUrl } = (await (await fetch(`http://127.0.0.1:${port}/json/version`)).json()) as { webSocketDebuggerUrl: string }
231
+ return await new Promise<T>((done, fail) => {
232
+ const ws = new WebSocket(webSocketDebuggerUrl)
233
+ const t = setTimeout(() => (ws.close(), fail(new Error(`${method}: no answer in 5 s`))), 5000)
234
+ ws.onopen = () => ws.send(JSON.stringify({ id: 1, method, params }))
235
+ ws.onmessage = (e) => {
236
+ clearTimeout(t)
237
+ ws.close()
238
+ done((JSON.parse(String(e.data)) as { result: T }).result)
239
+ }
240
+ ws.onerror = () => fail(new Error(`${method}: the browser's socket failed`))
241
+ })
242
+ }
243
+
244
+ type Target = { targetId: string; type: string; url: string; attached: boolean }
245
+
246
+ /** the pages a film drives now */
247
+ async function filming(port: number): Promise<number> {
248
+ const { targetInfos } = await browserCall<{ targetInfos: Target[] }>(port, 'Target.getTargets')
249
+ return targetInfos.filter((p) => p.type === 'page' && p.url !== 'about:blank' && p.attached).length
250
+ }
251
+
252
+ /** every SWEEP_MS: a page no client drives two sweeps in a row is closed (its film's process died and left it drawing
253
+ * on the GPU); every IDLE_CHECK_MS the idle rule. `drain`: a replaced browser, ended once no film drives a page */
254
+ const SWEEP_MS = 5000
255
+ const IDLE_CHECK_MS = 30_000
256
+
257
+ async function watch(pid: number, port: number, drain: boolean): Promise<void> {
258
+ let orphans = new Set<string>()
259
+ for (let n = 1; ; n++) {
260
+ await Bun.sleep(SWEEP_MS)
165
261
  if (!alive(pid)) return
166
- const idle = Date.now() - (statSync(USED, { throwIfNoEntry: false })?.mtimeMs ?? 0)
167
262
  let busy = false
263
+ let driven = 1
168
264
  try {
169
- const pages = (await (await fetch(`http://127.0.0.1:${CDP_PORT}/json/list`)).json()) as { type: string; url: string }[]
170
- busy = pages.some((p) => p.type === 'page' && p.url !== 'about:blank')
265
+ const { targetInfos } = await browserCall<{ targetInfos: Target[] }>(port, 'Target.getTargets')
266
+ const pages = targetInfos.filter((t) => t.type === 'page' && t.url !== 'about:blank')
267
+ busy = pages.length > 0
268
+ driven = pages.filter((t) => t.attached).length
269
+ const now = new Set(pages.filter((t) => !t.attached).map((t) => t.targetId))
270
+ for (const id of now) if (orphans.has(id)) await browserCall(port, 'Target.closeTarget', { targetId: id })
271
+ orphans = now
171
272
  } catch {}
273
+ if (drain && driven === 0) return void kill(pid)
274
+ if ((n * SWEEP_MS) % IDLE_CHECK_MS !== 0) continue
275
+ const idle = Date.now() - (statSync(USED, { throwIfNoEntry: false })?.mtimeMs ?? 0)
172
276
  if (idle > STALE_MS || (idle > IDLE_MS && !busy)) {
173
277
  kill(pid)
174
- rmSync(PID, { force: true })
278
+ if (current()?.pid === pid) rmSync(PID, { force: true })
175
279
  return
176
280
  }
177
281
  }
178
282
  }
179
283
 
180
284
  if (import.meta.main) {
181
- const [cmd, arg] = process.argv.slice(2)
285
+ const [cmd, arg, port, mode] = process.argv.slice(2)
182
286
  if (cmd === 'up' && arg) await up(arg)
183
- else if (cmd === 'watch' && Number(arg) > 0) await watch(Number(arg))
287
+ else if (cmd === 'watch' && Number(arg) > 0) await watch(Number(arg), Number(port) || CDP_PORT, mode === 'drain')
184
288
  else {
185
- console.error('usage: film-box.ts up <playwright version> | watch <browser pid>')
289
+ console.error('usage: film-box.ts up <playwright version> | watch <browser pid> [port] [drain]')
186
290
  process.exit(2)
187
291
  }
188
292
  }
@@ -20,6 +20,7 @@
20
20
  // lib (a toolkit every repo installs carries no browser). It is resolved from
21
21
  // the repo that runs this, through the one resolver `loadPlaywright`.
22
22
  import { mkdirSync } from 'fs'
23
+ import { format } from 'node:util'
23
24
  import { setPriority } from 'os'
24
25
  import { dirname } from 'path'
25
26
  import { loadPlaywright } from '../smoke/run-smoke.ts'
@@ -39,10 +40,21 @@ type Page = {
39
40
  reload(o?: { waitUntil?: string; timeout?: number }): Promise<unknown>
40
41
  evaluate<R, A>(fn: (a: A) => R | Promise<R>, arg?: A): Promise<R>
41
42
  waitForTimeout(ms: number): Promise<void>
42
- on(event: string, cb: (x: { message?: string; text?(): string; type?(): string }) => void): void
43
+ on(event: string, cb: (x: { message?: string; text?(): string; type?(): string; args?(): { jsonValue(): Promise<unknown> }[] }) => void): void
43
44
  close(): Promise<void>
44
45
  isClosed(): boolean
45
46
  }
47
+ /** a console call's format string with its arguments filled, as the page's own console prints it; null when its
48
+ * first argument formats nothing or an argument cannot be read */
49
+ export async function consoleWords(m: { args?(): { jsonValue(): Promise<unknown> }[] }): Promise<string | null> {
50
+ const args = m.args?.() ?? []
51
+ try {
52
+ const vs = await Promise.all(args.map((h) => h.jsonValue()))
53
+ return typeof vs[0] === 'string' && /%[sdifoOc]/.test(vs[0]) ? format(...vs).replace(/%c/g, '') : null
54
+ } catch {
55
+ return null
56
+ }
57
+ }
46
58
  type Context = { newPage(): Promise<Page>; newCDPSession(p: Page): Promise<Cdp>; addInitScript(s: { content: string }): Promise<void>; close(): Promise<void> }
47
59
  export type Browser = {
48
60
  newContext(o: { viewport: { width: number; height: number }; deviceScaleFactor: number; locale?: string }): Promise<Context>
@@ -192,7 +204,14 @@ export class Shooter {
192
204
  static #listen(page: Page, errors: string[]): void {
193
205
  page.on('pageerror', (e) => errors.push(`pageerror: ${e.message ?? ''}`))
194
206
  page.on('console', (m) => {
195
- if (m.type?.() === 'error') errors.push(`console: ${m.text?.() ?? ''}`)
207
+ if (m.type?.() !== 'error') return
208
+ // the text at once, so no error is lost; then its %s filled from the call's own arguments (React names
209
+ // the duplicate key there), unless the list was cleared or the line moved meanwhile
210
+ const line = `console: ${m.text?.() ?? ''}`
211
+ const at = errors.push(line) - 1
212
+ void consoleWords(m).then((w) => {
213
+ if (w != null && errors[at] === line) errors[at] = `console: ${w}`
214
+ })
196
215
  })
197
216
  }
198
217
 
@@ -1,4 +1,4 @@
1
- // a stepped clip of a page whose canvas is not the page (wiki build/trailer.md, film page): before each frame the page
1
+ // a stepped clip of a page whose canvas is not the page (wiki tools/trailer/index.md, film page): before each frame the page
2
2
  // is asked to draw the frame's time, `window[step](t)`, then the shot service waits for its ready mark and two painted
3
3
  // frames, takes one screenshot, and ffmpeg encodes the frames in order. A canvas page is stepped inside the page and
4
4
  // encoded by its own WebCodecs instead (clip-encoder.ts installClip). The page's own speed never shows: a frame that
package/src/site/desk.ts CHANGED
@@ -1,4 +1,4 @@
1
- // the site desk read (wiki build/shipkit/site.md): an identity's site, its address asked online, the repo that builds
1
+ // the site desk read (wiki tools/shipkit/site.md): an identity's site, its address asked online, the repo that builds
2
2
  // it, and through that repo's site unit its pages, its preview, what is online and what changed since. Nothing here
3
3
  // writes: the preview and the deploy are the unit's own commands (routes.ts)
4
4
  import { existsSync, readFileSync } from 'node:fs'
@@ -223,7 +223,7 @@ function missingOf(i: Identity, repo: SiteRepo | null): string {
223
223
  if (repo == null) return `no repo builds it: siteRepo: in ${i.id}'s identity.md`
224
224
  if (repo.path == null) return `${repo.name} is not on this disk`
225
225
  if (!repo.house) return `${repo.name} is not wired to shipkit: no site unit, so no pages, no preview and no deploy here`
226
- return `${repo.name} declares no site unit: a site({...}) in a .shipkit.ts (build/shipkit/site.md)`
226
+ return `${repo.name} declares no site unit: a site({...}) in a .shipkit.ts (tools/shipkit/site.md)`
227
227
  }
228
228
 
229
229
  export async function siteAnswer(root: string, id: string): Promise<SiteAnswer> {
@@ -1,4 +1,4 @@
1
- // the site desk's routes (wiki build/shipkit/site.md, Routes), on the home daemon: an identity's site read, its local
1
+ // the site desk's routes (wiki tools/shipkit/site.md, Routes), on the home daemon: an identity's site read, its local
2
2
  // preview started when down, its deploy run on his press with the log streamed. Each names an identity, never a path
3
3
  // or a command: the commands are the site unit's
4
4
  import { bad, NO_STORE } from '../review/http.ts'
package/src/site/unit.ts CHANGED
@@ -1,4 +1,4 @@
1
- // a repo's parts of the site desk (wiki build/shipkit/site.md, What a project adds): the command that lists its pages,
1
+ // a repo's parts of the site desk (wiki tools/shipkit/site.md, What a project adds): the command that lists its pages,
2
2
  // its local preview, its deploy, where what is online is read, what a deploy ships and the page a changed file touches.
3
3
  // Every unit file imports this module, so it stays light: desk.ts finds and reads the unit
4
4
 
@@ -0,0 +1,24 @@
1
+ // the drafts a review card was turned into: each draft whose front matter names the card (`review: <id>`), read from
2
+ // the front matter alone so the review page pays no desk load (wiki tools/shipkit/social.md, contract v3)
3
+ import { existsSync, readdirSync, readFileSync } from 'node:fs'
4
+ import { join } from 'node:path'
5
+ import { DRAFT_NAME, draftsDir } from './load.ts'
6
+
7
+ export type CardDraft = { slug: string; title: string }
8
+
9
+ const field = (head: string, key: string): string => new RegExp(`^${key}:[ \\t]*(.*)$`, 'm').exec(head)?.[1]?.trim() ?? ''
10
+
11
+ /** the drafts whose `review:` is one of `ids`, oldest first */
12
+ export function draftsOfCard(root: string, ids: ReadonlySet<string>): CardDraft[] {
13
+ const dir = draftsDir(root)
14
+ if (ids.size === 0 || !existsSync(dir)) return []
15
+ const out: CardDraft[] = []
16
+ for (const slug of readdirSync(dir).sort()) {
17
+ if (!DRAFT_NAME.test(slug)) continue
18
+ const f = join(dir, slug, 'draft.md')
19
+ if (!existsSync(f)) continue
20
+ const head = /^---\n([\s\S]*?)\n---/.exec(readFileSync(f, 'utf8'))?.[1] ?? ''
21
+ if (ids.has(field(head, 'review'))) out.push({ slug, title: field(head, 'title') || slug })
22
+ }
23
+ return out
24
+ }
@@ -1,4 +1,4 @@
1
- // a message's text on each platform (wiki build/shipkit/social.md, The tags): a filled link, the tweet's weighted
1
+ // a message's text on each platform (wiki tools/shipkit/social.md, The tags): a filled link, the tweet's weighted
2
2
  // length, a message's length and text on each account. Pure, no fs: the desk's editor counts with it too
3
3
  import { richText } from './richtext.ts'
4
4
 
@@ -37,7 +37,7 @@ export function messageLength(platform: string, text: string): number {
37
37
  export const TAG = /^#[\p{L}\p{N}_]+$/u
38
38
  /** the Saturday tag, joined where it fits */
39
39
  const SATURDAY = '#ScreenshotSaturday'
40
- /** what each platform takes of a message's tags (wiki build/shipkit/social.md, The tags); an account with no rule takes none */
40
+ /** what each platform takes of a message's tags (wiki tools/shipkit/social.md, The tags); an account with no rule takes none */
41
41
  const TAGS: Readonly<Record<string, 'all' | 'one' | 'vertical'>> = { x: 'all', bluesky: 'all', mastodon: 'all', threads: 'one', tiktok: 'vertical', instagram: 'vertical', youtube: 'vertical' }
42
42
 
43
43
  /** a message as one platform posts it: its text with the tags that platform takes (within its `max`), the footer of a
@@ -1,4 +1,4 @@
1
- // the desk.json answer kept while nothing it is built from moved (wiki build/shipkit/social.md, Routes). A stamp of
1
+ // the desk.json answer kept while nothing it is built from moved (wiki tools/shipkit/social.md, Routes). A stamp of
2
2
  // stats says it: the social folder, the identities, the repo's config and social unit, the media a draft names outside
3
3
  // its folder, and the day; HEAD moves the calendar alone. The desk is built, put on the wire and zipped once a stamp,
4
4
  // and a page that holds the answer gets a 304. A stamp misses a media named outside the folder that appears where none
@@ -1,4 +1,4 @@
1
- // the desk on the wire (wiki build/shipkit/social.md, Routes): a message leaves out what its draft and its account
1
+ // the desk on the wire (wiki tools/shipkit/social.md, Routes): a message leaves out what its draft and its account
2
2
  // already say (the draft's fields, its media by index, the write link its account fills), and an account's messages
3
3
  // are not sent twice, they are its drafts' messages again. `deskOfWire` gives back the very desk `wireOf` was given
4
4
  // (tests/social-desk.test.ts pins it). Pure, so the hub page imports it
@@ -1,4 +1,4 @@
1
- // one draft, one message for every platform (wiki build/shipkit/social.md, contract v3): `drafts/<slug>/draft.md` read into its
1
+ // one draft, one message for every platform (wiki tools/shipkit/social.md, contract v3): `drafts/<slug>/draft.md` read into its
2
2
  // sections and its posted links, the one write (a platform's line of `## Posted`), and where a media name points
3
3
  import { existsSync } from 'node:fs'
4
4
  import { homedir } from 'node:os'
@@ -73,7 +73,7 @@ function options(raw: string, where: string, errors: string[]): Partial<Record<O
73
73
  return out
74
74
  }
75
75
 
76
- /** `groups`: a group's word to its accounts (wiki build/shipkit/social.md, The accounts): a heading named for it goes to each, so their
76
+ /** `groups`: a group's word to its accounts (wiki tools/shipkit/social.md, The accounts): a heading named for it goes to each, so their
77
77
  * posted lines need no heading of their own */
78
78
  export function parseDraft(raw: string, file: string, groups: ReadonlyMap<string, readonly string[]> = new Map()): ParsedDraft {
79
79
  const { meta, body } = parseFrontmatter(raw)
@@ -131,7 +131,7 @@ export function resolveMedia(name: string, dir: string, repo: string): string |
131
131
  return null
132
132
  }
133
133
 
134
- /** a rendered trailer the draft makes and never commits (wiki build/shipkit/social.md, contract v3): its name says
134
+ /** a rendered trailer the draft makes and never commits (wiki tools/shipkit/social.md, contract v3): its name says
135
135
  * `-trailer.mp4` and its text names the command that writes it, `--out <its path from the repo's root>` */
136
136
  export function renderedTrailer(name: string, raw: string, dirFromRepo: string): boolean {
137
137
  return name.endsWith('-trailer.mp4') && raw.includes(`--out ${join(dirFromRepo, name)}`)
@@ -1,4 +1,4 @@
1
- // a repo's social folder read with every identity (wiki build/shipkit/social.md, contract v3): its drafts, one folder a
1
+ // a repo's social folder read with every identity (wiki tools/shipkit/social.md, contract v3): its drafts, one folder a
2
2
  // message, each platform's part handed to its speaker's account; the rhythm; the load's errors. Read from the disk as
3
3
  // it is on every call: the desks and `sk social` never hold a stale copy
4
4
  import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
@@ -22,6 +22,16 @@ const FOLDER_FILES = new Set(['rhythm.md', 'README.md'])
22
22
 
23
23
  export const draftsDir = (root: string): string => join(root, LAYOUT.social, 'drafts')
24
24
 
25
+ /** a draft's `review:`, the card it was asked from: a review item id, never checked against the store (gitignored, a
26
+ * fresh clone has none) */
27
+ function reviewOf(raw: string | undefined, file: string, errors: string[]): string | null {
28
+ const v = raw?.trim() ?? ''
29
+ if (v === '') return null
30
+ if (DRAFT_NAME.test(v)) return v
31
+ errors.push(`${file}: review "${v}" is no review card id (YYYYMMDD-HHMMSS-<slug>)`)
32
+ return null
33
+ }
34
+
25
35
  /** a media as the draft names it, and where it is on the disk: its folder, the repo, or anywhere */
26
36
  export type Media = { name: string; path: string }
27
37
 
@@ -87,6 +97,8 @@ export type Draft = {
87
97
  alt: string
88
98
  posts: SocialPost[]
89
99
  article: Article | null
100
+ /** the review card it was asked from (« 📣 post »), any id of its thread; null when none */
101
+ review: string | null
90
102
  }
91
103
 
92
104
  /** an identity's account with the repo's messages to it */
@@ -224,6 +236,7 @@ export function loadDesk(root: string, ids: Identities, o: { speaksAs?: string |
224
236
  alt: d.meta.alt ?? '',
225
237
  posts: [],
226
238
  article: article(ddir, root, unit),
239
+ review: reviewOf(d.meta.review, file, errors),
227
240
  }
228
241
  const footerText = footerOf(accounts)
229
242
  // each account heading's message, then a group heading's on every account of the group the draft gives no heading
@@ -1,4 +1,4 @@
1
- // the facts of a repo's draft media (wiki build/shipkit/social.md, Media): one local json, `.shipkit/social-media.json`,
1
+ // the facts of a repo's draft media (wiki tools/shipkit/social.md, Media): one local json, `.shipkit/social-media.json`,
2
2
  // each file of the drafts folder by `<slug>/<name>` with its sha, size, type and the mtime it was hashed at. The media
3
3
  // store's `social` kind writes it; a file the disk let go keeps its key here, so the desk still finds it
4
4
  import { readFileSync } from 'node:fs'
@@ -1,4 +1,4 @@
1
- // the social drafts as a kind of the media store (wiki build/shipkit/social.md, Media): every media file of every
1
+ // the social drafts as a kind of the media store (wiki tools/shipkit/social.md, Media): every media file of every
2
2
  // draft folder, and every file a draft names inside the drafts folder, by its facts (media-facts.ts). Every one goes up.
3
3
  // A file git tracks, or would commit, never leaves the disk: a purge would read as a deletion in git. Only a file git
4
4
  // ignores (a rendered trailer, a public repo's drafts) may go, and the desk then serves it from the Space
@@ -1,4 +1,4 @@
1
- // the size a committed draft media may take (wiki build/shipkit/social.md, contract v3): GitHub refuses a file over
1
+ // the size a committed draft media may take (wiki tools/shipkit/social.md, contract v3): GitHub refuses a file over
2
2
  // 100 MB, so the desk's background push would fail with the commit already made. The desk's load reads the disk,
3
3
  // SK036 the index at commit
4
4
  import { statSync } from 'node:fs'
@@ -1,4 +1,4 @@
1
- // the media a repo's drafts could lend a reply (wiki build/shipkit/veille.md, The page): each message of each draft with
1
+ // the media a repo's drafts could lend a reply (wiki tools/shipkit/veille.md, The page): each message of each draft with
2
2
  // a media file, read by the desk's own loader (load.ts) with the repo's speaker, synchronously for the Veille's routes
3
3
  import { readFileSync } from 'node:fs'
4
4
  import { join } from 'node:path'
@@ -1,4 +1,4 @@
1
- // the v2 channel files become drafts, once (wiki build/shipkit/social.md, `sk social`): every
1
+ // the v2 channel files become drafts, once (wiki tools/shipkit/social.md, `sk social`): every
2
2
  // `.shipkit/social/<channel>/<slug>[.<variant>].md` of one slug is ONE draft folder, a heading a channel. The chosen
3
3
  // variant (picked, else posted, else the first) is the heading's text; every other variant is kept word for word under
4
4
  // `## Angle`, with each file's angle and feedback, so nothing he wrote is lost. A v2 file goes once its draft is written
@@ -1,6 +1,6 @@
1
1
  import type { Account } from '../identities/identities.ts'
2
2
 
3
- // what counts as a post of OUR accounts (wiki build/shipkit/social.md, The post tracker): one rule a shape, its pattern built
3
+ // what counts as a post of OUR accounts (wiki tools/shipkit/social.md, The post tracker): one rule a shape, its pattern built
4
4
  // from the account's handle in account.md, never written here. The extension tests the same patterns (it gets them
5
5
  // from the desk), the desk matches again and writes the canonical url
6
6
 
@@ -1,4 +1,4 @@
1
- // what an identity posted, where and when (wiki build/shipkit/social.md, `sk social`), and what comes next (the rhythm):
1
+ // what an identity posted, where and when (wiki tools/shipkit/social.md, `sk social`), and what comes next (the rhythm):
2
2
  // every posted line of the drafts as one post, with its family and its moment, the moment's source said; the slots of
3
3
  // the week and the drafts that take them. Pure over what loadSocial read and a `today` given, never the clock
4
4
  import type { Topic } from './drafts.ts'
@@ -293,7 +293,7 @@ export function planOf(social: { weekly: readonly WeeklySlot[]; drafts: readonly
293
293
  /** a dot of the calendar: a post on its day, or (planned) a slotted draft's message still to post, on its slot's day */
294
294
  export type Mark = { day: string; slug: string; kind: string; planned: boolean }
295
295
  type Topics = { topic: Topic; n: number }[]
296
- /** the Communications desk's calendar (wiki build/shipkit/social.md): four weeks a row an account, the slots, the topics of
296
+ /** the Communications desk's calendar (wiki tools/shipkit/social.md): four weeks a row an account, the slots, the topics of
297
297
  * the last 14 days by family, the week ahead */
298
298
  export type Timeline = { today: string; days: string[]; rows: { account: string; family: Family; marks: Mark[] }[]; slots: SlotDay[]; topics: Record<'all' | Family, Topics>; plan: Plan }
299
299
 
@@ -1,6 +1,6 @@
1
1
  import type { Account } from '../identities/identities.ts'
2
2
 
3
- // the public read APIs of Mastodon and Bluesky (wiki build/shipkit/social.md, The post tracker): the account's latest
3
+ // the public read APIs of Mastodon and Bluesky (wiki tools/shipkit/social.md, The post tracker): the account's latest
4
4
  // posts, logged out, read only. Nothing here logs in, writes, or goes near the browser
5
5
 
6
6
  export type PublicPost = { url: string; at: number }
@@ -1,4 +1,4 @@
1
- // a draft's message posted to Bluesky as the identity's account (wiki build/shipkit/social.md, Publishing): its links
1
+ // a draft's message posted to Bluesky as the identity's account (wiki tools/shipkit/social.md, Publishing): its links
2
2
  // and #tags live, a picture shrunk under 1 MB or a clip through the video service the way Bluesky's own app sends one
3
3
  import { mkdirSync, statSync } from 'node:fs'
4
4
  import { tmpdir } from 'node:os'
@@ -1,4 +1,4 @@
1
- // a draft's message posted to Discord as the identity's bot (wiki build/shipkit/social.md, Publishing): to the channel
1
+ // a draft's message posted to Discord as the identity's bot (wiki tools/shipkit/social.md, Publishing): to the channel
2
2
  // its place names, a `#name` of a channel made its link, its media attached, pinned when it asks; a message already
3
3
  // posted is edited at its link. The server's layout is the project's own tool
4
4
  import type { Account } from '../../identities/identities.ts'
@@ -1,4 +1,4 @@
1
- // the desk's background push (wiki build/shipkit/social.md, The desks in the hub): never a wait in the write path, and
1
+ // the desk's background push (wiki tools/shipkit/social.md, The desks in the hub): never a wait in the write path, and
2
2
  // never silent. A failed push leaves its outcome in the repo's logs folder, which the desk's load turns into an error
3
3
  // line; the next push that lands removes it
4
4
  import { readFileSync } from 'node:fs'
@@ -12,9 +12,15 @@ export const pushLog = (root: string): string => join(root, LAYOUT.logs, 'social
12
12
  const SCRIPT = `out=$("$1" push -q 2>&1); c=$?
13
13
  if [ $c -eq 0 ]; then rm -f "$2"; else mkdir -p "$(dirname "$2")"; printf '%s exit %s\\n%s\\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$c" "$out" > "$2.tmp" && mv "$2.tmp" "$2"; fi`
14
14
 
15
- /** `git push` of the repo at `root`, detached: the caller never waits, the outcome lands in `pushLog` */
16
- export function pushInBackground(root: string): void {
17
- Bun.spawn(['sh', '-c', `nohup sh -c '${SCRIPT.replace(/'/g, `'\\''`)}' push "$0" "$1" >/dev/null 2>&1 &`, gitBin(), pushLog(root)], { cwd: root, stdout: 'ignore', stderr: 'ignore' })
15
+ /** `git push` of the repo at `root`, detached: the caller never waits, the outcome lands in `pushLog`. `git` is the
16
+ * binary to push with */
17
+ export function pushInBackground(root: string, git = gitBin()): void {
18
+ Bun.spawn(['sh', '-c', `nohup sh -c '${SCRIPT.replace(/'/g, `'\\''`)}' push "$0" "$1" >/dev/null 2>&1 &`, git, pushLog(root)], { cwd: root, stdout: 'ignore', stderr: 'ignore' })
19
+ }
20
+
21
+ /** the same push and outcome, waited for: what the background run leaves, at once */
22
+ export function pushNow(root: string): void {
23
+ Bun.spawnSync(['sh', '-c', SCRIPT, 'push', gitBin(), pushLog(root)], { cwd: root, stdout: 'ignore', stderr: 'ignore' })
18
24
  }
19
25
 
20
26
  /** the desk's error line while the last push failed, null once one landed */
@@ -1,4 +1,4 @@
1
- // a text as Bluesky shows and counts it (wiki build/shipkit/social.md, Publishing): each link shortened the way its app does,
1
+ // a text as Bluesky shows and counts it (wiki tools/shipkit/social.md, Publishing): each link shortened the way its app does,
2
2
  // its facet still the whole address, then the #tags; the 300 a post may take counts this text, never the draft's
3
3
  export type Facet = { index: { byteStart: number; byteEnd: number }; features: ({ $type: string } & Record<string, string>)[] }
4
4
 
@@ -1,4 +1,4 @@
1
- // the hub's social routes (wiki build/shipkit/social.md, Routes): the desk of the repo as json, the live numbers apart,
1
+ // the hub's social routes (wiki tools/shipkit/social.md, Routes): the desk of the repo as json, the live numbers apart,
2
2
  // a draft's media and an identity's pictures with byte ranges, his writes, « Publish », « Open all », the Finder and
3
3
  // his notes. Paths are relative to the repo hub's base; null: not a path of these. Every answer reads the disk again,
4
4
  // the desk through its index (desk-index.ts)
@@ -6,7 +6,7 @@ import { existsSync } from 'node:fs'
6
6
  import { homedir } from 'node:os'
7
7
  import { isAbsolute, join, relative, resolve } from 'node:path'
8
8
  import { bad, NO_STORE, ranged } from '../review/http.ts'
9
- import { noteOn, notesBy } from '../review/notes.ts'
9
+ import { askedPosts, noteOn, notesBy } from '../review/notes.ts'
10
10
  import { readAllCached, storeDir } from '../review/store.ts'
11
11
  import { DRAFT_NAME, draftsDir, type Desk } from './load.ts'
12
12
  import { deskAnswer } from './desk-index.ts'
@@ -71,6 +71,10 @@ export async function socialRoutes(root: string, req: Request, path: string): Pr
71
71
  for (const i of desk.identities) out[i.id] = trackerView(i.id)
72
72
  return Response.json(out, { headers: NO_STORE })
73
73
  }
74
+ if (sub === 'asked') {
75
+ const dir = storeDir(root)
76
+ return Response.json({ asked: askedPosts(readAllCached(dir).items) }, { headers: NO_STORE })
77
+ }
74
78
  if (sub === 'notes') {
75
79
  const slug = str(new URL(req.url).searchParams.get('slug'), 'draft', DRAFT_NAME)
76
80
  const dir = storeDir(root)
@@ -115,8 +119,10 @@ export async function socialRoutes(root: string, req: Request, path: string): Pr
115
119
  }
116
120
  if (sub === 'reveal') {
117
121
  const { desk } = await openDesk(root)
118
- const slug = str(b.slug, 'draft', DRAFT_NAME)
119
- const file = await socialMediaBack(root, draftMedia(desk, slug, str(b.name, 'media')))
122
+ // an identity's picture, or a draft's media (brought back from the Space when the disk let it go)
123
+ const file = b.identity != null
124
+ ? picture(desk, str(b.identity, 'identity', ID), String(b.file ?? ''))
125
+ : await socialMediaBack(root, draftMedia(desk, str(b.slug, 'draft', DRAFT_NAME), str(b.name, 'media')))
120
126
  Bun.spawn(['open', '-R', file], { stdout: 'ignore', stderr: 'ignore' })
121
127
  return Response.json({ ok: true })
122
128
  }
@@ -1,4 +1,4 @@
1
- // the live numbers an account shows for free (wiki build/shipkit/social.md, Routes): Bluesky's and Mastodon's public
1
+ // the live numbers an account shows for free (wiki tools/shipkit/social.md, Routes): Bluesky's and Mastodon's public
2
2
  // reads, a Discord invite's counts. Machine level, cached in the home folder 30 minutes a profile; a refusal backs off
3
3
  import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
4
4
  import { join } from 'node:path'
@@ -1,4 +1,4 @@
1
- // a repo's public life as text (wiki build/shipkit/social.md, `sk social`): the overview and its views, and the page
1
+ // a repo's public life as text (wiki tools/shipkit/social.md, `sk social`): the overview and its views, and the page
2
2
  // a repo may keep of it (`sk social state`), all read off one model (presence.ts) over the repo's identity. The page
3
3
  // holds nothing that moves with the clock or a live API: those live in `sk social` alone
4
4
  import type { DeskAccount, Desk } from './load.ts'
@@ -1,4 +1,4 @@
1
- // the post tracker's machine routes, for the extension in an identity's Chrome profile (wiki build/shipkit/social.md,
1
+ // the post tracker's machine routes, for the extension in an identity's Chrome profile (wiki tools/shipkit/social.md,
2
2
  // The post tracker): its rules, a url it saw, the links it read on our profile, each step of a check. Only the extension
3
3
  // sends `x-post-tracker` (a page elsewhere cannot without a preflight nobody answers), its `x-shipkit-profile` names the
4
4
  // profile's email, the email names the identity. null: not a path of these
@@ -1,4 +1,4 @@
1
- // the post tracker (wiki build/shipkit/social.md, The post tracker): the message last opened per identity and platform,
1
+ // the post tracker (wiki tools/shipkit/social.md, The post tracker): the message last opened per identity and platform,
2
2
  // the post urls seen since (the account's public read, the extension in the identity's Chrome profile, a copy of that
3
3
  // profile's History), each written on its line or kept as « seen » until he says where it goes. Machine level: the
4
4
  // state lives in the home folder, an open names the repo whose draft it is