rvlib-shipkit 2.23.0 → 2.25.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 (150) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/package.json +1 -1
  3. package/src/agent-time/live.ts +153 -0
  4. package/src/agent-time/render.ts +28 -14
  5. package/src/agent-time/report.ts +46 -25
  6. package/src/agent-time/store.ts +30 -10
  7. package/src/agent-time/timeline.ts +43 -15
  8. package/src/annex/offload.ts +16 -7
  9. package/src/asks/asks-queue.ts +32 -11
  10. package/src/check.ts +3 -1
  11. package/src/checks/SK004-gitignore-policy.check.ts +32 -11
  12. package/src/checks/SK027-agent-wiki-links.check.ts +1 -1
  13. package/src/checks/SK033-global-contribution.check.ts +1 -1
  14. package/src/checks/SK036-draft-media-size.check.ts +1 -1
  15. package/src/checks/SK040-release-words.check.ts +1 -1
  16. package/src/checks/SK042-post-kinds.check.ts +1 -1
  17. package/src/checks/SK044-behind-upstream.check.ts +38 -0
  18. package/src/cli/cmd_Annex.ts +12 -7
  19. package/src/cli/cmd_Asks.ts +2 -0
  20. package/src/cli/cmd_Assets.ts +5 -5
  21. package/src/cli/cmd_Backup.ts +16 -8
  22. package/src/cli/cmd_Bump.ts +1 -0
  23. package/src/cli/cmd_Capacity.ts +30 -0
  24. package/src/cli/cmd_Check.ts +1 -0
  25. package/src/cli/cmd_Checks.ts +13 -1
  26. package/src/cli/cmd_Ci.ts +3 -2
  27. package/src/cli/cmd_Commands.ts +61 -16
  28. package/src/cli/cmd_ConfigKeys.ts +17 -0
  29. package/src/cli/cmd_Home.ts +1 -30
  30. package/src/cli/cmd_Hooks.ts +1 -0
  31. package/src/cli/cmd_Keys.ts +4 -1
  32. package/src/cli/cmd_Lanes.ts +35 -0
  33. package/src/cli/cmd_Mv.ts +7 -7
  34. package/src/cli/cmd_Rec.ts +22 -7
  35. package/src/cli/cmd_Reflect.ts +1 -0
  36. package/src/cli/cmd_Releases.ts +1 -0
  37. package/src/cli/cmd_Review.ts +200 -49
  38. package/src/cli/cmd_Secret.ts +41 -2
  39. package/src/cli/cmd_Shot.ts +16 -4
  40. package/src/cli/cmd_Status.ts +7 -5
  41. package/src/cli/cmd_Time.ts +13 -5
  42. package/src/cli/cmd_Tmp.ts +82 -0
  43. package/src/cli/cmd_Veille.ts +10 -6
  44. package/src/cli/cmd_Wiki.ts +1 -0
  45. package/src/cli/family-help.ts +136 -0
  46. package/src/cli/family-pages.ts +0 -19
  47. package/src/cli/kit/calls.ts +35 -0
  48. package/src/cli/kit/project-cli.ts +2 -12
  49. package/src/cli/registry.ts +52 -7
  50. package/src/cli.ts +8 -4
  51. package/src/collections/pings.ts +1 -1
  52. package/src/core/capacity.ts +127 -0
  53. package/src/core/check-runner.ts +91 -16
  54. package/src/core/floor-resolve.ts +6 -2
  55. package/src/core/floor.ts +6 -2
  56. package/src/core/history-files.ts +18 -0
  57. package/src/core/jobs.ts +35 -16
  58. package/src/core/layout.ts +2 -2
  59. package/src/core/motherhome.ts +67 -9
  60. package/src/core/nearest.ts +16 -0
  61. package/src/core/remove-tree.ts +19 -0
  62. package/src/core/runs.ts +12 -3
  63. package/src/core/slots.ts +49 -12
  64. package/src/core/throwaway-worktree.ts +22 -4
  65. package/src/core/trace-audit.ts +21 -5
  66. package/src/drill/run.ts +5 -2
  67. package/src/home/daemon-jobs.ts +41 -4
  68. package/src/home/gui-app/ShipkitGui.swift +1 -0
  69. package/src/home/home-launchd.ts +11 -3
  70. package/src/home/home-routes.ts +11 -4
  71. package/src/home/machine-host.ts +65 -0
  72. package/src/home/machine-stores.ts +19 -17
  73. package/src/home/machine-temp.ts +485 -0
  74. package/src/home/other-macs.ts +74 -0
  75. package/src/home/run-daemon.ts +10 -2
  76. package/src/home/serve-web.ts +2 -2
  77. package/src/home/via-hub.ts +6 -1
  78. package/src/init-repo.ts +7 -3
  79. package/src/ledger/gate-checks.ts +3 -2
  80. package/src/ledger/git-key.ts +25 -4
  81. package/src/ledger/git-scan.ts +10 -0
  82. package/src/ledger/ledger.ts +6 -0
  83. package/src/ledger/store.ts +6 -0
  84. package/src/media-store/backup/daemon.ts +92 -20
  85. package/src/media-store/backup/keys.ts +21 -6
  86. package/src/media-store/backup/manifest.ts +52 -11
  87. package/src/media-store/backup/restore.ts +17 -10
  88. package/src/media-store/backup/run.ts +26 -17
  89. package/src/media-store/backup/sources.ts +168 -22
  90. package/src/media-store/backup/watch.ts +106 -0
  91. package/src/media-store/daemon.ts +36 -8
  92. package/src/media-store/hand.ts +3 -1
  93. package/src/mv/mv-md.ts +167 -56
  94. package/src/pb/run-pb.ts +2 -10
  95. package/src/plan/repo-source.ts +25 -14
  96. package/src/recordings/model.ts +1 -1
  97. package/src/reflect/transcript.ts +56 -11
  98. package/src/release/run-bump.ts +3 -2
  99. package/src/release/run-release.ts +12 -4
  100. package/src/releases/from-card.ts +45 -3
  101. package/src/releases/model.ts +6 -0
  102. package/src/releases/store.ts +8 -1
  103. package/src/repo-config.ts +5 -3
  104. package/src/review/cells.ts +26 -4
  105. package/src/review/format.ts +34 -10
  106. package/src/review/media-kind.ts +14 -11
  107. package/src/review/media-read.ts +6 -5
  108. package/src/review/model.ts +85 -4
  109. package/src/review/paste.ts +2 -1
  110. package/src/review/previews.ts +123 -36
  111. package/src/review/routes.ts +29 -18
  112. package/src/review/store.ts +89 -19
  113. package/src/review/threads.ts +7 -5
  114. package/src/review/trailer-model.ts +2 -2
  115. package/src/secrets/copy.ts +110 -0
  116. package/src/secrets/list.ts +17 -7
  117. package/src/serve/hub-app/home-strip.css +5 -0
  118. package/src/serve/hub-app/home-strip.tsx +18 -0
  119. package/src/serve/hub-app/hub-app.tsx +2 -1
  120. package/src/serve/hub-app/hub.css +14 -0
  121. package/src/serve/hub-app/inbox.css +1 -0
  122. package/src/serve/hub-app/pull-refresh.tsx +88 -0
  123. package/src/serve/hub-app/review/review-cells.tsx +52 -13
  124. package/src/serve/hub-app/review/review-list.tsx +6 -1
  125. package/src/serve/hub-app/review/review-st.ts +6 -5
  126. package/src/serve/hub-app/review/review-thread.tsx +3 -1
  127. package/src/serve/hub-app/review/review-views.tsx +18 -11
  128. package/src/serve/hub-app/review/thread-st.ts +82 -14
  129. package/src/serve/hub-app/review.css +15 -2
  130. package/src/serve/hub-runtime.ts +2 -1
  131. package/src/serve/run-serve.ts +4 -2
  132. package/src/serve/serve-hub.ts +9 -2
  133. package/src/shot/client.ts +4 -2
  134. package/src/shot/serve-shot.ts +71 -2
  135. package/src/shot/shooter.ts +65 -11
  136. package/src/shot/shot-ask.ts +32 -9
  137. package/src/suite/child-tools.ts +45 -0
  138. package/src/suite/judge-suites.ts +10 -22
  139. package/src/suite/select.ts +95 -9
  140. package/src/suite/suite-cli.ts +38 -14
  141. package/src/suite/suite-cores.ts +68 -0
  142. package/src/suite/suite-reads-preload.ts +8 -6
  143. package/src/suite/test-units.ts +31 -12
  144. package/src/trailer/graph.ts +2 -1
  145. package/src/ts/config.ts +21 -0
  146. package/src/ts/rename.ts +37 -13
  147. package/src/ts/workspaces.ts +45 -0
  148. package/src/wiki/run-wiki.ts +7 -2
  149. package/src/wiki/scan-md.ts +2 -1
  150. package/src/home/claude-temp.ts +0 -139
@@ -18,13 +18,23 @@ interface Here {
18
18
  err: (l: string) => void
19
19
  }
20
20
 
21
+ /** the shipkit repo the cwd stands in: only its store reaches a hub, so anywhere else a card is refused before a
22
+ * stray .shipkit/review/ is made where nobody looks */
23
+ async function reviewRoot(cwd: string): Promise<string | null> {
24
+ const { findRepoRoot } = await import('../ts/config.ts')
25
+ const { existsSync } = await import('node:fs')
26
+ const { join } = await import('node:path')
27
+ const root = findRepoRoot(cwd)
28
+ return existsSync(join(root, 'repo.config.ts')) ? root : null
29
+ }
30
+
21
31
  /** the store of the repo this runs in, its unit read when the verb needs it, and the body; a refusal is one FAIL line with its reason, exit 1 */
22
32
  async function run(context: Ctx, body: (h: Here) => Promise<number> | number, o: { unit?: boolean } = {}): Promise<number> {
23
- const { findRepoRoot } = await import('../ts/config.ts')
24
33
  const out = (l: string): void => void context.stdout.write(`${l}\n`)
25
34
  const err = (l: string): void => void context.stderr.write(`${l}\n`)
26
35
  try {
27
- const root = findRepoRoot(process.cwd())
36
+ const root = await reviewRoot(process.cwd())
37
+ if (root == null) throw new Error(`${process.cwd()} is in no shipkit repo (no repo.config.ts at its git root), so no hub would ever show what is stored here: run it from inside the repo the card is for`)
28
38
  if (o.unit === false) {
29
39
  const { storeDir } = await import('../review/store.ts')
30
40
  return await body({ dir: storeDir(root), unit: null, say: { spec: (await import('../review/model.ts')).NO_SPEC, more: () => [] }, out, err })
@@ -125,6 +135,61 @@ export function takeViews(args: readonly string[]): { views: ViewInput[]; rest:
125
135
  return { views, rest }
126
136
  }
127
137
 
138
+ const ADD_VIEW_USAGE = 'add-view <id> "<label>" <a.png> [<b.png>] | --image <a.png> | --before <a.png> --after <b.png> | --video <clip> | --audio <sound> | --gallery <a.png> … [--label "<label>"] [--note "<text>"]'
139
+ const MEDIA_FILE = /\.(png|jpe?g|webp|gif|mp4|webm|mov|wav|mp3|flac|ogg|opus|m4a)$/i
140
+ const quoted = (a: string): string => (/^[\w./=,@:+-]+$/.test(a) ? a : `"${a.replace(/"/g, '\\"')}"`)
141
+
142
+ /** add-view's args: the positional form, or the view flags of add; a flag is never a label, `own` are the repo unit's flags */
143
+ export async function addViewArgs(args: readonly string[], own: readonly string[]): Promise<{ id: string; view: ViewInput; repoFlags: Record<string, string[]> }> {
144
+ const one: Record<string, string> = {}
145
+ const repoFlags: Record<string, string[]> = {}
146
+ const words: string[] = []
147
+ let gallery: string[] | null = null
148
+ for (let i = 0; i < args.length; i++) {
149
+ const a = args[i] ?? ''
150
+ if (!a.startsWith('--')) {
151
+ ;(gallery ?? words).push(a)
152
+ continue
153
+ }
154
+ const name = a.slice(2)
155
+ if (name === 'gallery') {
156
+ gallery = []
157
+ continue
158
+ }
159
+ if (name === 'what') throw new Error(`--what: a view takes no --what, a line on it is --note "<text>"; ${ADD_VIEW_USAGE}`)
160
+ if (!['label', 'note', 'image', 'video', 'audio', 'before', 'after', ...own].includes(name)) throw new Error(`${a}: add-view takes no such flag; ${ADD_VIEW_USAGE}`)
161
+ const v = args[i + 1]
162
+ if (v === undefined || v.startsWith('--')) throw new Error(`${a} needs its value; ${ADD_VIEW_USAGE}`)
163
+ i++
164
+ if (own.includes(name)) (repoFlags[name] ??= []).push(v)
165
+ else one[name] = v
166
+ }
167
+ const [id, ...rest] = words
168
+ if (!id) throw new Error(ADD_VIEW_USAGE)
169
+ let label = one.label
170
+ let files = rest
171
+ if (label === undefined && rest[0] !== undefined && !MEDIA_FILE.test(rest[0])) [label, ...files] = rest
172
+ if (label === undefined && gallery?.[0] !== undefined && !MEDIA_FILE.test(gallery[0]) && !gallery[0].includes('=')) label = gallery.shift()
173
+ const given = [files.length > 0 ? 'files' : '', one.image ? '--image' : '', one.video ? '--video' : '', one.audio ? '--audio' : '', one.before || one.after ? '--before --after' : '', gallery ? '--gallery' : ''].filter((x) => x !== '')
174
+ if (given.length !== 1) throw new Error(`${given.length === 0 ? 'no media' : `one media a view, not ${given.join(' and ')}`}; ${ADD_VIEW_USAGE}`)
175
+ if (!label?.trim()) throw new Error(`the view needs its label: sk review ${['add-view', id, '"<label>"', ...args.filter((a) => a !== id).map(quoted)].join(' ')}`)
176
+ if ((one.before === undefined) !== (one.after === undefined)) throw new Error(`--before and --after go together; ${ADD_VIEW_USAGE}`)
177
+ if (gallery?.length === 0) throw new Error(`--gallery needs its images; ${ADD_VIEW_USAGE}`)
178
+ const view: ViewInput = one.image
179
+ ? { label, image: one.image }
180
+ : one.video
181
+ ? { label, video: one.video }
182
+ : one.audio
183
+ ? { label, audio: one.audio }
184
+ : one.before && one.after
185
+ ? { label, before: one.before, after: one.after }
186
+ : gallery
187
+ ? { label, gallery: gallery.map(tileOf) }
188
+ : (await import('../review/store.ts')).filesView(label, files, `${files.length} files: one image, or a before and an after; ${ADD_VIEW_USAGE}`)
189
+ if (one.note !== undefined) view.note = one.note
190
+ return { id, view, repoFlags }
191
+ }
192
+
128
193
  /** the flags of `add`, parsed by name: a value flag repeats where it says so */
129
194
  function flagsOf(args: readonly string[], values: readonly string[], repeat: readonly string[], bools: readonly string[]): { one: Record<string, string>; many: Record<string, string[]>; on: Set<string>; positionals: string[] } {
130
195
  const one: Record<string, string> = {}
@@ -153,7 +218,7 @@ function flagsOf(args: readonly string[], values: readonly string[], repeat: rea
153
218
  }
154
219
 
155
220
  const ADD_FLAGS = `flags:
156
- --title "<title>" one short line: what he looks at
221
+ --title "<title>" one short line: what he looks at (a lone "<title>" after add is the same)
157
222
  --what "<what>" what changed and why, short markdown: one line, then - bullets
158
223
  --post "<line>" the public line for a post of it, what a user gets (the repo's guard reads it)
159
224
  --changelog "<category>: <line>" its change in the release being filled: on his approval it lands in .shipkit/releases/next.md with the card's after picture (the repo's guard reads it)
@@ -175,6 +240,7 @@ const ADD_FLAGS = `flags:
175
240
  --subject <kind> what is judged (default shot; the repo's unit names its kinds)
176
241
  --commit <sha> the commit it shows
177
242
  --lane <id> the lane that made it; else SK_AGENT
243
+ --wip "<what is still wrong>" a card sent in work: « in progress », no verdict asked; each step after: sk review update <id> <broken|better|fixed> "<line>" <file>
178
244
  --supersedes <id> the card it follows up, after his answer
179
245
  --answers <id | live#3> the item it answers (a note he raised, a player's report), one thread (repeat it)
180
246
  --keeps "<what stays>" with --supersedes on an approved look: what of it stays
@@ -184,6 +250,10 @@ const ADD_FLAGS = `flags:
184
250
  * `--subject <kind>`); a repo with no unit, or one that does not load, says so on one line */
185
251
  async function helpWithUnit(context: Ctx, usage: string, kinds: boolean): Promise<number> {
186
252
  context.stdout.write(usage)
253
+ if ((await reviewRoot(process.cwd())) == null) {
254
+ context.stdout.write("\nno shipkit repo here, so no review unit adds flags\n")
255
+ return 0
256
+ }
187
257
  await run(context, (h) => {
188
258
  const lines = Object.entries(h.unit?.flags ?? {}).map(([k, d]) => ` --${k} ${d}`)
189
259
  if (kinds) for (const [name, k] of Object.entries(h.unit?.kinds ?? {})) for (const [f, d] of Object.entries(k.flags ?? {})) lines.push(` --${f} ${d} (with --subject ${name})`)
@@ -222,6 +292,7 @@ export async function trailerOfFlags(o: Record<string, string>, others: boolean)
222
292
 
223
293
  export class ReviewAddCommand extends Command {
224
294
  static override paths = [['review', 'add']]
295
+ static essential = {}
225
296
  static override usage = Command.Usage({
226
297
  category: 'Review',
227
298
  description: 'show the owner a change as one card he answers in the hub: an image, a clip, a pair, views',
@@ -242,19 +313,27 @@ export class ReviewAddCommand extends Command {
242
313
  return helpWithUnit(this.context, this.cli.usage(ReviewAddCommand, { detailed: true }), true)
243
314
  }
244
315
  return run(this.context, async (h) => {
245
- const { addItem } = await import('../review/store.ts')
246
- const { views, rest } = takeViews(this.args)
316
+ const { addItem, postUpdate, agentName } = await import('../review/store.ts')
317
+ // `--wip "<what is still wrong>"`: a card sent in work, its first update still broken; a bare --wip goes with --live
318
+ const w = this.args.indexOf('--wip')
319
+ const wipLine = w >= 0 && this.args[w + 1] !== undefined && !this.args[w + 1]!.startsWith('--') ? this.args[w + 1] : undefined
320
+ const { views, rest } = takeViews(wipLine === undefined ? this.args : [...this.args.slice(0, w + 1), ...this.args.slice(w + 2)])
247
321
  // the repo's own flags: the subject kind's (--where), and the unit's for any kind (--mark), each repeatable
248
322
  const kindName = rest[rest.indexOf('--subject') + 1]
249
323
  const kind = rest.includes('--subject') && kindName ? h.unit?.kinds?.[kindName] : undefined
250
324
  const own = [...Object.keys(kind?.flags ?? {}), ...Object.keys(h.unit?.flags ?? {})]
251
325
  const f = flagsOf(rest, ['title', 'what', 'post', 'changelog', 'rating', 'image', 'video', 'audio', 'before', 'after', 'label', 'topic', 'subject', 'commit', 'lane', 'supersedes', 'keeps', 'why', 'live', 'trailer', 'version', 'shots', 'pick'], ['answers', ...own], ['new', 'wip', 'choice'])
252
- if (f.positionals.length > 0) throw new Error(`unexpected ${f.positionals.join(' ')}`)
253
326
  const o = f.one
327
+ // a lone word is the title, as `sk ask <title>` takes it; a media file never is
328
+ const [lone, ...more] = f.positionals
329
+ if (lone !== undefined && more.length === 0 && o.title === undefined && !MEDIA_FILE.test(lone)) o.title = lone
330
+ else if (lone !== undefined) throw new Error(`unexpected ${f.positionals.map(quoted).join(' ')}: the title is --title "<title>", the subject --image <a.png> (sk review add --help)`)
254
331
  const trailer = await trailerOfFlags(o, views.length > 0 || f.on.has('wip') || f.on.has('choice'))
255
332
  const repoFlags = Object.fromEntries(own.flatMap((k) => (f.many[k] ? [[k, f.many[k]]] : [])))
256
333
  const parsed = kind?.parse ? kind.parse(Object.fromEntries(Object.keys(kind.flags ?? {}).map((k) => [k, f.many[k] ?? []]))) : null
257
- if (f.on.has('wip') !== (o.live !== undefined)) throw new Error('--wip --live <name>: a draft card names its live shot, and a live shot makes a draft card')
334
+ if (wipLine !== undefined && o.live !== undefined) throw new Error('--wip "<line>" sends a card in work; --wip --live <name> a draft on a live shot: one of the two')
335
+ if (wipLine === undefined && f.on.has('wip') !== (o.live !== undefined))
336
+ throw new Error('--wip "<what is still wrong>" sends a card in work (sk review update as it moves); --wip --live <name> a draft on a live shot')
258
337
  let wipViews: ViewInput[] = []
259
338
  if (o.live !== undefined) {
260
339
  if (!h.unit?.live) throw new Error("--live: the repo's review unit declares no live shots (live: { frames })")
@@ -319,6 +398,13 @@ export class ReviewAddCommand extends Command {
319
398
  if (h.unit?.add) input = await h.unit.add(input, repoFlags)
320
399
  const item = await addItem(h.dir, input).finally(() => trailer?.drop())
321
400
  h.out(item.id)
401
+ if (wipLine !== undefined) {
402
+ const who = item.origin.by === 'agent' ? (item.origin.lane ?? agentName()) : agentName()
403
+ await postUpdate(h.dir, item.id, { who, state: 'broken', text: wipLine })
404
+ h.err(`in progress: he sees it, it waits on no verdict; post each step with sk review update ${item.id} <broken|better|fixed> "<line>" <file>`)
405
+ }
406
+ // on stderr: a script reads the id alone on stdout
407
+ for (const line of await (await import('../review/previews.ts')).playCopies(h.dir, item)) h.err(line)
322
408
  if (item.trailer) h.out(`trailer card: ${item.trailer.trailer}/${item.trailer.after.cut}${item.trailer.before ? ` against ${item.trailer.before.cut}` : ''}${item.trailer.shots.length > 0 ? `, shots ${item.trailer.shots.join(', ')}` : ''}`)
323
409
  if (item.origin.by === 'agent' && !item.origin.lane) h.err('no lane on the card: pass --lane <id> (or SK_AGENT), so the hub colours it')
324
410
  if (item.choice && item.agentPick === undefined) h.err(`a choice with no pick of yours: every question carries one, sk review pick ${item.id} <view> (or --pick on add)`)
@@ -333,11 +419,15 @@ export class ReviewAddCommand extends Command {
333
419
 
334
420
  export class ReviewAddViewCommand extends Command {
335
421
  static override paths = [['review', 'add-view']]
422
+ static essential = {}
336
423
  static override usage = Command.Usage({
337
424
  category: 'Review',
338
425
  description: 'another angle on a card he has not answered yet: an image, a pair, a clip or a gallery',
339
- details: `${DETAILS}\n\nsk review add-view <id> "<label>" <a.png> [<b.png>] | --video <clip.mp4> | --audio <sound.wav> | --gallery <a.png> <b.png> … [--note "<a line on that view>"]`,
340
- examples: [['a view from above', 'sk review add-view <id> "from above" top.png']],
426
+ details: `${DETAILS}\n\nsk ${ADD_VIEW_USAGE}. The view flags are add's; the id may be its moment alone (<YYYYMMDD-HHMMSS>).`,
427
+ examples: [
428
+ ['a view from above', 'sk review add-view <id> "from above" top.png'],
429
+ ['a before and after', 'sk review add-view <id> --label "on a phone" --before a.png --after b.png'],
430
+ ],
341
431
  })
342
432
  args = Option.Proxy()
343
433
 
@@ -347,39 +437,14 @@ export class ReviewAddViewCommand extends Command {
347
437
  }
348
438
  return run(this.context, async (h) => {
349
439
  const { addView } = await import('../review/store.ts')
350
- const own = Object.keys(h.unit?.flags ?? {})
351
- const repoFlags: Record<string, string[]> = {}
352
- const args: string[] = []
353
- let note: string | undefined
354
- for (let i = 0; i < this.args.length; i++) {
355
- const a = this.args[i] ?? ''
356
- const name = a.startsWith('--') ? a.slice(2) : ''
357
- if (own.includes(name)) (repoFlags[name] ??= []).push(this.args[++i] ?? '')
358
- else if (name === 'note') note = this.args[++i]
359
- else args.push(a)
360
- }
361
- if (this.args.includes('--note') && (note === undefined || note.startsWith('--'))) throw new Error('--note "<text>": a line on that view')
362
- const [id, label, ...rest] = args
363
- if (!id || !label) throw new Error('add-view <id> "<label>" <media>')
364
- const v: ViewInput =
365
- rest[0] === '--video' && rest[1]
366
- ? { label, video: rest[1] }
367
- : rest[0] === '--audio' && rest[1]
368
- ? { label, audio: rest[1] }
369
- : rest[0] === '--gallery'
370
- ? { label, gallery: rest.slice(1).map(tileOf) }
371
- : rest.length === 1
372
- ? { label, image: rest[0] }
373
- : rest.length === 2
374
- ? { label, before: rest[0], after: rest[1] }
375
- : (() => {
376
- throw new Error('add-view <id> "<label>" <a.png> [<b.png>] | --video <clip> | --gallery <a.png> …')
377
- })()
378
- if (note !== undefined) v.note = note
379
- const extra = h.unit?.addView ? await h.unit.addView(v, repoFlags) : {}
440
+ const a = await addViewArgs(this.args, Object.keys(h.unit?.flags ?? {}))
441
+ const v = a.view
442
+ const id = await idOf(h.dir, a.id)
443
+ const extra = h.unit?.addView ? await h.unit.addView(v, a.repoFlags) : {}
380
444
  const item = await addView(h.dir, id, v, extra)
381
445
  const { viewLetter } = await import('../review/model.ts')
382
- h.out(`${id}: view ${viewLetter(item.views.length - 1)} "${label}" added`)
446
+ h.out(`${id}: view ${viewLetter(item.views.length - 1)} "${v.label}" added`)
447
+ for (const line of await (await import('../review/previews.ts')).playCopies(h.dir, item, item.views.length - 1)) h.err(line)
383
448
  return 0
384
449
  })
385
450
  }
@@ -406,7 +471,12 @@ export class ReviewLsCommand extends Command {
406
471
  return run(this.context, async (h) => {
407
472
  const verbs = h.unit?.verbs ?? {}
408
473
  const v = verbs[verb]
409
- if (!v) throw new Error(`no verb « ${verb} »: sk review --help lists sk's own; the repo's unit declares ${Object.keys(verbs).join(', ') || 'none'}`)
474
+ if (!v) {
475
+ const { typoOf } = await import('./family-help.ts')
476
+ const own = this.cli.definitions().map((d) => d.path.split(' ')).filter((w) => w[1] === 'review' && w.length === 3).map((w) => w[2]!)
477
+ const close = typoOf(verb, [...own, ...Object.keys(verbs)], 2)
478
+ throw new Error(`no verb « ${verb} »: ${close.length > 0 ? `did you mean ${close.map((c) => `sk review ${c}`).join(', ')} ? ` : ''}sk review --help lists sk's own; the repo's unit declares ${Object.keys(verbs).join(', ') || 'none'}`)
479
+ }
410
480
  const { dirname } = await import('node:path')
411
481
  return v.run(rest, { dir: h.dir, root: dirname(dirname(h.dir)), say: h.out, err: h.err })
412
482
  })
@@ -435,6 +505,7 @@ export class ReviewLsCommand extends Command {
435
505
 
436
506
  export class ReviewShowCommand extends Command {
437
507
  static override paths = [['review', 'show']]
508
+ static essential = { args: '<id>' }
438
509
  static override usage = Command.Usage({
439
510
  category: 'Review',
440
511
  description: 'one item and its thread: the verdict, rectangles, reactions, the whole conversation',
@@ -485,6 +556,7 @@ async function sessionOf(mine: boolean, session: string | undefined): Promise<st
485
556
 
486
557
  export class ReviewInboxCommand extends Command {
487
558
  static override paths = [['review', 'inbox']]
559
+ static essential = {}
488
560
  static override usage = Command.Usage({
489
561
  category: 'Review',
490
562
  description: 'every answer not marked seen and every open item he raised, frame notes included',
@@ -565,6 +637,7 @@ async function answererRefusal(dir: string, id: string, as: string | undefined,
565
637
 
566
638
  export class ReviewSeenCommand extends Command {
567
639
  static override paths = [['review', 'seen']]
640
+ static essential = { args: '<ids>' }
568
641
  static override usage = Command.Usage({ category: 'Review', description: 'mark his answers and replies on these items read, once you acted on them', details: DETAILS })
569
642
  ids = Option.Rest({ required: 1 })
570
643
  as = Option.String('--as', { description: 'the lane that read it (else SK_AGENT)' })
@@ -592,6 +665,7 @@ export class ReviewSeenCommand extends Command {
592
665
 
593
666
  export class ReviewReplyCommand extends Command {
594
667
  static override paths = [['review', 'reply']]
668
+ static essential = { args: '<id> <text>' }
595
669
  static override usage = Command.Usage({ category: 'Review', description: "your message on a card's thread: what you changed, the answer to his question", details: DETAILS })
596
670
  id = Option.String()
597
671
  text = Option.String()
@@ -611,17 +685,67 @@ export class ReviewReplyCommand extends Command {
611
685
  }
612
686
  }
613
687
 
688
+ export class ReviewUpdateCommand extends Command {
689
+ static override paths = [['review', 'update']]
690
+ static essential = { args: '<id> <state> <text>' }
691
+ static override usage = Command.Usage({
692
+ category: 'Review',
693
+ description: "where a card's work stands, any time: broken, better or fixed, a line, a file or a pair",
694
+ details: `${DETAILS}\n\nsk review update <id> <broken|better|fixed> "<one line>" [<file> | <before> <after>]: the file (an image, a clip or a sound, as it is: no special file) becomes the card's next view, the line and the state go on its thread in time order. Two files make that view a before and after pair, as add --before --after does: two images of one size, two clips of one size and length, or two sounds, never one of each; the owner picks how he compares them (side by side, wipe, fade). broken or better holds the card « in progress » (not waiting on the owner's verdict, still new in the list), fixed asks the owner's verdict again on the same thread, even after an answer. The owner's hint on an update reaches watch and inbox as a reply « on update <k> ». Posted on the thread's newest version.`,
695
+ examples: [
696
+ ['still broken, the take as it is', 'SK_AGENT=L2 sk review update <id> broken "her arm still crosses her leg at 2 s" take.mp4'],
697
+ ['better, not done', 'SK_AGENT=L2 sk review update <id> better "the crossing is gone, the landing still snaps" take.mp4'],
698
+ ['fixed: he answers again', 'SK_AGENT=L2 sk review update <id> fixed "no crossing, no snap over the whole clip" take.mp4'],
699
+ ['better, as a before and after he compares his way', 'SK_AGENT=L2 sk review update <id> better "the snap is half as deep" before.mp4 after.mp4'],
700
+ ],
701
+ })
702
+ id = Option.String()
703
+ state = Option.String()
704
+ text = Option.String()
705
+ files = Option.Rest()
706
+ as = Option.String('--as', { description: 'the lane that posts (else SK_AGENT)' })
707
+
708
+ async execute(): Promise<number> {
709
+ return run(this.context, async (h) => {
710
+ const { postUpdate, agentName, readAll } = await import('../review/store.ts')
711
+ const { threadsOf } = await import('../review/threads.ts')
712
+ const { threadOfId } = await import('../review/cells.ts')
713
+ const asked = await idOf(h.dir, this.id)
714
+ // an update goes where he reads: the thread's newest version
715
+ const id = threadOfId(asked, threadsOf(readAll(h.dir).items))?.head.item.id ?? asked
716
+ const refused = await answererRefusal(h.dir, id, this.as, 'reply')
717
+ if (refused !== null) throw new Error(refused)
718
+ const r = await postUpdate(h.dir, id, { who: laneOfCaller(this.as) ?? agentName(), state: this.state, text: this.text, files: this.files })
719
+ const { viewLetter, stateOf } = await import('../review/model.ts')
720
+ const { readItem } = await import('../review/store.ts')
721
+ const x = readItem(h.dir, id)
722
+ const now = x && stateOf(x, false).state === 'asks' ? "waits for the owner's verdict" : x && stateOf(x, false).state === 'draft' ? 'in progress, no verdict asked' : 'in work'
723
+ h.out(`${id}: ${r.tag}${r.view !== null ? `, view ${viewLetter(r.view)}` : ''}${id !== asked ? ` (on the newest version, ${asked} is older)` : ''}; the card ${now}`)
724
+ if (r.view !== null) for (const line of await (await import('../review/previews.ts')).playCopies(h.dir, r.item, r.view)) h.err(line)
725
+ const { unheardLine } = await import('../review/model.ts')
726
+ const { liveWatchers } = await import('../review/watchers.ts')
727
+ const unheard = unheardLine(r.item, liveWatchers(h.dir))
728
+ if (unheard) h.err(unheard)
729
+ return 0
730
+ })
731
+ }
732
+ }
733
+
614
734
  export class ReviewWithdrawCommand extends Command {
615
735
  static override paths = [['review', 'withdraw']]
616
736
  static override usage = Command.Usage({ category: 'Review', description: 'take an unanswered card back, with the reason', details: DETAILS })
617
737
  ids = Option.Rest({ required: 1 })
618
- why = Option.String('--why', { required: true, description: 'why it goes' })
738
+ why = Option.String('--why,--note', { required: true, description: 'why it goes (--note says the same, as on fixed, wontfix, blocked and drop)' })
619
739
 
620
740
  async execute(): Promise<number> {
621
741
  return run(this.context, async (h) => {
622
742
  const { withdraw } = await import('../review/store.ts')
623
- for (const id of this.ids) if (!withdraw(h.dir, id, this.why)) throw new Error(`${id}: no such card, or he answered it already`)
624
- h.out(`review: ${this.ids.length} withdrawn`)
743
+ const ids = await Promise.all(this.ids.map((ref) => idOf(h.dir, ref)))
744
+ for (const id of ids) {
745
+ const r = withdraw(h.dir, id, this.why)
746
+ if ('refused' in r) throw new Error(r.refused)
747
+ h.out(r.already ? `${id}: withdrawn already (${r.already}), nothing to do` : `${id}: withdrawn`)
748
+ }
625
749
  return 0
626
750
  })
627
751
  }
@@ -635,7 +759,14 @@ export class ReviewReopenCommand extends Command {
635
759
  async execute(): Promise<number> {
636
760
  return run(this.context, async (h) => {
637
761
  const { reopen } = await import('../review/store.ts')
638
- for (const id of this.ids) if (!reopen(h.dir, id)) throw new Error(`${id}: no such card, or no answer to reopen`)
762
+ const { followAnswer } = await import('../releases/from-card.ts')
763
+ const { dirname } = await import('node:path')
764
+ for (const ref of this.ids) {
765
+ const id = await idOf(h.dir, ref)
766
+ const v = reopen(h.dir, id)
767
+ if (!v) throw new Error(`${id}: no such card, or no answer to reopen`)
768
+ await followAnswer(dirname(dirname(h.dir)), id, v.status)
769
+ }
639
770
  h.out(`review: ${this.ids.length} reopened`)
640
771
  return 0
641
772
  })
@@ -657,9 +788,10 @@ export class ReviewPickCommand extends Command {
657
788
  return run(this.context, async (h) => {
658
789
  const { setAgentPick } = await import('../review/store.ts')
659
790
  const { viewLetter, viewName } = await import('../review/model.ts')
660
- const item = setAgentPick(h.dir, this.id, this.view)
791
+ const id = await idOf(h.dir, this.id)
792
+ const item = setAgentPick(h.dir, id, this.view)
661
793
  const n = item.agentPick ?? 0
662
- h.out(`${this.id}: my pick ${viewLetter(n)} "${viewName(item.views[n], n)}"`)
794
+ h.out(`${id}: my pick ${viewLetter(n)} "${viewName(item.views[n], n)}"`)
663
795
  return 0
664
796
  })
665
797
  }
@@ -671,6 +803,7 @@ type ActOp = 'fixed' | 'wontfix' | 'claim' | 'release' | 'blocked' | 'done' | 'd
671
803
  function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'optional'; text?: string; topic?: 'required' | 'optional'; named: boolean; examples: [string, string][] }) {
672
804
  return class extends Command {
673
805
  static override paths = [['review', op]]
806
+ static essential = op === 'done' ? { args: '<id> [what changed]' } : op === 'fixed' ? { args: '<id> --note <what was done>' } : undefined
674
807
  static override usage = Command.Usage({ category: 'Review', description, details: `${DETAILS}\n\nTakes an item id or a player report's ref (live#3). ${o.named ? 'Who acts: --as <name>, else SK_AGENT.' : 'Who acts: --as, else SK_AGENT, else agent.'}`, examples: o.examples })
675
808
  id = Option.String()
676
809
  words = o.text !== undefined || o.topic !== undefined ? Option.String({ required: false, name: o.text ?? 'topic' }) : undefined
@@ -688,6 +821,21 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
688
821
  if (o.topic === 'required' && !this.words) throw new Error(`${op} <id> <topic> (sk review topics)`)
689
822
  const id = await idOf(h.dir, this.id)
690
823
  const who = actor(this.as, o.named, op)
824
+ if (op === 'done') {
825
+ // done is asked of a card he answered « fix »: closed already is the goal reached, unanswered is withdraw's
826
+ const { readAll } = await import('../review/store.ts')
827
+ const { followedIds } = await import('../review/threads.ts')
828
+ const was = readItem(h.dir, id)
829
+ const followed = followedIds(readAll(h.dir).items).has(id)
830
+ const st = was ? stateOf(was, followed) : null
831
+ if (st?.state === 'closed') {
832
+ h.out(`${id}: closed already (${st.why ?? 'closed'}${followed ? ', a newer card follows it' : ''}), nothing to close`)
833
+ if (this.words || this.note) h.err(`your words are not posted: sk review reply ${id} "<text>"`)
834
+ return 0
835
+ }
836
+ if (st?.state === 'asks' || st?.state === 'draft')
837
+ throw new Error(`${id}: done closes a card the owner answered « fix »; this one ${st.state === 'asks' ? "waits on the owner's verdict" : 'is in progress'}: sk review withdraw ${id} --why "<why>" takes it back`)
838
+ }
691
839
  act(h.dir, id, op, who, {
692
840
  ...(this.note ? { note: this.note } : {}),
693
841
  ...(op === 'ask' && this.words ? { text: this.words } : {}),
@@ -840,8 +988,9 @@ export class ReviewReadyCommand extends Command {
840
988
  async execute(): Promise<number> {
841
989
  return run(this.context, async (h) => {
842
990
  const { readItem, readyItem } = await import('../review/store.ts')
843
- const live = readItem(h.dir, this.id)?.item.wip?.live
844
- const r = await readyItem(h.dir, this.id, this.image ? { image: this.image } : {})
991
+ const id = await idOf(h.dir, this.id)
992
+ const live = readItem(h.dir, id)?.item.wip?.live
993
+ const r = await readyItem(h.dir, id, this.image ? { image: this.image } : {})
845
994
  if (live !== undefined) h.unit?.live?.stop?.(live, 'ready')
846
995
  h.out(`${r.id} ready: he can answer it`)
847
996
  return 0
@@ -1083,6 +1232,7 @@ export class ReviewAutoCommand extends Command {
1083
1232
 
1084
1233
  export class ReviewWatchCommand extends Command {
1085
1234
  static override paths = [['review', 'watch']]
1235
+ static essential = {}
1086
1236
  static override usage = Command.Usage({
1087
1237
  category: 'Review',
1088
1238
  description: 'one line per verdict, reply or raised note as it lands; every unseen one first; ends with its owner',
@@ -1184,6 +1334,7 @@ export const REVIEW_COMMANDS = [
1184
1334
  ReviewInboxCommand,
1185
1335
  ReviewSeenCommand,
1186
1336
  ReviewReplyCommand,
1337
+ ReviewUpdateCommand,
1187
1338
  ReviewWithdrawCommand,
1188
1339
  ReviewReopenCommand,
1189
1340
  ReviewPickCommand,
@@ -3,6 +3,9 @@
3
3
  // Logic in secrets/list.ts and secrets/manager.ts. A value only ever goes to stdout of `get`/`account`,
4
4
  // and only for a repo in the name's scope.
5
5
  import { Command, Option } from 'clipanion'
6
+ import { homedir } from 'os'
7
+ import { relative } from 'path'
8
+ import { houseRootOf } from '../home/home-start.ts'
6
9
  import { presence, secretsFor } from '../secrets/list.ts'
7
10
  import { houseScopeOf, managerTemplate as template, NoManager, readRefusal, REFUSED_EXIT, secretsWhere as where, storeArgv } from '../secrets/manager.ts'
8
11
  import { secretArgv } from '../smoke/run-smoke.ts'
@@ -20,6 +23,7 @@ async function refusing(stderr: NodeJS.WritableStream, run: () => Promise<number
20
23
 
21
24
  export class SecretListCommand extends Command {
22
25
  static override paths = [['secret', 'list'], ['secret']]
26
+ static essential = {}
23
27
 
24
28
  static override usage = Command.Usage({
25
29
  category: 'Secrets',
@@ -51,10 +55,11 @@ export class SecretListCommand extends Command {
51
55
  const mine = rows.filter((r) => r.mine).length
52
56
  say(`${w.repos[0]} speaks as ${w.identity ?? 'no identity'}: ${rows.filter((r) => r.inScope).length} secrets, ${mine} for this repo or identity`)
53
57
  const pad = (k: 'name' | 'for'): number => Math.max(...rows.map((r) => r[k].length))
58
+ if ([...has.values()].includes('locked')) say(`LOCK: there, in a keychain locked to this session (an ssh session sees it so): \`security unlock-keychain\` in it to read them`)
54
59
  for (const r of rows) {
55
60
  const p = has.get(r.name)
56
- const mark = !r.inScope ? 'out ' : p === true ? 'ok ' : 'MISS'
57
- const fix = p === false ? ` → sk secret set ${r.name}` : ''
61
+ const mark = !r.inScope ? 'out ' : p === 'ok' ? 'ok ' : p === 'locked' ? 'LOCK' : 'MISS'
62
+ const fix = p === 'missing' ? ` → sk secret set ${r.name}` : ''
58
63
  say(`${mark} ${r.name.padEnd(pad('name'))} ${r.level.padEnd(5)} ${r.for.padEnd(pad('for'))} ${(r.service ?? '').slice(0, 40)}${fix}`)
59
64
  }
60
65
  return 0
@@ -63,6 +68,7 @@ export class SecretListCommand extends Command {
63
68
 
64
69
  export class SecretReadCommand extends Command {
65
70
  static override paths = [['secret', 'get'], ['secret', 'account']]
71
+ static essential = { args: '<name>' }
66
72
 
67
73
  static override usage = Command.Usage({
68
74
  category: 'Secrets',
@@ -106,3 +112,36 @@ export class SecretSetCommand extends Command {
106
112
  })
107
113
  }
108
114
  }
115
+
116
+ export class SecretCopyCommand extends Command {
117
+ static override paths = [['secret', 'copy']]
118
+
119
+ static override usage = Command.Usage({
120
+ category: 'Secrets',
121
+ description: "this Mac's secrets into another Mac's keychain over ssh, each on ssh's stdin; what it holds stays",
122
+ details: "With no name: every secret of this repo's list that this Mac holds. The other Mac runs its own `sk secret set` from the house checkout at the same place under its home. A secret it already answers is left as it is. A keychain locked to ssh stops the copy and says how to unlock it.",
123
+ examples: [['every secret mini1 lacks', 'sk secret copy --to mini1'], ['one secret', 'sk secret copy rv/shipkit/spaces --to mini1'], ['a Mac whose keychain ssh sees locked, from your terminal', 'sk secret copy --to mini1 --unlock']],
124
+ })
125
+
126
+ names = Option.Rest()
127
+ to = Option.String('--to', { required: true, description: 'the other Mac, as ssh reaches it: an alias of ~/.ssh/config' })
128
+ unlock = Option.Boolean('--unlock', false, { description: "unlock that Mac's keychain first, in the same ssh session: run it from your terminal, it asks for that Mac's login password once" })
129
+
130
+ async execute(): Promise<number> {
131
+ return refusing(this.context.stderr, async () => {
132
+ const w = await where(process.cwd())
133
+ const houseRoot = houseRootOf(process.cwd())
134
+ if (houseRoot == null || !houseRoot.startsWith(`${homedir()}/`)) throw new NoManager('FAIL the house checkout is not under the home folder: the other Mac finds it at the same place under its own')
135
+ const inHouse = w.house != null && w.house === w.own
136
+ const rows = secretsFor({ asker: w, own: inHouse ? [] : (w.own?.creds ?? []), house: w.house?.creds ?? [] }).filter((r) => r.inScope)
137
+ const names = this.names.length > 0 ? this.names : rows.map((r) => r.name)
138
+ const { copySecrets, copyWithUnlock } = await import('../secrets/copy.ts')
139
+ if (this.unlock) return copyWithUnlock({ names, to: this.to, reader: template(w, 'credsReadCommand'), houseRel: relative(homedir(), houseRoot), say: (l) => void this.context.stdout.write(`${l}\n`) })
140
+ const r = await copySecrets({ names, to: this.to, reader: template(w, 'credsReadCommand'), houseRel: relative(homedir(), houseRoot) })
141
+ for (const c of r.copied) this.context.stdout.write(`${c.did === 'failed' ? 'FAIL' : c.did === 'copied' ? 'ok ' : 'skip'} ${c.name} ${c.did}${c.why ? `: ${c.why}` : ''}\n`)
142
+ const n = (d: string): number => r.copied.filter((c) => c.did === d).length
143
+ this.context.stdout.write(`${n('copied')} copied, ${n('there')} already on ${this.to}, ${n('not here')} not on this Mac, ${n('failed')} failed${r.locked ? ' (stopped: locked)' : ''}\n`)
144
+ return n('failed') > 0 ? 1 : 0
145
+ })
146
+ }
147
+ }
@@ -1,7 +1,9 @@
1
1
  // sk shot: a still of any url (webp by default), or a clip with --video, through the machine's
2
2
  // one warm browser (shot/client.ts). A repo's own CLI wraps it with its setup
3
3
  // flags; the trailer's `url` film calls the same functions.
4
- import { relative } from 'path'
4
+ import { statSync } from 'fs'
5
+ import { relative, resolve } from 'path'
6
+ import { pathToFileURL } from 'url'
5
7
  import { Command, Option } from 'clipanion'
6
8
  import { clipUrl, shotUrl, type ShotResult } from '../shot/client.ts'
7
9
  import { askOf, isClip } from '../shot/shot-ask.ts'
@@ -17,16 +19,25 @@ export const renderShot = (r: ShotResult, cwd: string): string[] => {
17
19
  return lines
18
20
  }
19
21
 
22
+ /** the path of a file on this machine as its file url; anything else as typed */
23
+ export const fileUrlOf = (s: string, cwd: string): string => {
24
+ if (/^[a-z]+:\/\//i.test(s)) return s
25
+ const p = resolve(cwd, s)
26
+ return statSync(p, { throwIfNoEntry: false })?.isFile() ? pathToFileURL(p).href : s
27
+ }
28
+
20
29
  export class ShotCommand extends Command {
21
30
  static override paths = [['shot']]
31
+ static essential = { args: '<url>' }
22
32
 
23
33
  static override usage = Command.Usage({
24
34
  category: 'Serve',
25
35
  description: 'a webp of any url through the warm browser (a png with --out x.png), or an mp4 clip with --video',
26
36
  details:
27
- 'one warm headless chromium for the whole machine (the `shot` global process, started when down). A still reuses the warm page when it already shows the url, so a warm shot answers in about 0.1 s. A page with `<meta name="shot-ready" content="wait">` is shot once it sets content="ready"; any other page --wait ms after its load. --video films a page that is a canvas through its WebCodecs encoder (H.264 muxed with no second encode), and any other page as chromium paints it (its screencast, encoded by ffmpeg as the frames arrive); --dom films the page even when a canvas fills it. --step <hook> films frame by frame: before each frame the page draws its time t (seconds) in `await window[hook](t)`, then its ready mark, so a slow page films smooth at its fps; a canvas page is encoded by its own WebCodecs at the exact time n / fps, any other page a screenshot a frame. A still with --step is the page drawn at --at s',
37
+ 'one warm headless chromium for the whole machine (the `shot` global process, started when down). A still reuses the warm page when it already shows the url, so a warm shot answers in about 0.1 s. A page with `<meta name="shot-ready" content="wait">` is shot once it sets content="ready"; any other page --wait ms after its load; a page that navigates while it loads (a sign in that redirects) gets its wait again where it lands. --full shoots the whole page at the width of the viewport. A file of this machine is a url too (its path, or file://). --video films a page that is a canvas through its WebCodecs encoder (H.264 muxed with no second encode), and any other page as chromium paints it (its screencast, encoded by ffmpeg as the frames arrive); --dom films the page even when a canvas fills it. --step <hook> films frame by frame: before each frame the page draws its time t (seconds) in `await window[hook](t)`, then its ready mark, so a slow page films smooth at its fps; a canvas page is encoded by its own WebCodecs at the exact time n / fps, any other page a screenshot a frame. A still with --step is the page drawn at --at s. A session: cookies follow every shot (one jar in memory for the whole machine), the local storage of a page does not: a shot at another viewport, a clip and the idle close (60 s) each start with an empty one, as two browser contexts do. So when an app keeps its session in local storage, open its sign in at the viewport you shoot at; a request the page sees answered 401 or 403 prints its own WARN line',
28
38
  examples: [
29
39
  ['a still of a running dev server', 'sk shot localhost:5173/'],
40
+ ['a whole tall page at a phone width', 'sk shot :5173/guest --viewport 390,844 --full --out shots/guest.png'],
30
41
  ['a phone screen, at the pixel ratio of a phone', 'sk shot :5173/play --viewport 390,844 --dpr 3 --out shots/phone.png'],
31
42
  ['a 3 s clip', 'sk shot :4808/ --video 3 --out clips/walk.mp4'],
32
43
  ['a clip of a whole web app page, canvas or not', 'sk shot :5173/settings --video 3 --dom'],
@@ -39,7 +50,8 @@ export class ShotCommand extends Command {
39
50
  dpr = Option.String('--dpr', { description: 'device pixel ratio (default 1)' })
40
51
  out = Option.String('--out', { description: 'the file (default .shipkit/tmp/shots/<url>.webp, or .mp4 with --video); its extension picks the still: .webp and .jpg at quality 90, .png lossless' })
41
52
  reload = Option.Boolean('--reload', false, { description: 'load the page again even when the warm page shows this url' })
42
- wait = Option.String('--wait', { description: 'ms after load for a page with no ready mark (default 300)' })
53
+ wait = Option.String('--wait', { description: 'ms after load for a page with no ready mark (default 300, at most 60000)' })
54
+ full = Option.Boolean('--full', false, { description: 'the whole page, past the viewport height (a still only)' })
43
55
  video = Option.String('--video', { description: 'seconds of clip: an mp4 of the page (its canvas when a canvas fills it)' })
44
56
  fps = Option.String('--fps', { description: 'clip frames per second (default 30)' })
45
57
  long = Option.Boolean('--long', false, { description: 'allow a clip past 30 s' })
@@ -52,7 +64,7 @@ export class ShotCommand extends Command {
52
64
  const cwd = process.cwd()
53
65
  const err = (l: string) => this.context.stderr.write(`${l}\n`)
54
66
  try {
55
- const a = askOf({ url: this.url, viewport: this.viewport, dpr: this.dpr, out: this.out, reload: this.reload, wait: this.wait, video: this.video, fps: this.fps, long: this.long, dom: this.dom, step: this.step, at: this.at }, cwd)
67
+ const a = askOf({ url: fileUrlOf(this.url, cwd), full: this.full, viewport: this.viewport, dpr: this.dpr, out: this.out, reload: this.reload, wait: this.wait, video: this.video, fps: this.fps, long: this.long, dom: this.dom, step: this.step, at: this.at }, cwd)
56
68
  const r = isClip(a) ? await clipUrl(a, err) : await shotUrl(a, err)
57
69
  if (this.json) this.context.stdout.write(`${JSON.stringify(r)}\n`)
58
70
  else for (const l of renderShot(r, cwd)) this.context.stdout.write(`${l}\n`)
@@ -1,25 +1,27 @@
1
1
  // shipkit status — read back a gate started with `shipkit ci --detach`. Thin
2
2
  // clipanion surface; logic in core/jobs.ts.
3
3
  import { Command, Option } from 'clipanion'
4
- import { jobStatus, STILL_RUNNING } from '../core/jobs.ts'
4
+ import { jobStatus, STILL_RUNNING, waitStatus } from '../core/jobs.ts'
5
5
 
6
6
  export class StatusCommand extends Command {
7
7
  static override paths = [['status']]
8
+ static essential = {}
8
9
 
9
10
  static override usage = Command.Usage({
10
11
  category: 'Gate',
11
12
  description: 'the output and verdict of a gate started with `sk ci --detach`',
12
- details: `a gate started with \`shipkit ci --detach\`: its wire lines so far, then its verdict. Exit code = the gate's own once it finished, ${STILL_RUNNING} while it still runs, 1 when it died without one`,
13
+ details: `a gate started with \`shipkit ci --detach\`: its verdict on the first line (finished green, finished red, still running, died), then its wire lines so far. Exit code = the gate's own once it finished, ${STILL_RUNNING} while it still runs, 1 when it died without one. --wait holds until the run has a verdict (10 minutes at most): one call from a backgrounded shell in place of a poll every few seconds. With no id: the latest run \`--detach\` started here, never a job of the daemon`,
13
14
  examples: [
14
- ['the latest detached run of this checkout', 'sk status'],
15
- ['one run by id', 'sk status ci-mf3k2a-1x2y'],
15
+ ['hold until the run ends, then its verdict', 'sk status ci-mf3k2a-1x2y --wait'],
16
+ ['the latest detached run of this checkout, as it stands', 'sk status'],
16
17
  ],
17
18
  })
18
19
 
19
20
  id = Option.String({ required: false })
21
+ wait = Option.Boolean('--wait', false, { description: 'hold until the run has a verdict, 10 minutes at most, then print it' })
20
22
 
21
23
  async execute(): Promise<number> {
22
- const r = jobStatus(process.cwd(), this.id)
24
+ const r = this.wait ? await waitStatus(process.cwd(), this.id) : jobStatus(process.cwd(), this.id)
23
25
  for (const l of r.lines) this.context.stdout.write(`${l}\n`)
24
26
  return r.code
25
27
  }