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
@@ -4,16 +4,16 @@
4
4
  // private in the Space. The card named is the thread's first version, so a later version approved again replaces its
5
5
  // change instead of adding a second
6
6
  import { ensureLocal } from '../review/media-read.ts'
7
- import { isApproved, verdictOf, type Item, type ReviewItem } from '../review/model.ts'
7
+ import { isApproved, verdictOf, type Item, type ReviewItem, type ReviewStatus } from '../review/model.ts'
8
8
  import { stageablesOf } from '../review/stage-card.ts'
9
- import { readAll, readItem, storeDir } from '../review/store.ts'
9
+ import { addMessage, readAll, readItem, storeDir } from '../review/store.ts'
10
10
  import { threadOfItem, threadsOf } from '../review/threads.ts'
11
11
  import { commitPaths } from '../social/writes.ts'
12
12
  import { idleBefore } from './before.ts'
13
13
  import type { PostRating } from '../identities/rating.ts'
14
14
  import { changesOf, isClip, NEXT, ratingOf, type Change, type Picture, type Shot } from './model.ts'
15
15
  import { keepPicture } from './pictures.ts'
16
- import { addChange, readRelease, undeclaredReleases, writeRelease } from './store.ts'
16
+ import { addChange, dropCardChange, readRelease, releaseVersions, undeclaredReleases, writeRelease } from './store.ts'
17
17
 
18
18
  /** the versions of a card, newest first, following `supersedes` */
19
19
  export function versionsOf(dir: string, x: ReviewItem): Item[] {
@@ -104,6 +104,48 @@ export async function onVerdict(root: string, id: string): Promise<string | null
104
104
  return file
105
105
  }
106
106
 
107
+ /** after an approval taken back (a reopen, or another verdict in its place): next.md drops the card's change, committed,
108
+ * while no version of its thread stays approved. What happened, in words for the card's thread; null when the card
109
+ * brought no change. A change already released stays, and the words say so */
110
+ export async function onTakeBack(root: string, id: string): Promise<string | null> {
111
+ const dir = storeDir(root)
112
+ const x = readItem(dir, id)
113
+ const versions = x ? versionsOf(dir, x) : []
114
+ if (!versions.some((v) => v.changelog)) return null
115
+ const card = versions.at(-1)!.id
116
+ const still = threadOfItem(id, threadsOf(readAll(dir).items))?.versions.find((v) => isApproved(verdictOf(v)?.status ?? 'rejected'))
117
+ if (still) return `the approval was taken back, and next.md keeps this card's change: its version ${still.item.id} is still approved`
118
+ const file = dropCardChange(root, card)
119
+ if (file) {
120
+ commitPaths([file], `releases: next drops the change of the card ${card}, its approval taken back`)
121
+ return 'the approval was taken back: next.md no longer holds this change (git keeps its words)'
122
+ }
123
+ const shipped = releaseVersions(root).find((v) => v !== NEXT && readRelease(root, v)?.categories.some((c) => c.changes.some((ch) => ch.card === card)))
124
+ return shipped ? `the approval was taken back, but this change already shipped in ${shipped}: that release still holds it` : null
125
+ }
126
+
127
+ /** what a change of the owner's answer does to next.md, from the hub or the CLI: an approval adds the card's change, an
128
+ * approval taken back (`was`, the status before) drops it. A failure and every take back say so on the card's thread and
129
+ * in the log, so the release never moves in silence */
130
+ export async function followAnswer(root: string, id: string, was: ReviewStatus | null): Promise<void> {
131
+ try {
132
+ const x = readItem(storeDir(root), id)
133
+ const now = x ? (verdictOf(x)?.status ?? null) : null
134
+ if (now !== null && isApproved(now)) await onVerdict(root, id)
135
+ else if (was !== null && isApproved(was)) {
136
+ const said = await onTakeBack(root, id)
137
+ if (said) {
138
+ console.error(`review: ${id}: ${said}`)
139
+ addMessage(storeDir(root), id, 'releases', said)
140
+ }
141
+ }
142
+ } catch (e) {
143
+ const why = (e as Error).message
144
+ console.error(`FAIL: the release did not follow the answer on ${id}: ${why}`)
145
+ addMessage(storeDir(root), id, 'releases', `the release did not follow this answer: ${why}. Run sk releases add --card ${id}, or edit .shipkit/releases/next.md`)
146
+ }
147
+ }
148
+
107
149
  /** the version of a card's thread a change stands for: its newest approved one, else its newest */
108
150
  function approvedOf(dir: string, id: string): ReviewItem | null {
109
151
  const t = threadOfItem(id, threadsOf(readAll(dir).items))
@@ -266,6 +266,12 @@ export function upsertChange(r: Release, category: string, change: Change): Rele
266
266
  return { ...r, categories: cats.filter((c) => c.changes.length > 0) }
267
267
  }
268
268
 
269
+ /** the release without the change of that card; a category left empty goes */
270
+ export const withoutCard = (r: Release, card: string): Release => ({
271
+ ...r,
272
+ categories: r.categories.map((c) => ({ ...c, changes: c.changes.filter((x) => x.card !== card) })).filter((c) => c.changes.length > 0),
273
+ })
274
+
269
275
  export const changesOf = (r: Release): Change[] => r.categories.flatMap((c) => c.changes)
270
276
 
271
277
  /** a change's key on a page: its card, else its title */
@@ -4,7 +4,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync } from 'node:f
4
4
  import { join } from 'node:path'
5
5
  import { atomicWrite } from '../core/locked-write.ts'
6
6
  import { LAYOUT } from '../core/layout.ts'
7
- import { byVersion, emptyRelease, fileOf, NEXT, parseRelease, renderRelease, upsertChange, type Change, type Release } from './model.ts'
7
+ import { byVersion, emptyRelease, fileOf, NEXT, parseRelease, renderRelease, upsertChange, withoutCard, type Change, type Release } from './model.ts'
8
8
 
9
9
  const FILE = /^(next|\d+\.\d+\.\d+)\.md$/
10
10
 
@@ -30,6 +30,13 @@ export function releaseVersions(root: string): string[] {
30
30
  .sort(byVersion)
31
31
  }
32
32
 
33
+ /** next without the change of that card, written; the file, or null when next holds no change of it */
34
+ export function dropCardChange(root: string, card: string): string | null {
35
+ const r = readRelease(root, NEXT)
36
+ if (!r?.categories.some((c) => c.changes.some((x) => x.card === card))) return null
37
+ return writeRelease(root, withoutCard(r, card))
38
+ }
39
+
33
40
  /** one release file, parsed; null when there is none */
34
41
  export function readRelease(root: string, version: string): Release | null {
35
42
  const f = releaseFile(root, version)
@@ -65,9 +65,11 @@ export type ServeConfig = {
65
65
  }
66
66
  /** agent/ graph entrypoint (default: index.md AND README.md) */
67
67
  agentIndex?: string
68
- /** off-machine hostname for the hub, as in a tailnet MagicDNS name. It
69
- * prints beside localhost and rides on every ping message, because a
70
- * phone cannot resolve localhost */
68
+ /** off-machine hostname for the hub, overriding this Mac's tailnet name,
69
+ * which is read from tailscale when this is absent. It prints beside
70
+ * localhost and rides on every ping message, because a phone cannot
71
+ * resolve localhost. A Mac's own name: never set it in a repo that
72
+ * more than one Mac checks out */
71
73
  publicHost?: string
72
74
  /** the ids of the global processes this repo needs (any house repo's
73
75
  * `globalProcess` unit files). The home rail marks the repo while one is off */
@@ -3,6 +3,10 @@
3
3
  // folds into one thread, nothing is rewritten). The paged list's rows and its query. Pure and browser safe: the routes
4
4
  // send these shapes, the hub page draws them
5
5
  import {
6
+ inWork,
7
+ UPDATE_WORDS,
8
+ updatesOf,
9
+ type UpdateState,
6
10
  isMarkItem,
7
11
  isReply,
8
12
  isStale,
@@ -86,6 +90,10 @@ export interface ReplyCell extends CellOf<'reply'> {
86
90
  op?: 'ask' | 'answer'
87
91
  /** the other party marked it seen */
88
92
  read: boolean
93
+ /** an agent's update: its number on the item from 1, its state, the view of the item that holds its media */
94
+ update?: { k: number; state: UpdateState; view?: number }
95
+ /** his hint on an update: the update's cell id, its number and state */
96
+ re?: { id: string; k: number; state: UpdateState }
89
97
  }
90
98
 
91
99
  /** what the owner or a player raised (its item, its opening words and rectangles), or the owner's mark on the subject */
@@ -176,6 +184,7 @@ function messageCells(x: ReviewItem, n: number, opening: Message | undefined): C
176
184
  const current = verdictOf(x)?.id
177
185
  const read = { agent: readBy(x, 'agent'), owner: readBy(x, 'owner') }
178
186
  const other = (who: string): Party => (partyOf(who) === 'owner' ? 'agent' : 'owner')
187
+ const updates = updatesOf(x)
179
188
  const out: Cell[] = []
180
189
  for (const m of x.thread) {
181
190
  if (m.op === 'seen' || m === opening) continue
@@ -204,7 +213,13 @@ function messageCells(x: ReviewItem, n: number, opening: Message | undefined): C
204
213
  out.push({ ...base, kind: 'note', ...(m.text !== undefined ? { text: m.text } : {}), rects: m.rects ?? [], ...(m.image ? { image: m.image } : {}), rate: r, read: wasRead, summary: `marked ${said}${m.text ? `: ${firstLine(m.text)}` : ''}` })
205
214
  } else if (isReply(m)) {
206
215
  const op = m.op === 'ask' || m.op === 'answer' ? m.op : undefined
207
- out.push({ ...base, kind: 'reply', text: m.text ?? '', ...(m.image ? { image: m.image } : {}), ...(op ? { op } : {}), read: wasRead, summary: firstLine(m.text) })
216
+ const k = updates.findIndex((u) => u.id === m.id)
217
+ const update = k >= 0 && m.update ? { k: k + 1, state: m.update.state, ...(m.update.view !== undefined ? { view: m.update.view } : {}) } : undefined
218
+ const rk = m.re ? updates.findIndex((u) => u.id === m.re) : -1
219
+ const reOn = rk >= 0 ? updates[rk]!.update : undefined
220
+ const re = reOn ? { id: `${id}/${m.re}`, k: rk + 1, state: reOn.state } : undefined
221
+ const said = update ? `${UPDATE_WORDS[update.state]}: ` : re ? `on update ${re.k}: ` : ''
222
+ out.push({ ...base, kind: 'reply', text: m.text ?? '', ...(m.image ? { image: m.image } : {}), ...(op ? { op } : {}), read: wasRead, ...(update ? { update } : {}), ...(re ? { re } : {}), summary: `${said}${firstLine(m.text)}` })
208
223
  } else if (m.op !== undefined) {
209
224
  const commit = m.fix?.commit
210
225
  out.push({
@@ -282,7 +297,8 @@ export function cellsOf(t: Thread, items: readonly ReviewItem[]): Cell[] {
282
297
  cells.sort((a, b) => a.at.localeCompare(b.at) || rank[a.kind] - rank[b.kind] || a.id.localeCompare(b.id))
283
298
  const last = t.head.item.id
284
299
  const latest = cells.find((c) => c.id === last)
285
- const answer = cells.findLast((c) => c.party === 'owner' && c.kind !== 'event' && c.id !== last)
300
+ // no findLast: a consumer's own typecheck reads this source, under whatever lib its tsconfig names
301
+ const answer = [...cells].reverse().find((c) => c.party === 'owner' && c.kind !== 'event' && c.id !== last)
286
302
  const unreadIds = new Set(membersOf(t).flatMap((x) => unreadBy(x, 'owner').map((m) => `${x.item.id}/${m.id}`)))
287
303
  for (const c of cells) {
288
304
  if (c.kind === 'event') continue
@@ -365,6 +381,8 @@ export interface ThreadRow {
365
381
  pair: boolean
366
382
  choice: boolean
367
383
  wip: boolean
384
+ /** the head's newest agent update: its state and line; its picture is the row's thumb when it carries one */
385
+ update?: { state: UpdateState; text: string; at: string }
368
386
  waits: boolean
369
387
  active: boolean
370
388
  /** agent words the owner has not read on any of its items */
@@ -446,6 +464,9 @@ function rowOf(t: Thread, items: readonly ReviewItem[], followed: ReadonlySet<st
446
464
  const m = x.thread.at(-1)?.at ?? x.item.created
447
465
  return m > u ? m : u
448
466
  }, h.item.created)
467
+ const newest = updatesOf(h).at(-1)
468
+ const shows = newest?.update?.view !== undefined ? h.item.views[newest.update.view] : undefined
469
+ const thumbOf = shows ?? first
449
470
  return {
450
471
  head: h.item.id,
451
472
  title: h.item.title,
@@ -461,11 +482,12 @@ function rowOf(t: Thread, items: readonly ReviewItem[], followed: ReadonlySet<st
461
482
  move: moveOf(stateOf(h, followed.has(h.item.id)).state),
462
483
  versions: t.versions.length,
463
484
  views: h.item.views.length,
464
- thumb: first ? thumbFileOf(first) || null : null,
485
+ thumb: thumbOf ? thumbFileOf(thumbOf) || null : null,
465
486
  clip: h.item.views.some((v) => !isGallery(v) && v.clip !== undefined),
466
487
  pair: first !== undefined && !isGallery(first) && isPair(first.files),
467
488
  choice: h.item.choice === true,
468
- wip: h.item.wip !== undefined,
489
+ wip: inWork(h),
490
+ ...(newest?.update ? { update: { state: newest.update.state, text: newest.text ?? '', at: newest.at } } : {}),
469
491
  waits: waits(h),
470
492
  active: isActive(t, now),
471
493
  unread: members.some((x) => unreadBy(x, 'owner').length > 0),
@@ -1,8 +1,17 @@
1
1
  // what `sk review inbox`, `show`, `watch`, `next` and `board` print of an item and its answer (wiki tools/shipkit/review.md):
2
2
  // one record per thread, rectangles normalized and in pixels, a frame note's cut, shot and time into it, and the lines the
3
3
  // repo's unit adds (a kind's facts, a source's), handed in as `more` so this module stays pure
4
- import { aboutText, isFrame, isGallery, isPair, NO_SPEC, placeText, stateOf, unreadBy, verdictOf, type Message, type Rect, type ReviewItem, type Spec, type Subject } from './model.ts'
5
- import { answererOf, conversationOf, openingOf, type Thread } from './threads.ts'
4
+ import { aboutText, isFrame, isGallery, isPair, NO_SPEC, placeText, stateOf, takenBackOf, unreadBy, updateTag, verdictOf, type Message, type Rect, type ReviewItem, type ReviewStatus, type Spec, type Subject } from './model.ts'
5
+ import { answererOf, conversationOf, membersOf, openingOf, type Thread } from './threads.ts'
6
+
7
+ /** what a message is in a thread beyond its words: ` [update 2 (still broken)]` on an agent's update, ` (on update 2
8
+ * (still broken))` on his hint about one */
9
+ const updateText = (x: ReviewItem, m: Message): string => {
10
+ const own = m.update ? updateTag(x, m.id) : null
11
+ if (own) return ` [${own}]`
12
+ const re = m.re ? updateTag(x, m.re) : null
13
+ return re ? ` (on ${re})` : ''
14
+ }
6
15
 
7
16
  /** the lines a repo's unit adds under an item's head, and its spec for the words */
8
17
  export interface Say {
@@ -46,11 +55,21 @@ export const refOf = (x: ReviewItem): string => (x.item.origin.by === 'player' ?
46
55
 
47
56
  /** one owner reply, for a monitor; on an item a card answers, it reads on the card's thread */
48
57
  export const replyLine = (x: ReviewItem, m: Message, card: ReviewItem | null = null): string =>
49
- `${(card ?? x).item.id} reply "${(card ?? x).item.title}"${card ? ` (on ${refOf(x)})` : ''}: ${flat(m.text ?? '')}${m.image ? ` [image thread/${m.image}]` : ''}`
58
+ `${(card ?? x).item.id} reply "${(card ?? x).item.title}"${card ? ` (on ${refOf(x)})` : ''}${updateText(x, m)}: ${flat(m.text ?? '')}${m.image ? ` [image thread/${m.image}]` : ''}`
59
+
60
+ const TOOK: Record<ReviewStatus, string> = { approved: 'approval', 'approved-with-fix': '« ok with a fix »', rejected: 'rejection', archived: '« archived, later »' }
61
+
62
+ /** each verdict he took back, unseen: what it was, when he gave it, and that it no longer holds */
63
+ export const takeBackTexts = (x: ReviewItem): { m: Message; text: string }[] =>
64
+ takenBackOf(x).map(({ m, took, given }) => ({
65
+ m,
66
+ text: `he took his ${TOOK[took]} back (given ${given}): the card waits for his answer again and that ${TOOK[took]} no longer holds; hold or undo what you did on it, then sk review seen ${x.item.id}`,
67
+ }))
50
68
 
51
- /** what watch prints of an item, each with the key it prints once under: an unseen feedback (again when sent again), each unseen reply */
69
+ /** what watch prints of an item, each with the key it prints once under: a verdict he took back, an unseen feedback (again
70
+ * when sent again), each unseen reply */
52
71
  export function watchLines(x: ReviewItem, items: readonly ReviewItem[] = []): { key: string; text: string }[] {
53
- const out: { key: string; text: string }[] = []
72
+ const out: { key: string; text: string }[] = takeBackTexts(x).map((t) => ({ key: `${x.item.id}#${t.m.id}`, text: `${x.item.id} taken back "${x.item.title}": ${t.text}` }))
54
73
  const f = verdictOf(x)
55
74
  if (f && !f.seen) out.push({ key: `${x.item.id}@${f.at}`, text: line(x) })
56
75
  const card = x.item.origin.by === 'agent' ? null : answererOf(x.item.id, items)
@@ -83,7 +102,11 @@ export function threadDetail(t: Thread, dir: string, full = false, say: Say = PL
83
102
  if (full) {
84
103
  const conv = conversationOf(t)
85
104
  if (conv.length > 0) out.push(' thread:')
86
- for (const m of conv) out.push(` ${m.who} ${m.at}${m.on === t.head.item.id ? '' : ` [on ${m.on}]`}: ${flat(m.text ?? '')}${m.image ? ` [image ${dir}/${m.on}/thread/${m.image}]` : ''}`)
105
+ const members = membersOf(t)
106
+ for (const m of conv) {
107
+ const of = members.find((y) => y.item.id === m.on)
108
+ out.push(` ${m.who} ${m.at}${m.on === t.head.item.id ? '' : ` [on ${m.on}]`}${of ? updateText(of, m) : ''}: ${flat(m.text ?? '')}${m.image ? ` [image ${dir}/${m.on}/thread/${m.image}]` : ''}`)
109
+ }
87
110
  }
88
111
  return out.join('\n')
89
112
  }
@@ -120,14 +143,14 @@ export function detail(x: ReviewItem, dir: string, full = false, followed = fals
120
143
  const head = ` "${r.title}" (${aboutText(r, say.spec)})`
121
144
  const frame = subjectText(r.subject)
122
145
  const sub = [...(frame ? [frame] : []), ...say.more(x)]
123
- const replies = unreadBy(x, 'agent').map((m) => ` reply ${m.at}: ${m.text}${m.image ? ` [image ${dir}/${r.id}/thread/${m.image}]` : ''}`)
146
+ const replies = unreadBy(x, 'agent').map((m) => ` reply ${m.at}${updateText(x, m)}: ${m.text}${m.image ? ` [image ${dir}/${r.id}/thread/${m.image}]` : ''}`)
124
147
  if (r.origin.by !== 'agent') {
125
148
  const st = stateOf(x, followed)
126
149
  const said = x.thread.filter((m) => m.who === 'owner' || m.who === 'player')
127
150
  const words = full ? x.thread.filter((m) => (m.text !== undefined || m.op !== undefined) && m.op !== 'seen') : said.filter((m) => m.text !== undefined && m.op === undefined)
128
151
  const pins = said.filter((m) => m.rects !== undefined).at(-1)
129
152
  const first = r.views[0]
130
- const image = first && 'files' in first ? Object.values(first.files) : []
153
+ const image = first && !isGallery(first) ? Object.values(first.files) : []
131
154
  return [
132
155
  `${r.id} ${st.state.toUpperCase()}${st.why ? ` (${st.why})` : ''} raised by ${raisedBy(r.origin)} ${r.created}${r.commit ? ` at ${r.commit}` : ''}`,
133
156
  head,
@@ -139,9 +162,10 @@ export function detail(x: ReviewItem, dir: string, full = false, followed = fals
139
162
  ...(image.length > 0 ? [` image: ${image.map((n) => `${dir}/${r.id}/${n}`).join(' ')}`] : []),
140
163
  ].join('\n')
141
164
  }
142
- if (!f) return [`${r.id} NO VERDICT YET`, head, ...sub, ...replies].join('\n')
165
+ const back = takeBackTexts(x).map((t) => ` taken back ${t.m.at}: ${t.text}`)
166
+ if (!f) return [`${r.id} ${back.length > 0 ? 'TAKEN BACK, NO VERDICT NOW' : 'NO VERDICT YET'}`, head, ...sub, ...back, ...replies].join('\n')
143
167
  const pick = pickText(x)
144
- const out = [`${r.id} ${f.status.toUpperCase()} ${f.at}`, head, ...sub, ...(pick ? [` ${pick}`] : []), ` comment: ${f.comment || '(none)'}`]
168
+ const out = [`${r.id} ${f.status.toUpperCase()} ${f.at}`, head, ...sub, ...back, ...(pick ? [` ${pick}`] : []), ` comment: ${f.comment || '(none)'}`]
145
169
  for (const t of reactionTexts(x)) out.push(` view ${t}`)
146
170
  const px = (v: number, of: number): number => Math.round(v * of)
147
171
  const views = r.views
@@ -1,6 +1,6 @@
1
1
  // the review store as a kind of the media store (wiki tools/shipkit/review.md, Media in the Space): each file a card's
2
2
  // views name, by the facts its item.json keeps; kept on the disk while its thread is active or spoke in the window; an
3
- // image's previews sent up before it goes
3
+ // image's previews and a clip's play copy sent up before it goes
4
4
  import { existsSync, statSync } from 'node:fs'
5
5
  import { join } from 'node:path'
6
6
  import type { MediaKind, MediaRow } from '../media-store/kind.ts'
@@ -9,7 +9,7 @@ import type { Space } from '../media-store/space.ts'
9
9
  import { threadIndex } from './cells.ts'
10
10
  import { previewKey, REVIEW_KIND } from './media-read.ts'
11
11
  import { mediaFilesOf } from './model.ts'
12
- import { previewFile, PREVIEW_W, type PreviewSize } from './previews.ts'
12
+ import { playsCopy, previewFile, PREVIEW_W, type PreviewSize } from './previews.ts'
13
13
  import { fillMedia, readAll, readAllCached, storeDir, storeStamp } from './store.ts'
14
14
  import { membersOf } from './threads.ts'
15
15
 
@@ -63,22 +63,25 @@ export const reviewMedia: MediaKind = {
63
63
  return (r) => ({ pinned: pinned.has(r.item), used: used.get(r.item) })
64
64
  },
65
65
  async beforePurge(dir, space, r) {
66
- if (IMAGE.test(r.name) && !r.name.startsWith('thread/')) await previewsUp(dir, space, r)
66
+ if (r.name.startsWith('thread/')) return
67
+ if (IMAGE.test(r.name)) await previewsUp(dir, space, r, Object.keys(PREVIEW_W) as PreviewSize[], 'webp')
68
+ else if (playsCopy(dir, r.item, r.name)) await previewsUp(dir, space, r, ['fit'], 'mp4')
67
69
  },
68
70
  }
69
71
 
70
- /** an image's previews made (when the cache lacks them) and sent up, before the image leaves the disk: a PUT and a
71
- * HEAD each, none for a preview the index saw up */
72
- async function previewsUp(dir: string, space: Space, r: { item: string; name: string; key: string }): Promise<void> {
72
+ /** a file's previews made (when the cache lacks them) and sent up, before the file leaves the disk: an image's webps,
73
+ * a clip's play copy; a PUT and a HEAD each, none for a preview the index saw up */
74
+ async function previewsUp(dir: string, space: Space, r: { item: string; name: string; key: string }, sizes: readonly PreviewSize[], ext: 'webp' | 'mp4'): Promise<void> {
73
75
  const sha = r.key.slice(`${REVIEW_KIND}/`.length).replace(/\.[^.]+$/, '')
74
- for (const size of Object.keys(PREVIEW_W) as PreviewSize[]) {
75
- const key = previewKey({ sha }, size)
76
- // up already: a card that shares the image, or a purge that stopped after it
76
+ for (const size of sizes) {
77
+ const key = previewKey({ sha }, size, ext)
78
+ // up already: a card that shares the file, or a purge that stopped after it
77
79
  if (isUp(key)) continue
78
80
  const file = await previewFile(dir, r.item, r.name, size)
79
- if (!file || !existsSync(file)) continue
81
+ // a copy that failed answers the clip itself, never sent up as its preview
82
+ if (!file || !existsSync(file) || file === join(dir, r.item, r.name)) continue
80
83
  const n = statSync(file).size
81
- await space.put(key, file, 'image/webp')
84
+ await space.put(key, file, ext === 'mp4' ? 'video/mp4' : 'image/webp')
82
85
  if ((await space.head(key))?.size === n) recordUp(key, n)
83
86
  }
84
87
  }
@@ -11,8 +11,9 @@ export const REVIEW_KIND = 'review'
11
11
 
12
12
  /** where the Space keeps a file of a card */
13
13
  export const reviewKey = (f: Pick<MediaFact, 'sha'>, name: string): string => mediaKey(REVIEW_KIND, f, name)
14
- /** where the Space keeps an image's preview at a size: by the image's own sha, so it is found from the item alone */
15
- export const previewKey = (f: Pick<MediaFact, 'sha'>, size: string): string => `${REVIEW_KIND}/${f.sha}.${size}.webp`
14
+ /** where the Space keeps a file's preview at a size (an image's webp, a clip's play copy): by the file's own sha, so it
15
+ * is found from the item alone */
16
+ export const previewKey = (f: Pick<MediaFact, 'sha'>, size: string, ext: 'webp' | 'mp4' = 'webp'): string => `${REVIEW_KIND}/${f.sha}.${size}.${ext}`
16
17
 
17
18
  /** the fact a head keeps for one of its files, read from its item.json alone */
18
19
  export function factOfFile(dir: string, id: string, name: string): MediaFact | null {
@@ -31,10 +32,10 @@ export async function remoteUrl(dir: string, id: string, name: string): Promise<
31
32
  return f ? signedUrl(reviewKey(f, name), f.size) : null
32
33
  }
33
34
 
34
- /** a signed URL for an image's preview at a size, when the Space holds it */
35
- export async function remotePreviewUrl(dir: string, id: string, name: string, size: string): Promise<string | null> {
35
+ /** a signed URL for a file's preview at a size, when the Space holds it */
36
+ export async function remotePreviewUrl(dir: string, id: string, name: string, size: string, ext: 'webp' | 'mp4' = 'webp'): Promise<string | null> {
36
37
  const f = factOfFile(dir, id, name)
37
- return f ? signedIfUp(previewKey(f, size)) : null
38
+ return f ? signedIfUp(previewKey(f, size, ext)) : null
38
39
  }
39
40
 
40
41
  /** the path of an item's file on the disk, fetched back from the Space first when the disk let it go; null when neither
@@ -166,6 +166,12 @@ export const tileName = (t: GalleryTile): string => (t.group ? `${t.group}/${t.l
166
166
  export interface GalleryView {
167
167
  label: string
168
168
  gallery: GalleryTile[]
169
+ // a media view's optional fields, absent: `view.marks` reads on any ReviewView. `files` and `size` stay off
170
+ // this type: a consumer narrows with `'files' in view`, which an optional key here would stop
171
+ clip?: undefined
172
+ audio?: undefined
173
+ marks?: undefined
174
+ note?: undefined
169
175
  }
170
176
 
171
177
  export type ReviewView = MediaView | GalleryView
@@ -378,6 +384,17 @@ export interface ReviewReaction {
378
384
  export const OPS = ['dispatch', 'ask', 'answer', 'reassign', 'claim', 'release', 'blocked', 'fixed', 'done', 'wontfix', 'drop', 'withdraw', 'reopen', 'ready', 'seen'] as const
379
385
  export type Op = (typeof OPS)[number]
380
386
 
387
+ /** what an agent's update says of the work, at a glance: still broken, better, or fixed (it asks the owner's verdict again) */
388
+ export const UPDATE_STATES = ['broken', 'better', 'fixed'] as const
389
+ export type UpdateState = (typeof UPDATE_STATES)[number]
390
+ export const UPDATE_WORDS: Record<UpdateState, string> = { broken: 'still broken', better: 'better', fixed: 'fixed' }
391
+
392
+ /** an agent's progress post on a card: its state, and the view of the card that holds its picture, clip or sound */
393
+ export interface MessageUpdate {
394
+ state: UpdateState
395
+ view?: number
396
+ }
397
+
381
398
  /** one act on an item, one file of `thread/`, never rewritten */
382
399
  export interface Message {
383
400
  id: string
@@ -403,6 +420,10 @@ export interface Message {
403
420
  /** `seen`: the messages it read */
404
421
  of?: string[]
405
422
  fix?: { commit: string }
423
+ /** an agent's update: its line in `text`, its media a view of the item */
424
+ update?: MessageUpdate
425
+ /** his word on one message of the thread (a hint on an update): its id */
426
+ re?: string
406
427
  }
407
428
 
408
429
  /** what the store reads of one folder, what the list sends */
@@ -449,10 +470,28 @@ export function textOf(v: unknown): { text: string } | { error: string } {
449
470
  const readBy = (x: ReviewItem, party: Party): Set<string> =>
450
471
  new Set(x.thread.flatMap((m) => (m.op === 'seen' && partyOf(m.who) === party ? (m.of ?? []) : [])))
451
472
 
452
- /** the talk of the other party that `party` has not read: replies, verdicts, ratings */
473
+ /** the owner took a verdict back on an agent's card: news for the agent, which may have acted on that verdict */
474
+ const isTakeBack = (x: ReviewItem, m: Message): boolean => m.op === 'reopen' && m.who === 'owner' && x.item.origin.by === 'agent'
475
+
476
+ /** the talk of the other party that `party` has not read: replies, verdicts, ratings, his verdicts taken back */
453
477
  const unreadTalk = (x: ReviewItem, party: Party): Message[] => {
454
478
  const read = readBy(x, party)
455
- return x.thread.filter((m) => isTalk(m) && partyOf(m.who) !== party && !read.has(m.id))
479
+ return x.thread.filter((m) => (isTalk(m) || isTakeBack(x, m)) && partyOf(m.who) !== party && !read.has(m.id))
480
+ }
481
+
482
+ /** each verdict the owner took back that no agent marked seen: his reopen and the verdict it took back */
483
+ export function takenBackOf(x: ReviewItem): { m: Message; took: ReviewStatus; given: string }[] {
484
+ const unread = new Set(unreadTalk(x, 'agent').map((m) => m.id))
485
+ const out: { m: Message; took: ReviewStatus; given: string }[] = []
486
+ let v: Message | undefined
487
+ for (const n of x.thread) {
488
+ if (n.verdict !== undefined) v = n
489
+ else if (n.op === 'reopen' || isFixedUpdate(n)) {
490
+ if (v?.verdict && isTakeBack(x, n) && unread.has(n.id)) out.push({ m: n, took: v.verdict, given: v.at })
491
+ v = undefined
492
+ }
493
+ }
494
+ return out
456
495
  }
457
496
 
458
497
  /** the replies of the other party `party` has not read; a verdict is no reply (verdictOf says whether it was seen) */
@@ -474,12 +513,26 @@ export interface Verdict {
474
513
  seen: boolean
475
514
  }
476
515
 
516
+ /** an agent's update saying the work is fixed: it asks the owner's verdict again, as a reopen does */
517
+ const isFixedUpdate = (m: Message): boolean => m.update?.state === 'fixed' && partyOf(m.who) === 'agent'
518
+
519
+ /** the agent's updates on an item, oldest first */
520
+ export const updatesOf = (x: ReviewItem): Message[] => x.thread.filter((m) => m.update !== undefined && partyOf(m.who) === 'agent')
521
+
522
+ /** an update as the CLI and the page name it: `update 3 (still broken)`; null for a message that is no update */
523
+ export function updateTag(x: ReviewItem, id: string): string | null {
524
+ const all = updatesOf(x)
525
+ const k = all.findIndex((m) => m.id === id)
526
+ const u = all[k]?.update
527
+ return u ? `update ${k + 1} (${UPDATE_WORDS[u.state]})` : null
528
+ }
529
+
477
530
  export function verdictOf(x: ReviewItem): Verdict | null {
478
531
  let m: Message | undefined
479
532
  let text: string | undefined
480
533
  let rects: Rect[] | undefined
481
534
  for (const n of x.thread) {
482
- if (n.op === 'reopen') [m, text, rects] = [undefined, undefined, undefined]
535
+ if (n.op === 'reopen' || isFixedUpdate(n)) [m, text, rects] = [undefined, undefined, undefined]
483
536
  else if (n.verdict !== undefined) {
484
537
  if (m?.verdict !== n.verdict) [text, rects] = [undefined, undefined]
485
538
  m = n
@@ -574,6 +627,14 @@ export function stateOf(x: ReviewItem, superseded: boolean): ItemState {
574
627
  s = { ...keep, state: 'closed', why: 'rated' }
575
628
  continue
576
629
  }
630
+ // an agent's update on its card: still broken or better holds it in work, fixed asks the owner's verdict again
631
+ if (m.update !== undefined && i.origin.by === 'agent' && partyOf(m.who) === 'agent') {
632
+ if (m.update.state === 'fixed') {
633
+ if (s.state === 'draft' || s.state === 'claimed' || s.state === 'closed') s = { ...keep, state: 'asks' }
634
+ given = s
635
+ } else if (s.state === 'asks') s = { ...keep, state: 'draft' }
636
+ continue
637
+ }
577
638
  // the owner's words on a question answer it: it goes back to the dispatcher
578
639
  if (m.op === undefined && partyOf(m.who) === 'owner' && m.text !== undefined && s.state === 'question') {
579
640
  s = { ...keep, state: 'new' }
@@ -599,6 +660,9 @@ export function stateOf(x: ReviewItem, superseded: boolean): ItemState {
599
660
  case 'blocked':
600
661
  s = { ...keep, state: 'blocked' }
601
662
  break
663
+ case 'ready':
664
+ if (s.state === 'draft') s = { ...keep, state: 'asks' }
665
+ break
602
666
  case 'fixed':
603
667
  s = { ...keep, state: 'closed', why: 'fixed' }
604
668
  break
@@ -628,6 +692,9 @@ export function stateOf(x: ReviewItem, superseded: boolean): ItemState {
628
692
  return s
629
693
  }
630
694
 
695
+ /** a card in work: a draft on a live shot, or an agent's card its latest update calls still broken or better */
696
+ export const inWork = (x: ReviewItem): boolean => stateOf(x, false).state === 'draft'
697
+
631
698
  /** the states each op leaves from */
632
699
  const FROM: Record<Exclude<Op, 'seen'>, readonly State[]> = {
633
700
  dispatch: ['new', 'blocked'],
@@ -721,7 +788,14 @@ export function notAnswererOf(x: ReviewItem, me: { lane: string | null; session:
721
788
  const s = stateOf(x, false)
722
789
  if (op === 'seen' && s.state === 'closed' && s.why === 'approved') return null
723
790
  const id = x.item.id
724
- const takeOver = `another lane takes it over with sk review claim ${id} --as <lane>`
791
+ // the way out names claim only where claim takes it
792
+ const noClaim = allowed(s, 'claim', me.lane ?? 'agent', null, false)
793
+ const takeOver =
794
+ noClaim === null
795
+ ? `another lane takes it over with sk review claim ${id} --as <lane>`
796
+ : s.state === 'asks' || s.state === 'draft'
797
+ ? 'no other lane takes it over before the verdict'
798
+ : `no takeover: ${noClaim}`
725
799
  const claimed = s.state === 'claimed' && s.since !== undefined ? s.worker : undefined
726
800
  const lane = claimed ?? o.lane
727
801
  if (lane) return me.lane === lane ? null : `${id} is answered by lane ${lane} (${claimed ? 'its claim' : 'it made the card'}): as that lane, SK_AGENT=${lane} or --as ${lane}; ${takeOver}`
@@ -935,6 +1009,13 @@ export function messageProblems(v: unknown, name: string): string[] {
935
1009
  for (const k of ['text', 'image', 'note']) if (v[k] !== undefined && typeof v[k] !== 'string') out.push(`${k}: a text`)
936
1010
  if (v.pick !== undefined && !(Number.isInteger(v.pick) && (v.pick as number) >= 0 && v.verdict !== undefined)) out.push('pick: a view index, on a verdict')
937
1011
  if (v.op === 'seen' && !(Array.isArray(v.of) && v.of.every((x) => typeof x === 'string'))) out.push('of: the ids a seen message read')
1012
+ if (v.update !== undefined) {
1013
+ const u = v.update
1014
+ if (!obj(u) || !UPDATE_STATES.includes(u.state as UpdateState) || (u.view !== undefined && !(Number.isInteger(u.view) && (u.view as number) >= 0)))
1015
+ out.push(`update: { state: ${UPDATE_STATES.join(', ')}, view? }`)
1016
+ if (typeof v.text !== 'string') out.push('update: its line in text')
1017
+ }
1018
+ if (v.re !== undefined && !(typeof v.re === 'string' && MESSAGE_RE.test(v.re))) out.push('re: the id of a message of the thread')
938
1019
  if (v.op === undefined && v.verdict === undefined && v.rate === undefined && typeof v.text !== 'string' && !Array.isArray(v.rects))
939
1020
  out.push('a message says something: text, rects, verdict, rate or op')
940
1021
  return out
@@ -5,6 +5,7 @@ import { homedir } from 'node:os'
5
5
  import { homePort } from '../home/home-paths.ts'
6
6
  import { loadRepoConfig } from '../repo-config.ts'
7
7
  import { defaultHubPort } from '../serve/hub-port.ts'
8
+ import { machinePublicHost } from '../home/machine-host.ts'
8
9
 
9
10
  export interface PasteHosts {
10
11
  /** the repo's path, `~` for the home folder */
@@ -18,7 +19,7 @@ export interface PasteHosts {
18
19
  export async function pasteHosts(root: string): Promise<PasteHosts> {
19
20
  const c = await loadRepoConfig(root)
20
21
  const home = homedir()
21
- const host = c.serve?.publicHost
22
+ const host = machinePublicHost(c)
22
23
  return {
23
24
  root: root.startsWith(`${home}/`) ? `~${root.slice(home.length)}` : root,
24
25
  open: `http://localhost:${homePort()}/r/${encodeURIComponent(c.name)}/`,