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.
- package/CHANGELOG.md +45 -0
- package/package.json +1 -1
- package/src/agent-time/live.ts +153 -0
- package/src/agent-time/render.ts +28 -14
- package/src/agent-time/report.ts +46 -25
- package/src/agent-time/store.ts +30 -10
- package/src/agent-time/timeline.ts +43 -15
- package/src/annex/offload.ts +16 -7
- package/src/asks/asks-queue.ts +32 -11
- package/src/check.ts +3 -1
- package/src/checks/SK004-gitignore-policy.check.ts +32 -11
- package/src/checks/SK027-agent-wiki-links.check.ts +1 -1
- package/src/checks/SK033-global-contribution.check.ts +1 -1
- package/src/checks/SK036-draft-media-size.check.ts +1 -1
- package/src/checks/SK040-release-words.check.ts +1 -1
- package/src/checks/SK042-post-kinds.check.ts +1 -1
- package/src/checks/SK044-behind-upstream.check.ts +38 -0
- package/src/cli/cmd_Annex.ts +12 -7
- package/src/cli/cmd_Asks.ts +2 -0
- package/src/cli/cmd_Assets.ts +5 -5
- package/src/cli/cmd_Backup.ts +16 -8
- package/src/cli/cmd_Bump.ts +1 -0
- package/src/cli/cmd_Capacity.ts +30 -0
- package/src/cli/cmd_Check.ts +1 -0
- package/src/cli/cmd_Checks.ts +13 -1
- package/src/cli/cmd_Ci.ts +3 -2
- package/src/cli/cmd_Commands.ts +61 -16
- package/src/cli/cmd_ConfigKeys.ts +17 -0
- package/src/cli/cmd_Home.ts +1 -30
- package/src/cli/cmd_Hooks.ts +1 -0
- package/src/cli/cmd_Keys.ts +4 -1
- package/src/cli/cmd_Lanes.ts +35 -0
- package/src/cli/cmd_Mv.ts +7 -7
- package/src/cli/cmd_Rec.ts +22 -7
- package/src/cli/cmd_Reflect.ts +1 -0
- package/src/cli/cmd_Releases.ts +1 -0
- package/src/cli/cmd_Review.ts +200 -49
- package/src/cli/cmd_Secret.ts +41 -2
- package/src/cli/cmd_Shot.ts +16 -4
- package/src/cli/cmd_Status.ts +7 -5
- package/src/cli/cmd_Time.ts +13 -5
- package/src/cli/cmd_Tmp.ts +82 -0
- package/src/cli/cmd_Veille.ts +10 -6
- package/src/cli/cmd_Wiki.ts +1 -0
- package/src/cli/family-help.ts +136 -0
- package/src/cli/family-pages.ts +0 -19
- package/src/cli/kit/calls.ts +35 -0
- package/src/cli/kit/project-cli.ts +2 -12
- package/src/cli/registry.ts +52 -7
- package/src/cli.ts +8 -4
- package/src/collections/pings.ts +1 -1
- package/src/core/capacity.ts +127 -0
- package/src/core/check-runner.ts +91 -16
- package/src/core/floor-resolve.ts +6 -2
- package/src/core/floor.ts +6 -2
- package/src/core/history-files.ts +18 -0
- package/src/core/jobs.ts +35 -16
- package/src/core/layout.ts +2 -2
- package/src/core/motherhome.ts +67 -9
- package/src/core/nearest.ts +16 -0
- package/src/core/remove-tree.ts +19 -0
- package/src/core/runs.ts +12 -3
- package/src/core/slots.ts +49 -12
- package/src/core/throwaway-worktree.ts +22 -4
- package/src/core/trace-audit.ts +21 -5
- package/src/drill/run.ts +5 -2
- package/src/home/daemon-jobs.ts +41 -4
- package/src/home/gui-app/ShipkitGui.swift +1 -0
- package/src/home/home-launchd.ts +11 -3
- package/src/home/home-routes.ts +11 -4
- package/src/home/machine-host.ts +65 -0
- package/src/home/machine-stores.ts +19 -17
- package/src/home/machine-temp.ts +485 -0
- package/src/home/other-macs.ts +74 -0
- package/src/home/run-daemon.ts +10 -2
- package/src/home/serve-web.ts +2 -2
- package/src/home/via-hub.ts +6 -1
- package/src/init-repo.ts +7 -3
- package/src/ledger/gate-checks.ts +3 -2
- package/src/ledger/git-key.ts +25 -4
- package/src/ledger/git-scan.ts +10 -0
- package/src/ledger/ledger.ts +6 -0
- package/src/ledger/store.ts +6 -0
- package/src/media-store/backup/daemon.ts +92 -20
- package/src/media-store/backup/keys.ts +21 -6
- package/src/media-store/backup/manifest.ts +52 -11
- package/src/media-store/backup/restore.ts +17 -10
- package/src/media-store/backup/run.ts +26 -17
- package/src/media-store/backup/sources.ts +168 -22
- package/src/media-store/backup/watch.ts +106 -0
- package/src/media-store/daemon.ts +36 -8
- package/src/media-store/hand.ts +3 -1
- package/src/mv/mv-md.ts +167 -56
- package/src/pb/run-pb.ts +2 -10
- package/src/plan/repo-source.ts +25 -14
- package/src/recordings/model.ts +1 -1
- package/src/reflect/transcript.ts +56 -11
- package/src/release/run-bump.ts +3 -2
- package/src/release/run-release.ts +12 -4
- package/src/releases/from-card.ts +45 -3
- package/src/releases/model.ts +6 -0
- package/src/releases/store.ts +8 -1
- package/src/repo-config.ts +5 -3
- package/src/review/cells.ts +26 -4
- package/src/review/format.ts +34 -10
- package/src/review/media-kind.ts +14 -11
- package/src/review/media-read.ts +6 -5
- package/src/review/model.ts +85 -4
- package/src/review/paste.ts +2 -1
- package/src/review/previews.ts +123 -36
- package/src/review/routes.ts +29 -18
- package/src/review/store.ts +89 -19
- package/src/review/threads.ts +7 -5
- package/src/review/trailer-model.ts +2 -2
- package/src/secrets/copy.ts +110 -0
- package/src/secrets/list.ts +17 -7
- package/src/serve/hub-app/home-strip.css +5 -0
- package/src/serve/hub-app/home-strip.tsx +18 -0
- package/src/serve/hub-app/hub-app.tsx +2 -1
- package/src/serve/hub-app/hub.css +14 -0
- package/src/serve/hub-app/inbox.css +1 -0
- package/src/serve/hub-app/pull-refresh.tsx +88 -0
- package/src/serve/hub-app/review/review-cells.tsx +52 -13
- package/src/serve/hub-app/review/review-list.tsx +6 -1
- package/src/serve/hub-app/review/review-st.ts +6 -5
- package/src/serve/hub-app/review/review-thread.tsx +3 -1
- package/src/serve/hub-app/review/review-views.tsx +18 -11
- package/src/serve/hub-app/review/thread-st.ts +82 -14
- package/src/serve/hub-app/review.css +15 -2
- package/src/serve/hub-runtime.ts +2 -1
- package/src/serve/run-serve.ts +4 -2
- package/src/serve/serve-hub.ts +9 -2
- package/src/shot/client.ts +4 -2
- package/src/shot/serve-shot.ts +71 -2
- package/src/shot/shooter.ts +65 -11
- package/src/shot/shot-ask.ts +32 -9
- package/src/suite/child-tools.ts +45 -0
- package/src/suite/judge-suites.ts +10 -22
- package/src/suite/select.ts +95 -9
- package/src/suite/suite-cli.ts +38 -14
- package/src/suite/suite-cores.ts +68 -0
- package/src/suite/suite-reads-preload.ts +8 -6
- package/src/suite/test-units.ts +31 -12
- package/src/trailer/graph.ts +2 -1
- package/src/ts/config.ts +21 -0
- package/src/ts/rename.ts +37 -13
- package/src/ts/workspaces.ts +45 -0
- package/src/wiki/run-wiki.ts +7 -2
- package/src/wiki/scan-md.ts +2 -1
- 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))
|
package/src/releases/model.ts
CHANGED
|
@@ -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 */
|
package/src/releases/store.ts
CHANGED
|
@@ -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)
|
package/src/repo-config.ts
CHANGED
|
@@ -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,
|
|
69
|
-
*
|
|
70
|
-
*
|
|
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 */
|
package/src/review/cells.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
|
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),
|
package/src/review/format.ts
CHANGED
|
@@ -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:
|
|
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
|
-
|
|
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 &&
|
|
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
|
-
|
|
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
|
package/src/review/media-kind.ts
CHANGED
|
@@ -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 (
|
|
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
|
-
/**
|
|
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
|
|
75
|
-
const key = previewKey({ sha }, size)
|
|
76
|
-
// up already: a card that shares the
|
|
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
|
-
|
|
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
|
}
|
package/src/review/media-read.ts
CHANGED
|
@@ -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
|
|
15
|
-
|
|
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
|
|
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
|
package/src/review/model.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
package/src/review/paste.ts
CHANGED
|
@@ -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
|
|
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)}/`,
|