rvlib-shipkit 2.19.0 → 2.21.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 (196) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/package.json +1 -1
  3. package/src/annex/annex.ts +227 -0
  4. package/src/annex/offload.ts +279 -0
  5. package/src/checks/SK004-gitignore-policy.check.ts +6 -3
  6. package/src/checks/SK040-release-words.check.ts +43 -0
  7. package/src/checks/SK041-annex-links.check.ts +28 -0
  8. package/src/checks/SK042-post-kinds.check.ts +73 -0
  9. package/src/cli/cmd_Annex.ts +179 -0
  10. package/src/cli/cmd_Commands.ts +4 -1
  11. package/src/cli/cmd_GlobalProcesses.ts +2 -107
  12. package/src/cli/cmd_Home.ts +4 -3
  13. package/src/cli/cmd_Messages.ts +155 -0
  14. package/src/cli/cmd_Overview.ts +2 -1
  15. package/src/cli/cmd_Releases.ts +84 -0
  16. package/src/cli/cmd_Review.ts +176 -12
  17. package/src/cli/cmd_Shot.ts +4 -4
  18. package/src/cli/cmd_Social.ts +151 -8
  19. package/src/cli/cmd_Sound.ts +17 -4
  20. package/src/cli/cmd_Trailer.ts +67 -1
  21. package/src/cli/family-pages.ts +2 -0
  22. package/src/cli/kit/index.ts +1 -1
  23. package/src/cli/kit/verb.ts +11 -3
  24. package/src/cli/registry.ts +7 -1
  25. package/src/collections/collection-types.ts +8 -1
  26. package/src/collections/providers.ts +4 -1
  27. package/src/collections/review.ts +23 -4
  28. package/src/commands/model.ts +36 -0
  29. package/src/commands/registry.ts +49 -0
  30. package/src/commands/routes.ts +59 -0
  31. package/src/commands/runner.ts +35 -0
  32. package/src/commands/runs.ts +112 -0
  33. package/src/core/app-icon.ts +4 -3
  34. package/src/core/icon-type.ts +8 -0
  35. package/src/core/jobs.ts +4 -3
  36. package/src/core/layout.ts +11 -2
  37. package/src/core/squircle.ts +95 -0
  38. package/src/home/daemon-jobs.ts +26 -2
  39. package/src/home/global-units.ts +3 -0
  40. package/src/home/gui-app/ShipkitGui.swift +337 -5
  41. package/src/home/gui-app.ts +64 -33
  42. package/src/home/hmr-keep.ts +134 -0
  43. package/src/home/home-start.ts +2 -2
  44. package/src/home/lib-watch.ts +21 -11
  45. package/src/home/pm-switch.ts +112 -0
  46. package/src/home/pm.ts +1 -1
  47. package/src/home/process-apps.ts +181 -0
  48. package/src/home/resources.ts +3 -3
  49. package/src/home/run-web.ts +7 -4
  50. package/src/home/serve-web.ts +64 -14
  51. package/src/identities/collection.ts +49 -0
  52. package/src/identities/identities.ts +121 -14
  53. package/src/identities/machine.ts +4 -3
  54. package/src/identities/rating.ts +33 -0
  55. package/src/identities/shown.ts +170 -0
  56. package/src/identities/steps.ts +5 -0
  57. package/src/media-store/purge.ts +15 -1
  58. package/src/media-store/remote.ts +22 -6
  59. package/src/messages/brief.ts +117 -0
  60. package/src/messages/collection.ts +40 -0
  61. package/src/messages/model.ts +171 -0
  62. package/src/messages/routes.ts +15 -0
  63. package/src/messages/score.ts +182 -0
  64. package/src/messages/tabs.ts +13 -0
  65. package/src/release/notes.ts +130 -0
  66. package/src/release/run-bump.ts +41 -18
  67. package/src/release/run-release.ts +22 -4
  68. package/src/release/run-releases.ts +17 -15
  69. package/src/release/unit-resolve.ts +9 -0
  70. package/src/releases/add.ts +94 -0
  71. package/src/releases/before.ts +31 -0
  72. package/src/releases/collection.ts +36 -0
  73. package/src/releases/from-card.ts +151 -0
  74. package/src/releases/model.ts +327 -0
  75. package/src/releases/pictures.ts +110 -0
  76. package/src/releases/routes.ts +36 -0
  77. package/src/releases/store.ts +71 -0
  78. package/src/repo-config.ts +5 -0
  79. package/src/review/cells.ts +0 -11
  80. package/src/review/format.ts +10 -6
  81. package/src/review/http.ts +1 -1
  82. package/src/review/model.ts +102 -3
  83. package/src/review/notes.ts +2 -48
  84. package/src/review/routes.ts +28 -10
  85. package/src/review/stage-card.ts +197 -0
  86. package/src/review/stage-routes.ts +123 -0
  87. package/src/review/store.ts +47 -1
  88. package/src/review/trailer-card.ts +99 -0
  89. package/src/review/trailer-desk.ts +76 -4
  90. package/src/review/trailer-model.ts +106 -7
  91. package/src/review/trailer-notes.ts +45 -0
  92. package/src/review/trailer-routes.ts +119 -13
  93. package/src/review/trailer-voices.ts +144 -0
  94. package/src/review/watchers.ts +58 -1
  95. package/src/serve/hub-app/app-bridge.ts +71 -0
  96. package/src/serve/hub-app/benign-errors.ts +22 -0
  97. package/src/serve/hub-app/commands/commands-page.tsx +122 -0
  98. package/src/serve/hub-app/commands/commands-st.ts +177 -0
  99. package/src/serve/hub-app/commands.css +24 -0
  100. package/src/serve/hub-app/hash-route.ts +59 -8
  101. package/src/serve/hub-app/home-st.ts +19 -2
  102. package/src/serve/hub-app/home.html +3 -0
  103. package/src/serve/hub-app/hub-app.tsx +8 -0
  104. package/src/serve/hub-app/icons.tsx +5 -0
  105. package/src/serve/hub-app/identities-view.tsx +4 -1
  106. package/src/serve/hub-app/identities.css +1 -0
  107. package/src/serve/hub-app/index.html +3 -0
  108. package/src/serve/hub-app/keys.ts +2 -2
  109. package/src/serve/hub-app/machine-st.ts +41 -10
  110. package/src/serve/hub-app/messages/messages-page.tsx +354 -0
  111. package/src/serve/hub-app/messages/messages-st.ts +74 -0
  112. package/src/serve/hub-app/messages.css +35 -0
  113. package/src/serve/hub-app/project-list.css +7 -2
  114. package/src/serve/hub-app/project-list.tsx +9 -0
  115. package/src/serve/hub-app/projects-svc.ts +16 -6
  116. package/src/serve/hub-app/releases/releases-page.tsx +187 -0
  117. package/src/serve/hub-app/releases/releases-st.ts +111 -0
  118. package/src/serve/hub-app/releases.css +52 -0
  119. package/src/serve/hub-app/repo-sections.ts +16 -2
  120. package/src/serve/hub-app/repo-st.ts +66 -10
  121. package/src/serve/hub-app/review/clip-st.ts +34 -4
  122. package/src/serve/hub-app/review/kit.tsx +3 -3
  123. package/src/serve/hub-app/review/note-place.ts +31 -0
  124. package/src/serve/hub-app/review/review-cells.tsx +27 -3
  125. package/src/serve/hub-app/review/review-st.ts +77 -2
  126. package/src/serve/hub-app/review/review-thread.tsx +9 -31
  127. package/src/serve/hub-app/review/review-views.tsx +164 -58
  128. package/src/serve/hub-app/review/thread-st.ts +108 -41
  129. package/src/serve/hub-app/review/trailer-card.tsx +187 -0
  130. package/src/serve/hub-app/review/trailer-page.tsx +92 -36
  131. package/src/serve/hub-app/review/trailer-st.ts +306 -34
  132. package/src/serve/hub-app/review/trailer-timeline.tsx +68 -23
  133. package/src/serve/hub-app/review/trailer-voices-st.ts +370 -0
  134. package/src/serve/hub-app/review/trailer-voices.tsx +574 -0
  135. package/src/serve/hub-app/review.css +137 -6
  136. package/src/serve/hub-app/social/comms-page.tsx +65 -28
  137. package/src/serve/hub-app/social/identity-pictures.ts +46 -8
  138. package/src/serve/hub-app/social/kit.tsx +9 -6
  139. package/src/serve/hub-app/social/next-release.tsx +118 -0
  140. package/src/serve/hub-app/social/post-card.tsx +10 -2
  141. package/src/serve/hub-app/social/social-model.ts +39 -3
  142. package/src/serve/hub-app/social/social-page.tsx +179 -65
  143. package/src/serve/hub-app/social/social-st.ts +117 -27
  144. package/src/serve/hub-app/social/stage-popup.tsx +268 -0
  145. package/src/serve/hub-app/social/stage-st.ts +310 -0
  146. package/src/serve/hub-app/social/step-layout.ts +42 -0
  147. package/src/serve/hub-app/social.css +68 -1
  148. package/src/serve/hub-app/tree-build.ts +40 -1
  149. package/src/serve/hub-app/tree-svc.ts +10 -3
  150. package/src/serve/project-gutter-route.ts +12 -2
  151. package/src/serve/project-gutter.ts +4 -2
  152. package/src/serve/same-origin.ts +24 -1
  153. package/src/serve/serve-hub.ts +15 -1
  154. package/src/shipkit-files.ts +9 -7
  155. package/src/shot/box.ts +33 -12
  156. package/src/shot/client.ts +1 -1
  157. package/src/shot/shooter.ts +22 -12
  158. package/src/shot/shot-ask.ts +14 -3
  159. package/src/shot/shot.shipkit.ts +1 -1
  160. package/src/social/desk-index.ts +49 -8
  161. package/src/social/discord-layout.ts +54 -7
  162. package/src/social/drafts.ts +1 -1
  163. package/src/social/fit.ts +84 -0
  164. package/src/social/identity-words.ts +74 -0
  165. package/src/social/kind-pages.ts +41 -0
  166. package/src/social/kinds.ts +93 -0
  167. package/src/social/load.ts +125 -10
  168. package/src/social/media-limit.ts +63 -2
  169. package/src/social/presence.ts +1 -1
  170. package/src/social/publish/bluesky.ts +58 -19
  171. package/src/social/publish/index.ts +47 -6
  172. package/src/social/reach.ts +49 -0
  173. package/src/social/release-stage.ts +277 -0
  174. package/src/social/routes.ts +44 -8
  175. package/src/social/stage.ts +246 -0
  176. package/src/social/strip.ts +85 -0
  177. package/src/social/text.ts +6 -2
  178. package/src/social/unit.ts +57 -1
  179. package/src/social/writes.ts +11 -0
  180. package/src/trailer/bed.ts +111 -0
  181. package/src/trailer/build.ts +72 -40
  182. package/src/trailer/ffmpeg.ts +6 -0
  183. package/src/trailer/grammar.ts +37 -6
  184. package/src/trailer/graph.ts +12 -1
  185. package/src/trailer/public-words.ts +41 -0
  186. package/src/trailer/shot-plan.ts +75 -0
  187. package/src/trailer/shot-state.ts +191 -0
  188. package/src/trailer/sound/audio.ts +28 -0
  189. package/src/trailer/sound/brand.ts +53 -3
  190. package/src/trailer/sound/gen.ts +61 -2
  191. package/src/trailer/sound/index.ts +25 -11
  192. package/src/trailer/sound/presets.ts +86 -5
  193. package/src/trailer/sound/run.ts +1 -1
  194. package/src/trailer/sound/takes.ts +94 -0
  195. package/src/trailer/titles.ts +36 -0
  196. package/src/trailer/url.ts +1 -1
@@ -74,7 +74,7 @@ export interface Spec {
74
74
  }
75
75
 
76
76
  /** the kinds every repo has, whatever its unit declares */
77
- export const BUILTIN_KINDS: Record<string, SpecKind> = { shot: { label: 'images' }, screen: { label: 'screens' }, frame: { label: 'trailer frames' }, store: { label: 'store pages', icon: '🏪' }, post: { label: 'post requests', icon: '📣' } }
77
+ export const BUILTIN_KINDS: Record<string, SpecKind> = { shot: { label: 'images' }, screen: { label: 'screens' }, frame: { label: 'trailer frames' }, trailer: { label: 'trailers', icon: '🎬' }, store: { label: 'store pages', icon: '🏪' }, post: { label: 'post requests', icon: '📣' } }
78
78
 
79
79
  export const NO_SPEC: Spec = { kinds: {}, topics: {}, dispatcher: false }
80
80
 
@@ -175,6 +175,21 @@ export const isGallery = (v: ReviewView): v is GalleryView => 'gallery' in v
175
175
 
176
176
  export const SHA_RE = /^[0-9a-f]{64}$/
177
177
 
178
+ /** a card's public change: the release category it goes under and its one line, the `### ` title */
179
+ export interface CardChangelog {
180
+ category: string
181
+ line: string
182
+ /** what its media shows (`--rating`): the rating its picture lands with; absent, unrated (it reads explicit) */
183
+ rating?: 'safe' | 'mild' | 'explicit'
184
+ }
185
+
186
+ /** `--changelog "<category>: <line>"` read; a line with no category throws saying the shape */
187
+ export function changelogOfFlag(s: string): CardChangelog {
188
+ const m = /^([^:]+):\s*(.+)$/.exec(s.trim())
189
+ if (!m || m[1]!.trim() === '' || m[2]!.trim() === '') throw new Error(`--changelog "${s}": "<category>: <public line>", like "Studio: Move the body anywhere on the floor"`)
190
+ return { category: m[1]!.trim(), line: m[2]!.trim() }
191
+ }
192
+
178
193
  /** `item.json`: the head, written at creation, changed by `add-view`, a draft's refresh and the media facts it lacks */
179
194
  export interface Item {
180
195
  id: string
@@ -185,6 +200,11 @@ export interface Item {
185
200
  title: string
186
201
  /** an agent card's markdown: what changed and why */
187
202
  what?: string
203
+ /** the public line its agent wrote for a post of it (`--post`), checked by the repo's guard at add */
204
+ post?: string
205
+ /** the change its approval adds to the release being filled (`--changelog "<category>: <line>"`, releases/from-card.ts),
206
+ * checked by the repo's guard at add */
207
+ changelog?: CardChangelog
188
208
  topic?: string
189
209
  commit?: string
190
210
  /** a media view (an image, a clip, a sound, a pair) or a gallery of images, any of them first */
@@ -202,10 +222,33 @@ export interface Item {
202
222
  wip?: { live: string; frame: number }
203
223
  /** a choice: every view is an option, he scores them and picks one */
204
224
  choice?: true
225
+ /** on a choice: the option its agent suggests, the view's index (the hub's « my pick » pill); his own pick is the verdict's */
226
+ agentPick?: number
227
+ /** a trailer card: its body plays this cut in the trailer entry's player, never a compiled clip */
228
+ trailer?: TrailerCard
205
229
  /** each media file the views name, by its name: what the Space keeps it under once the disk lets it go */
206
230
  media?: Record<string, MediaFact>
207
231
  }
208
232
 
233
+ /** one render a trailer card plays: the cut, and the render pinned by its mtime in ms */
234
+ export interface TrailerSide {
235
+ cut: string
236
+ render: number
237
+ }
238
+
239
+ /** what a trailer card plays (wiki tools/shipkit/review.md, A trailer): a cut of `trailer/<trailer>/`, the render it is
240
+ * compared with, the shots the change touched by name */
241
+ export interface TrailerCard {
242
+ trailer: string
243
+ after: TrailerSide
244
+ before?: TrailerSide
245
+ shots: string[]
246
+ /** the cut's frame in pixels: what his rectangles on it measure in */
247
+ size?: [number, number]
248
+ }
249
+
250
+ export const isTrailerCard = (i: Item): i is Item & { trailer: TrailerCard } => i.trailer !== undefined
251
+
209
252
  /** a choice card: he picks one of its views */
210
253
  export const isChoice = (i: Item): boolean => i.choice === true
211
254
 
@@ -256,6 +299,16 @@ export const viewTag = (n: number, i: number): string => `${n}.${viewLetter(i)}`
256
299
  /** a view's name as the page and the CLI show it: its label, or « view B » */
257
300
  export const viewName = (v: ReviewView | undefined, i: number): string => v?.label || `view ${viewLetter(i)}`
258
301
 
302
+ /** a view named by its label, else by its letter (`B`); throws naming every view when none matches */
303
+ export function viewIndexOf(views: readonly { label: string }[], ref: string): number {
304
+ const r = ref.trim()
305
+ const byLabel = views.findIndex((v) => v.label === r)
306
+ if (r !== '' && byLabel >= 0) return byLabel
307
+ const byLetter = views.findIndex((_, i) => viewLetter(i) === r.toUpperCase())
308
+ if (r !== '' && byLetter >= 0) return byLetter
309
+ throw new Error(`« ${ref} » names no view: ${views.map((v, i) => `${viewLetter(i)}${v.label ? ` "${v.label}"` : ''}`).join(', ')}`)
310
+ }
311
+
259
312
  /** every media file a card's views name: images, pairs, clips and their posters, sounds and their waveforms, tiles */
260
313
  export function viewFilesOf(i: Item): string[] {
261
314
  return i.views.flatMap((v) => {
@@ -282,7 +335,8 @@ export const onFrame = (t: number, time: number, fps: number): boolean => Math.f
282
335
  export type Side = 'before' | 'after'
283
336
 
284
337
  /** a rectangle on a view, normalized 0..1; w = h = 0 is a pin. `view` the index of its view, absent on the first;
285
- * `side` only on a pair; `t` only on a clip */
338
+ * `side` only on a pair (on a trailer card with a before, the render it is drawn on); `t` only on a clip or a trailer
339
+ * card's frame */
286
340
  export interface Rect {
287
341
  x: number
288
342
  y: number
@@ -293,6 +347,8 @@ export interface Rect {
293
347
  side?: Side
294
348
  /** the clip time it was drawn at, in seconds */
295
349
  t?: number
350
+ /** on a trailer card's frame: the shot it sits on and the seconds into it, so a new render places it */
351
+ shot?: { name: string; time: number }
296
352
  /** the gallery tile it is drawn on, its coordinates the tile's image */
297
353
  tile?: number
298
354
  world?: { x0: number; y0: number; x1: number; y1: number }
@@ -658,6 +714,14 @@ export const coversCard = (f: WatchFilter, x: ReviewItem): boolean =>
658
714
  /** the live watchers that will read his answer on any of these cards */
659
715
  export const listenersOf = (cards: readonly ReviewItem[], watchers: readonly Watcher[]): Watcher[] => watchers.filter((w) => cards.some((x) => coversCard(w, x)))
660
716
 
717
+ /** who listens, in plain words: one lane's watch by its lane, any other by « an agent », several by their count */
718
+ export function listenWords(ws: readonly Watcher[]): string {
719
+ const [w] = ws
720
+ if (w === undefined) return 'nobody listens'
721
+ if (ws.length > 1) return `${ws.length} agents listening`
722
+ return w.lane ? `the ${w.lane} lane is listening` : 'an agent is listening'
723
+ }
724
+
661
725
  /** what `review add` says when no live watch of the card's own session or lane will read his answer, else null: an
662
726
  * unfiltered watch (a dispatcher, another session) hears it for someone else */
663
727
  export function unheardLine(item: Item, watchers: readonly Watcher[]): string | null {
@@ -783,6 +847,16 @@ function originProblems(o: unknown): string[] {
783
847
  return ['origin.by: agent, owner, player or auto']
784
848
  }
785
849
 
850
+ function trailerCardProblems(t: unknown): string[] {
851
+ const side = (v: unknown): boolean => obj(v) && typeof v.cut === 'string' && v.cut !== '' && typeof v.render === 'number' && Number.isFinite(v.render)
852
+ if (!obj(t) || typeof t.trailer !== 'string' || t.trailer === '' || !side(t.after)) return ['trailer: { trailer, after: { cut, render }, before?, shots }']
853
+ const out: string[] = []
854
+ if (t.before !== undefined && !side(t.before)) out.push('trailer.before: { cut, render }, or absent')
855
+ if (!Array.isArray(t.shots) || !t.shots.every((s) => typeof s === 'string' && s !== '')) out.push('trailer.shots: a list of shot names')
856
+ if (t.size !== undefined && !(Array.isArray(t.size) && t.size.length === 2 && t.size.every((n) => Number.isInteger(n) && (n as number) > 0))) out.push('trailer.size: [width, height] in pixels, or absent')
857
+ return out
858
+ }
859
+
786
860
  /** every reason an item.json read back is not an item; empty: it is one */
787
861
  export function itemProblems(v: unknown): string[] {
788
862
  if (!obj(v)) return ['not an object']
@@ -801,10 +875,15 @@ export function itemProblems(v: unknown): string[] {
801
875
  })
802
876
  if (v.answers !== undefined && !(Array.isArray(v.answers) && v.answers.length > 0 && v.answers.every((a) => typeof a === 'string' && ID_RE.test(a))))
803
877
  out.push('answers: a list of item ids')
804
- for (const k of ['what', 'commit', 'supersedes', 'why', 'keeps']) if (v[k] !== undefined && typeof v[k] !== 'string') out.push(`${k}: a text`)
878
+ for (const k of ['what', 'post', 'commit', 'supersedes', 'why', 'keeps']) if (v[k] !== undefined && typeof v[k] !== 'string') out.push(`${k}: a text`)
879
+ if (v.changelog !== undefined && !(obj(v.changelog) && typeof v.changelog.category === 'string' && v.changelog.category.trim() !== '' && typeof v.changelog.line === 'string' && v.changelog.line.trim() !== '' && (v.changelog.rating === undefined || ['safe', 'mild', 'explicit'].includes(v.changelog.rating as string))))
880
+ out.push('changelog: { category, line, rating? }, or absent')
805
881
  if (v.light !== undefined && v.light !== 'review') out.push('light: review, or absent')
806
882
  if (v.wip !== undefined && !(obj(v.wip) && typeof v.wip.live === 'string' && v.wip.live !== '' && Number.isInteger(v.wip.frame))) out.push('wip: { live, frame }, or absent')
883
+ if (v.trailer !== undefined) out.push(...trailerCardProblems(v.trailer))
807
884
  if (v.choice !== undefined && !(v.choice === true && Array.isArray(v.views) && v.views.length >= 2)) out.push('choice: true on a card of two views or more, or absent')
885
+ if (v.agentPick !== undefined && !(v.choice === true && Number.isInteger(v.agentPick) && Array.isArray(v.views) && (v.agentPick as number) >= 0 && (v.agentPick as number) < v.views.length))
886
+ out.push('agentPick: the index of one of its views, on a choice card, or absent')
808
887
  if (v.media !== undefined) {
809
888
  if (!obj(v.media)) out.push('media: { <file name>: { sha, size, type } }, or absent')
810
889
  else
@@ -896,6 +975,21 @@ function viewProblems(v: Record<string, unknown>, at: string): string[] {
896
975
  }
897
976
 
898
977
  /** the verdict the page sends for an item, checked: every rectangle inside its view, a side exactly on a pair */
978
+ /** what a rectangle on a trailer card's frame carries beyond its box: the time on the cut it was drawn at, the shot and
979
+ * the seconds into it, and with a before the render it sits on; null with its errors pushed */
980
+ function trailerRect(r: Record<string, unknown>, t: TrailerCard, i: number, errors: string[]): Pick<Rect, 't' | 'shot' | 'side'> | null {
981
+ const at = r.t
982
+ const shot = r.shot as { name?: unknown; time?: unknown } | undefined
983
+ const bad: string[] = []
984
+ if (typeof at !== 'number' || !Number.isFinite(at) || at < 0) bad.push(`rects[${i}].t: the time on the cut it was drawn at`)
985
+ if (!obj(shot) || typeof shot.name !== 'string' || shot.name === '' || typeof shot.time !== 'number' || !Number.isFinite(shot.time) || shot.time < 0)
986
+ bad.push(`rects[${i}].shot: { name, time }, the shot it sits on and the seconds into it`)
987
+ if (t.before ? r.side !== 'before' && r.side !== 'after' : r.side !== undefined) bad.push(`rects[${i}].side: ${t.before ? 'before or after, the render it is drawn on' : 'none on a trailer card with no before'}`)
988
+ errors.push(...bad)
989
+ if (bad.length > 0 || !obj(shot)) return null
990
+ return { t: at as number, shot: { name: shot.name as string, time: shot.time as number }, ...(t.before ? { side: r.side as Side } : {}) }
991
+ }
992
+
899
993
  export function verdictMessageOf(body: unknown, item: Item): { ok: true; message: Pick<Message, 'verdict' | 'text' | 'rects' | 'reactions' | 'pick'> } | { ok: false; errors: string[] } {
900
994
  if (!obj(body)) return { ok: false, errors: ['not an object'] }
901
995
  const errors: string[] = []
@@ -932,6 +1026,11 @@ export function verdictMessageOf(body: unknown, item: Item): { ok: true; message
932
1026
  errors.push(`rects[${i}].view: no rectangle on a sound, react to the view instead`)
933
1027
  continue
934
1028
  }
1029
+ if (view === 0 && isTrailerCard(item)) {
1030
+ const r2 = trailerRect(r, item.trailer, i, errors)
1031
+ if (r2) out.push({ x: r.x, y: r.y, w: r.w, h: r.h, comment: typeof r.comment === 'string' ? r.comment : '', ...r2 })
1032
+ continue
1033
+ }
935
1034
  const pair = isPair(on.files)
936
1035
  if (pair && r.side !== 'before' && r.side !== 'after') errors.push(`rects[${i}].side: before or after, on a pair`)
937
1036
  if (!pair && r.side !== undefined) errors.push(`rects[${i}].side: none on a single image`)
@@ -1,10 +1,9 @@
1
1
  // his notes on one thing a desk shows (a store page's picture or field, a draft): the first an item of the one store,
2
2
  // its subject the thing, so the review page and `sk review inbox` hold it; the next ones, while that thread is open,
3
3
  // his replies on it, never a second item. The one path for a note on a thing (wiki tools/shipkit/stores.md)
4
- import { threadOfId } from './cells.ts'
5
- import { isPostSubject, stateOf, subjectKey, type Origin, type PostSubject, type ReviewItem, type Subject } from './model.ts'
4
+ import { stateOf, subjectKey, type Origin, type ReviewItem, type Subject } from './model.ts'
6
5
  import { addMessage, raiseItem, readAll, specOf } from './store.ts'
7
- import { followedIds, membersOf, threadsOf, type Thread } from './threads.ts'
6
+ import { membersOf, threadsOf, type Thread } from './threads.ts'
8
7
 
9
8
  /** one note as a desk shows it: the owner's words, where it stands, the agent's last word once answered */
10
9
  export type SubjectNote = { id: string; at: string; text: string; state: string; answer?: string }
@@ -78,48 +77,3 @@ export async function noteOn(
78
77
  return { id: x.item.id }
79
78
  }
80
79
 
81
- /** a post the owner asked from a card and no draft answers yet: what Communications lists on top of its drafts */
82
- export type AskedPost = { id: string; at: string; card: string; title: string; text: string; state: string }
83
-
84
- /** every post request not closed, oldest first: the card's title as it is now, the owner's words joined */
85
- export function askedPosts(items: readonly ReviewItem[]): AskedPost[] {
86
- const threads = threadsOf(items)
87
- const followed = followedIds(items)
88
- return items
89
- .filter((x) => isPostSubject(x.item.subject))
90
- .map((x) => ({ x, st: stateOf(x, followed.has(x.item.id)) }))
91
- .filter(({ st }) => st.state !== 'closed')
92
- .sort((a, b) => a.x.item.created.localeCompare(b.x.item.created))
93
- .map(({ x, st }) => {
94
- const card = (x.item.subject as PostSubject).card
95
- const t = threadOfId(card, threads)
96
- const words = x.thread.filter((m) => m.who === 'owner' && m.op === undefined && m.verdict === undefined && m.text !== undefined).map((m) => m.text as string)
97
- return { id: x.item.id, at: x.item.created, card: t?.head.item.id ?? card, title: t?.head.item.title ?? card, text: words.join('\n'), state: st.state }
98
- })
99
- }
100
-
101
- /** « 📣 post » on a card: a request for its own public post, keyed on the card's first version so every version asks
102
- * the same one; `topic` the social unit's notes topic, left out where the store's topics lack it */
103
- export async function askPost(dir: string, o: { card: string; text?: string; topic?: string }): Promise<{ id: string }> {
104
- const t = threadOfId(o.card, threadsOf(readAll(dir).items))
105
- if (!t) throw new Error(`post: no card ${o.card}`)
106
- const head = t.head.item
107
- if (isPostSubject(head.subject)) throw new Error('post: this card is itself a post request')
108
- const first = t.versions.at(-1)?.item.id ?? head.id
109
- const spec = specOf(dir)
110
- const topic = o.topic !== undefined && (Object.keys(spec.topics).length === 0 || spec.topics[o.topic]) ? o.topic : undefined
111
- const subject: PostSubject = { kind: 'post', card: first }
112
- return noteOn(dir, {
113
- subject,
114
- origin: { by: 'owner', from: 'review' },
115
- name: `post « ${head.title} »`,
116
- text: o.text?.trim() || 'this card deserves its own post',
117
- ...(topic ? { topic } : {}),
118
- what: [
119
- `A public post from the card « ${head.title} » (${head.id}).`,
120
- `- read the card: \`sk review show ${head.id}\`; its views are the post's media`,
121
- `- write the draft: \`.shipkit/social/drafts/<YYYYMMDD-HHMMSS>-<topic>/draft.md\`, \`review: ${head.id}\` in its front matter, the media in its \`media/\` (wiki tools/shipkit/social.md)`,
122
- '- close this request: `sk review fixed <this id> --note "draft <slug>"`',
123
- ].join('\n'),
124
- })
125
- }
@@ -1,14 +1,14 @@
1
1
  // the hub's review routes (wiki tools/shipkit/review.md, The hub): the store's list, an item's images and clips, the
2
2
  // owner's verdicts, replies and read marks appended to its thread. The trailer view's routes: trailer-routes.ts. Paths are
3
3
  // relative to the repo hub's base. null: not a path of these
4
- import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
4
+ import { existsSync, mkdtempSync, rmSync, statSync, writeFileSync } from 'node:fs'
5
5
  import { tmpdir } from 'node:os'
6
6
  import { dirname, extname, join } from 'node:path'
7
7
  import { isAnimFormat, isAnimLabels, isAnimMode, pairAnimation } from './anim.ts'
8
8
  import { startAuto } from './auto.ts'
9
9
  import { bad, KEEP, NO_STORE, ranged, tagged, TYPES } from './http.ts'
10
10
  import { viewFilesOf, type Rect, type ReviewItem, type Subject } from './model.ts'
11
- import { askPost } from './notes.ts'
11
+ import { stageGet, stagePost } from './stage-routes.ts'
12
12
  import { pasteHosts } from './paste.ts'
13
13
  import { openReview, partFile, viewOfItem } from './project.ts'
14
14
  import { isPreviewSize, previewOrRemote, warmPreviews } from './previews.ts'
@@ -23,8 +23,8 @@ import { trailerRoutes } from './trailer-routes.ts'
23
23
  import { specData, type ReviewUnit } from './unit.ts'
24
24
  import { liveWatchers } from './watchers.ts'
25
25
  import { autoRulesOf } from '../veille/auto.ts'
26
- import { loadSocialUnit } from '../social/unit.ts'
27
26
  import { draftsOfCard } from '../social/card-drafts.ts'
27
+ import { draftsDir } from '../social/load.ts'
28
28
 
29
29
  // ── each repo's review unit, read again at most every 5 s; its auto rules scheduled in this server while it serves ──
30
30
 
@@ -50,6 +50,19 @@ async function project(root: string): Promise<{ dir: string; unit: ReviewUnit |
50
50
  return { dir, unit }
51
51
  }
52
52
 
53
+ /** an approved card's changelog line into next.md (releases/from-card.ts), after the verdict answered: a failure says so
54
+ * on the card's thread and in the hub's log, so the change is never lost in silence */
55
+ async function changeOnVerdict(dir: string, id: string): Promise<void> {
56
+ try {
57
+ const { onVerdict } = await import('../releases/from-card.ts')
58
+ await onVerdict(dirname(dirname(dir)), id)
59
+ } catch (e) {
60
+ const why = (e as Error).message
61
+ console.error(`FAIL: the release did not take the change of ${id}: ${why}`)
62
+ addMessage(dir, id, 'releases', `the release did not take this change: ${why}. Run sk releases add --card ${id}`)
63
+ }
64
+ }
65
+
53
66
  /** an image the page sent as a data url, written to a scratch file the caller removes */
54
67
  function dataUrlFile(url: unknown): { file: string; done(): void } | null {
55
68
  if (url === undefined || url === null) return null
@@ -148,7 +161,9 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
148
161
  }
149
162
  const t = threadOfId(id, x.threads)
150
163
  if (!t) return bad(`no item ${ref}`, 404)
151
- return tagged(req, x.tag, () => {
164
+ // a draft staged from the card moves the drafts folder, not the store: its time joins the tag
165
+ const staged = statSync(draftsDir(dirname(dirname(dir))), { throwIfNoEntry: false })?.mtimeMs ?? 0
166
+ return tagged(req, `${x.tag.slice(0, -1)}.${Math.round(staged)}"`, () => {
152
167
  const members = membersOf(t)
153
168
  return { ...threadView(t, readAllCached(dir).items, x.threads, id), missing: missingOf(dir, members), drafts: draftsOfCard(dirname(dirname(dir)), new Set(members.map((m) => m.item.id))) }
154
169
  })
@@ -231,14 +246,10 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
231
246
  try {
232
247
  if (name === 'feedback') {
233
248
  const r = writeVerdict(dir, id, await req.json())
249
+ if (r.ok) void changeOnVerdict(dir, id)
234
250
  return r.ok ? Response.json(r.message, { headers: NO_STORE }) : Response.json({ error: r.errors.join('\n'), errors: r.errors }, { status: 400, headers: NO_STORE })
235
251
  }
236
- if (name === 'post') {
237
- const b = (await req.json().catch(() => ({}))) as { text?: unknown }
238
- const social = await loadSocialUnit(dirname(dirname(dir)))
239
- const text = typeof b.text === 'string' ? b.text : undefined
240
- return Response.json(await askPost(dir, { card: id, topic: social?.notes ?? 'social', ...(text ? { text } : {}) }), { headers: NO_STORE })
241
- }
252
+ if (name === 'stage') return await stagePost(dirname(dirname(dir)), dir, id, unit, (await req.json().catch(() => ({}))) as Record<string, unknown>)
242
253
  if (name === 'reply') return Response.json(addMessage(dir, id, 'owner', ((await req.json()) as { text?: unknown }).text), { headers: NO_STORE })
243
254
  if (name === 'read') {
244
255
  // the page names the words it drew: a word that came after them stays unread
@@ -268,6 +279,13 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
268
279
  return bad(`POST ${path}?`, 404)
269
280
  }
270
281
  if (req.method !== 'GET') return null
282
+ if (name === 'stage') {
283
+ try {
284
+ return await stageGet(dirname(dirname(dir)), dir, id)
285
+ } catch (e) {
286
+ return bad(e)
287
+ }
288
+ }
271
289
  // a kind's data view of one item, computed here: the page never runs the repo's code
272
290
  if (name === 'view') {
273
291
  try {
@@ -0,0 +1,197 @@
1
+ // what a review card offers a post (wiki tools/shipkit/review-raised-items.md, A post staged from a card): each media of
2
+ // each version (an image, a clip, a pair's after, its before, its wipe, a gallery tile; never a sound alone), and the
3
+ // card's own words as chips: its title, its `what` cut into lines, its views' labels and notes, the line its agent
4
+ // wrote for a post, the owner's words and the agents' replies on the thread. A pick is a name the card names, never a path
5
+ import type { PostRating } from '../identities/rating.ts'
6
+ import { cutPassage } from '../social/fit.ts'
7
+ import type { StageInput } from '../social/stage.ts'
8
+ import { pairAnimation } from './anim.ts'
9
+ import { threadOfId } from './cells.ts'
10
+ import { ensureLocal } from './media-read.ts'
11
+ import { isApproved, isGallery, isPair, isReply, partyOf, viewLetter, viewName, wordsOf, type Item, type ReviewItem } from './model.ts'
12
+ import { readAll } from './store.ts'
13
+ import { threadsOf } from './threads.ts'
14
+
15
+ export type StageSide = 'before' | 'after' | 'wipe'
16
+
17
+ /** one media of a card a post may carry */
18
+ export type Stageable = {
19
+ /** `<item>#<view>[.<side>|/<tile>]`: the pick the popup sends back */
20
+ key: string
21
+ item: string
22
+ view: number
23
+ side?: StageSide
24
+ tile?: number
25
+ /** `2.A after`, `2.C vitality` */
26
+ label: string
27
+ kind: 'image' | 'clip'
28
+ /** the store's file the page shows for it (a wipe: the pair's after) */
29
+ file: string
30
+ /** its width over its height */
31
+ ratio: number
32
+ /** what it shows, for the alt: the view's note, its label */
33
+ note: string
34
+ }
35
+
36
+ /** a word of the card he may click into his text, and where it comes from */
37
+ export type Chip = { from: 'post' | 'card' | 'view' | 'his' | 'agent'; text: string }
38
+
39
+ const isClip = (f: string): boolean => /\.(mp4|webm)$/i.test(f)
40
+
41
+ /** every media of one version a post may carry, `n` its version number */
42
+ export function stageablesOf(i: Item, n: number): Stageable[] {
43
+ const out: Stageable[] = []
44
+ i.views.forEach((v, k) => {
45
+ const tag = `${n}.${viewLetter(k)}`
46
+ const name = viewName(v, k)
47
+ if (isGallery(v)) {
48
+ v.gallery.forEach((t, j) => out.push({ key: `${i.id}#${k}/${j}`, item: i.id, view: k, tile: j, label: `${tag} ${t.group ? `${t.group}/` : ''}${t.label}`, kind: 'image', file: t.file, ratio: t.size.w / Math.max(1, t.size.h), note: t.label }))
49
+ return
50
+ }
51
+ if (v.audio) return
52
+ const ratio = v.size.w / Math.max(1, v.size.h)
53
+ const note = v.note ?? (v.label || i.title)
54
+ const f = v.files
55
+ if (isPair(f)) {
56
+ const clip = isClip(f.after)
57
+ out.push({ key: `${i.id}#${k}.after`, item: i.id, view: k, side: 'after', label: `${tag} ${name} after`, kind: clip ? 'clip' : 'image', file: f.after, ratio, note })
58
+ out.push({ key: `${i.id}#${k}.before`, item: i.id, view: k, side: 'before', label: `${tag} ${name} before`, kind: clip ? 'clip' : 'image', file: f.before, ratio, note })
59
+ // a wipe is drawn from two images (the anim cache); two clips have none
60
+ if (!clip) out.push({ key: `${i.id}#${k}.wipe`, item: i.id, view: k, side: 'wipe', label: `${tag} ${name} wipe`, kind: 'clip', file: f.after, ratio, note })
61
+ return
62
+ }
63
+ const file = 'image' in f ? f.image : 'video' in f ? f.video : ''
64
+ if (file !== '') out.push({ key: `${i.id}#${k}`, item: i.id, view: k, label: `${tag} ${name}`, kind: isClip(file) ? 'clip' : 'image', file, ratio, note })
65
+ })
66
+ return out
67
+ }
68
+
69
+ /** every media of a thread's versions, the newest version first; the versions oldest first is `versions` reversed */
70
+ export const stageablesOfThread = (versions: readonly ReviewItem[]): Stageable[] => versions.flatMap((x, k) => stageablesOf(x.item, versions.length - k))
71
+
72
+ /** markdown read as plain words, one chip a line or a sentence */
73
+ function linesOf(md: string): string[] {
74
+ const plain = md
75
+ .replace(/```[\s\S]*?```/g, '')
76
+ .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
77
+ .replace(/[*_`]+/g, '')
78
+ .replace(/^#+\s*/gm, '')
79
+ return plain
80
+ .split('\n')
81
+ .map((l) => l.replace(/^\s*(?:[-+*]|\d+\.)\s+/, '').trim())
82
+ .flatMap((l) => l.split(/(?<=[.!?])\s+(?=[A-Z])/))
83
+ .map((l) => l.trim())
84
+ .filter((l) => l.length >= 3 && l.length <= 400)
85
+ }
86
+
87
+ /** the words of a thread he may pick from, each once, the card's own post line first */
88
+ export function chipsOf(versions: readonly ReviewItem[]): Chip[] {
89
+ const out: Chip[] = []
90
+ const seen = new Set<string>()
91
+ const add = (from: Chip['from'], text: string | undefined): void => {
92
+ const t = text?.trim() ?? ''
93
+ if (t === '' || seen.has(t)) return
94
+ seen.add(t)
95
+ out.push({ from, text: t })
96
+ }
97
+ for (const x of versions) add('post', x.item.post)
98
+ for (const x of versions) {
99
+ add('card', x.item.title)
100
+ for (const l of linesOf(x.item.what ?? '')) add('card', l)
101
+ x.item.views.forEach((v, k) => {
102
+ add('view', v.label || undefined)
103
+ if (!isGallery(v)) add('view', v.note)
104
+ void k
105
+ })
106
+ }
107
+ for (const x of versions)
108
+ for (const m of x.thread) {
109
+ if (m.op !== undefined && m.op !== 'ask' && m.op !== 'answer') continue
110
+ const owner = partyOf(m.who) === 'owner'
111
+ if (owner) {
112
+ if (m.verdict === undefined || isApproved(m.verdict)) add('his', m.text)
113
+ for (const r of m.reactions ?? []) add('his', r.comment)
114
+ for (const r of m.rects ?? []) add('his', r.comment)
115
+ } else if (isReply(m)) add('agent', m.text)
116
+ }
117
+ return out
118
+ }
119
+
120
+ /** what he asks of the stage: the pick (a key `stageablesOf` gives; unset, the newest version's first media), his
121
+ * text, the rating, and where else it goes */
122
+ export type StageAsk = {
123
+ pick?: string
124
+ text: string
125
+ rating: PostRating
126
+ /** what the post is for (wiki guides/post-kinds/index.md); unset, a card's `iteration` */
127
+ kind?: string
128
+ /** a `custom` kind's one line on why no kind fits */
129
+ kindWhy?: string
130
+ alt?: string
131
+ slot?: string
132
+ tags?: string
133
+ /** a channel he picked on an account (Discord) over its default: that account gets its own heading */
134
+ place?: { account: string; place: string }
135
+ /** an agent rewrites it in the identity's voice: the draft note raised to the social topic */
136
+ polish?: boolean
137
+ /** a clip's passage, his in and out in seconds */
138
+ passage?: { from: number; to: number }
139
+ /** one copy within the tightest limits of the venues it reaches */
140
+ fit?: boolean
141
+ }
142
+
143
+ const slugWords = (s: string): string => wordsOf(s).join('-').slice(0, 40).replace(/-+$/, '') || 'post'
144
+
145
+ /** the thread a card id belongs to, its versions head first */
146
+ function versionsOf(dir: string, id: string): ReviewItem[] {
147
+ const t = threadOfId(id, threadsOf(readAll(dir).items))
148
+ if (t == null) throw new Error(`no card ${id}`)
149
+ if (t.head.item.origin.by !== 'agent') throw new Error(`${id} is no agent's card: only a card's media is staged`)
150
+ return t.versions
151
+ }
152
+
153
+ /** the stage of one card: its media, its words, the drafts already made from it */
154
+ export function stageOfCard(dir: string, id: string): { head: string; first: string; title: string; media: Stageable[]; words: Chip[] } {
155
+ const versions = versionsOf(dir, id)
156
+ const head = versions[0]!.item
157
+ return { head: head.id, first: versions.at(-1)!.item.id, title: head.title, media: stageablesOfThread(versions), words: chipsOf(versions) }
158
+ }
159
+
160
+ /** the owner's ask made a stage input: the pick resolved to a local file, its copy's name, the draft's angle and headings */
161
+ export async function stageInputOf(dir: string, id: string, ask: StageAsk, font?: string): Promise<{ input: StageInput; pick: Stageable | null }> {
162
+ const s = stageOfCard(dir, id)
163
+ const pick = ask.pick === undefined ? (s.media[0] ?? null) : (s.media.find((m) => m.key === ask.pick) ?? null)
164
+ if (ask.pick !== undefined && pick == null) throw new Error(`the card names no media ${ask.pick} (${s.media.map((m) => m.key).join(', ') || 'none'})`)
165
+ const whole = pick ? await stageFileOf(dir, pick, font) : null
166
+ if (ask.passage && pick?.kind !== 'clip') throw new Error('a passage is cut from a clip')
167
+ const file = whole && ask.passage ? cutPassage(whole, ask.passage.from, ask.passage.to) : whole
168
+ const tag = pick ? pick.label.split(' ')[0]!.replace('.', '').toLowerCase() : ''
169
+ const name = pick ? `${slugWords(s.title)}-${tag}${pick.side && pick.side !== 'after' ? `-${pick.side}` : pick.tile !== undefined ? `-${pick.tile + 1}` : ''}` : ''
170
+ const input: StageInput = {
171
+ source: { review: s.first },
172
+ title: s.title,
173
+ text: ask.text,
174
+ media: pick && file ? { file, name, vertical: pick.kind === 'clip' && pick.ratio < 0.6 } : null,
175
+ ...(ask.alt !== undefined ? { alt: ask.alt } : {}),
176
+ rating: ask.rating,
177
+ ...(ask.kind ? { kind: ask.kind } : {}),
178
+ ...(ask.kindWhy ? { kindWhy: ask.kindWhy } : {}),
179
+ ...(ask.slot ? { slot: ask.slot } : {}),
180
+ ...(ask.tags ? { tags: ask.tags } : {}),
181
+ angle: `Staged from the card « ${s.title} » (${s.head})${pick ? `, ${pick.label}` : ''}${ask.passage ? `, ${ask.passage.from.toFixed(2)} s to ${ask.passage.to.toFixed(2)} s` : ''}.`,
182
+ headings: [{ id: 'short' }, ...(ask.place ? [{ id: ask.place.account, place: ask.place.place }] : [])],
183
+ }
184
+ return { input, pick }
185
+ }
186
+
187
+ /** the local file a pick stands for: the store's own, fetched back from the Space when the disk let it go; a wipe
188
+ * drawn once into the anim cache */
189
+ export async function stageFileOf(dir: string, s: Stageable, font?: string): Promise<string> {
190
+ if (s.side === 'wipe') {
191
+ const a = await pairAnimation(dir, s.item, { view: s.view, mode: 'wipe', format: 'mp4', labels: 'none', ...(font ? { font } : {}) })
192
+ return a.file
193
+ }
194
+ const f = await ensureLocal(dir, s.item, s.file)
195
+ if (f == null) throw new Error(`${s.item}/${s.file}: neither the disk nor the Space holds it`)
196
+ return f
197
+ }