rvlib-shipkit 2.32.0 → 2.33.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 (54) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +1 -1
  3. package/src/advisors/advisor-view.ts +28 -7
  4. package/src/advisors/edge/api.ts +1 -30
  5. package/src/advisors/project.ts +3 -3
  6. package/src/advisors/sync.ts +7 -3
  7. package/src/advisors/users-router.ts +13 -11
  8. package/src/cli/cmd_Capacity.ts +6 -2
  9. package/src/cli/cmd_Ci.ts +2 -1
  10. package/src/cli/cmd_Shot.ts +26 -4
  11. package/src/cli.ts +13 -2
  12. package/src/core/admission.ts +268 -0
  13. package/src/core/code-lines.ts +36 -21
  14. package/src/core/machine-read.ts +5 -2
  15. package/src/core/peer-sk.ts +8 -0
  16. package/src/gate/admit-heavy.ts +150 -0
  17. package/src/gate/check-runner.ts +6 -0
  18. package/src/gate/head-gate.ts +1 -1
  19. package/src/gate/job-run.ts +2 -1
  20. package/src/gate/pre-commit-discovery.ts +6 -3
  21. package/src/gate/run-check.ts +3 -0
  22. package/src/gate/run-ci.ts +4 -0
  23. package/src/home/run-daemon.ts +3 -1
  24. package/src/hooks/commit-msg-run.ts +61 -0
  25. package/src/hooks/commit-run.ts +16 -166
  26. package/src/hooks/gate-outcome.ts +108 -0
  27. package/src/hooks/git-hook.ts +9 -9
  28. package/src/hooks/hook-config.ts +2 -1
  29. package/src/hooks/pre-commit-checks.ts +1 -1
  30. package/src/hooks/run-hooks.ts +2 -1
  31. package/src/hooks/shared-file.ts +3 -2
  32. package/src/plan/planner.ts +3 -2
  33. package/src/repo-config.ts +8 -1
  34. package/src/review/answer-kinds.ts +2 -0
  35. package/src/review/cells.ts +34 -7
  36. package/src/review/format.ts +1 -1
  37. package/src/review/model.ts +3 -3
  38. package/src/review/routes.ts +2 -28
  39. package/src/review/store-parties.ts +28 -0
  40. package/src/review/store.ts +9 -1
  41. package/src/review/thread-state.ts +9 -3
  42. package/src/secrets/copy.ts +4 -4
  43. package/src/serve/hub-app/dock-st.ts +1 -1
  44. package/src/serve/hub-app/review/question-views.tsx +28 -17
  45. package/src/serve/hub-app/review/review-host.ts +6 -2
  46. package/src/serve/hub-app/review/review-list.tsx +8 -5
  47. package/src/serve/hub-app/review/review-st.ts +2 -2
  48. package/src/serve/hub-app/review/review-views.tsx +10 -7
  49. package/src/serve/hub-app/review/thread-st.ts +17 -9
  50. package/src/serve/hub-app/review/tone-bar.tsx +27 -24
  51. package/src/serve/hub-app/review/tones.ts +18 -0
  52. package/src/serve/hub-app/review.css +11 -2
  53. package/src/shot/client.ts +2 -1
  54. package/src/shot/on-place.ts +141 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## 2.33.0
2
+
3
+ ### Added
4
+
5
+ - **`sk shot <url> --on <place>`**: a still or a clip shot by another machine of the house, its own browser, the file back at `--out`; a machine shipkit does not run on is refused with the reason.
6
+ - **Heavy work waits while the machine is full** and names who uses the CPU, by repo, process and session: at most 80 s, never in `sk bump`; `sk capacity` prints the same table, and the hub's held pill names the top user.
7
+ - **A question answers in question words**: each option picks, its pencil picks with a remark; under the options « none of these », « your call » (not on a confirm) and « no answer ». Versions keep the five tones.
8
+ - **Advisors see the hub's thread names, codes, groups, search and filters**: the users' port runs the hub's own list over the advisor's rows, and an advisor has a « since you left » line.
9
+
10
+ ### Changed
11
+
12
+ - **Browser checks follow the slow tests' rule**: a case whose only misses are waits under load runs again alone; passing alone it is a warning row in `.shipkit/cache/slow-tests.json`.
13
+ - **The daemon boots in 410 MB at its peak** (was 2.5 GB): the public clean check hashes only what npm packs, and the run record holds each check's newest runs.
14
+ - **The commit hooks do less**: the check table walks only when a unit file is staged, commit-msg loads its own gates.
15
+
16
+ ### Fixed
17
+
18
+ - **A click near the end of a thread is never lost**: the column keeps its distance from its end when a line measures again, an answer shows as given at the click, a failed send puts the value back.
19
+ - **A jump to a waiting question finds its line on a busy machine** and lands at once.
20
+
1
21
  ## 2.32.0
2
22
 
3
23
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rvlib-shipkit",
3
- "version": "2.32.0",
3
+ "version": "2.33.0",
4
4
  "funding": "https://github.com/sponsors/rvion",
5
5
  "description": "All-in-one repo companion: ci gate (task DAG), auto-discovered health checks, release-contract fulfillness, asks queue, md-wiki tools, asset atelier, live tui",
6
6
  "license": "MIT",
@@ -7,12 +7,13 @@
7
7
  // (`Rules<T>` asks every key), and a value its rule refuses leaves as nothing, a fault the port logs and the owner's pass reports
8
8
  import type { Cursor } from '../review/traces.ts'
9
9
  import { personState, type Closed, type OwnerWaiting, type ThreadState } from '../review/thread-state.ts'
10
- import { threadIndex, threadView, type Cell, type ReplyCell, type ThreadRow, type ThreadView, type VerdictCell, type VersionCell, type NoteCell, type EventCell } from '../review/cells.ts'
10
+ import { listIndexOf, pageOf, queryOf, threadIndex, threadView, type ThreadPage, type Cell, type ReplyCell, type ThreadRow, type ThreadView, type VerdictCell, type VersionCell, type NoteCell, type EventCell } from '../review/cells.ts'
11
11
  import type { Item, ReviewScene, ReviewView, Verdict } from '../review/model.ts'
12
12
  import { membersOf, threadsOf, type Thread } from '../review/threads.ts'
13
13
  import { traceWords, type Trace } from '../review/traces.ts'
14
14
  import type { ProjectedItems } from './project.ts'
15
15
  import { mask, maskHits, type ScanContext } from './scan.ts'
16
+ import { CODE_RE } from '../review/thread-code.ts'
16
17
 
17
18
  /** how one key leaves: `text` scanned (a hit hidden), `id` an id of the view, `file` a served picture, `address` the
18
19
  * view's one address, `token` a short word (an enum) scanned too, `time`, `num`, `bool`, `drop` never; or a function */
@@ -100,9 +101,9 @@ const always =
100
101
  x
101
102
 
102
103
  const SIZE = table<{ w: number; h: number }>({ w: 'num', h: 'num' })
103
- /** a thread's short code (review/thread-code.ts) is the owner's, of the owner's repo's ids: the view's ids are others, so an
104
- * advisor reads none (the page draws no code where it is empty) */
105
- const CODE = always('')
104
+ /** a thread's short code (review/thread-code.ts): the owner's, of his repo's ids, given to advisorThread (the view's ids
105
+ * are others), so both say « #m6rz » of one thread; a hash of ids, no word of the store */
106
+ const CODE = (v: unknown, o: Out): unknown => (typeof v === 'string' && (v === '' || CODE_RE.test(v)) ? v : leaf('num', v, o))
106
107
  /** a panorama kept: an advisor looks around it as the owner does. A splat or a mesh is dropped, its 3D file never
107
108
  * sent: the advisor sees its poster */
108
109
  const SCENE = (s: unknown): ReviewScene | undefined => (s !== null && typeof s === 'object' && (s as ReviewScene).kind === 'pano' ? { kind: 'pano' } : undefined)
@@ -312,6 +313,7 @@ const STATE: Rules<ThreadState> = {
312
313
  recap: always(null),
313
314
  cursor: (v, o) => (v === null ? null : CURSOR(v, o)),
314
315
  updated: 'time',
316
+ works: 'bool',
315
317
  }
316
318
 
317
319
  const ROW: Rules<ThreadRow> = {
@@ -343,6 +345,22 @@ const ROW: Rules<ThreadRow> = {
343
345
  advisors: 'drop',
344
346
  }
345
347
 
348
+ /** a row a person may see, with the words their search reads of it */
349
+ export type PersonEntry = { row: ThreadRow; text: string }
350
+
351
+ /** the person's list as the owner's hub pages his: its order, its search (words, `#code`), its filters, its counts,
352
+ * what moved since their last act */
353
+ export const personPage = (rows: readonly PersonEntry[], q: URLSearchParams, since: ThreadPage['since'] = null): ThreadPage => pageOf(listIndexOf(rows, since), queryOf(q))
354
+
355
+ /** what moved since the person's last act (`left`: a word, a pick, a verdict, a thread they started; never a read, which
356
+ * the page marks as it opens), as his hub's line reads his (thread-state.ts sinceHeLeft): the threads anyone but them
357
+ * wrote in since, and how many are their turn. Null before their first act */
358
+ export function personSince(read: readonly { row: ThreadRow; view: ThreadView }[], left: string | null): ThreadPage['since'] {
359
+ if (left === null) return null
360
+ const moved = read.filter((x) => x.view.cells.some((c) => c.who !== 'advisor' && c.at > left && !(c.kind === 'event' && c.trace?.act === 'read')))
361
+ return { at: left, moved: moved.length, yours: moved.filter((x) => x.row.state.turn === 'yours').length }
362
+ }
363
+
346
364
  /** the view's whitelist, for a test that a key of the type is named */
347
365
  export const ADVISOR_VIEW_KEYS = { view: Object.keys(VIEW), row: Object.keys(ROW), item: Object.keys(ITEM), reply: Object.keys(REPLY) }
348
366
 
@@ -443,11 +461,13 @@ export function namesOf(view: ThreadView, row: ThreadRow, items: ProjectedItems[
443
461
 
444
462
  /** the thread as the advisor's page reads it: the hub's view and row of the projected items, by the output whitelist.
445
463
  * `null` when the view holds nothing of the thread */
464
+ /** `code`: the thread's code in the owner's store (review/store.ts threadCodeOf), the one his hub shows; `works`: a
465
+ * live agent works it now, as his hub's band reads it of his parties (thread-state.ts bandOf) */
446
466
  /** `cursor`: where the owner's newest word stands in the store's own thread (review/traces.ts cursorOf): the projection
447
467
  * holds no read mark, so the view takes it from there, its agent unnamed */
448
468
  export function advisorThread(
449
469
  p: Pick<ProjectedItems, 'items' | 'head'> & Partial<Pick<ProjectedItems, 'title' | 'numbers' | 'headKept'>>,
450
- o: { scan: ScanContext; now: Date; owner: string; cursor?: Cursor | null; names?: readonly string[]; real?: ThreadState; deferred?: boolean },
470
+ o: { scan: ScanContext; now: Date; owner: string; cursor?: Cursor | null; names?: readonly string[]; real?: ThreadState; deferred?: boolean; code?: string; works?: boolean },
451
471
  ): AdvisorThread | null {
452
472
  const threads = threadsOf(p.items)
453
473
  const t = threads.find((x) => x.versions.some((v) => v.item.id === p.head) || x.answers.some((a) => a.item.id === p.head)) ?? threads[0]
@@ -457,11 +477,12 @@ export function advisorThread(
457
477
  // thread's state read for them (thread-state.ts personState), the store's cursor alone (the builders would read one
458
478
  // off the agents' reads the view holds)
459
479
  const view0 = threadView(t, p.items, threads, t.head.item.id, o.now)
460
- const truth = <T extends { state: ThreadState; title: string; versions: number }>(x: T, top: number): T => ({
480
+ const truth = <T extends { state: ThreadState; title: string; versions: number; code: string }>(x: T, top: number): T => ({
461
481
  ...x,
462
482
  ...(p.title !== undefined ? { title: p.title } : {}),
483
+ code: o.code ?? '',
463
484
  ...(top > 0 ? { versions: top } : {}),
464
- state: { ...personState(o.real ?? x.state, x.state, { deferred: o.deferred ?? false, headKept: kept }), cursor: o.cursor ?? null },
485
+ state: { ...personState(o.real ?? x.state, x.state, { deferred: o.deferred ?? false, headKept: kept, works: o.works ?? false }), cursor: o.cursor ?? null },
465
486
  })
466
487
  let top = 0
467
488
  const cells = view0.cells.map((c) => {
@@ -1,5 +1,5 @@
1
1
  // what the users' port answers its page with besides a thread (wiki tools/shipkit/advisors.md, The advisor's app): the
2
- // list's page over the rows a person may see, the fixed answers of the routes the page reads at its start, a read
2
+ // search text of a share, the fixed answers of the routes the page reads at its start, a read
3
3
  // cursor, the files a page stages before the words that take them
4
4
  // the one constraint a reader breaks first: a staged file is opaque bytes under its own token, named and typed only by
5
5
  // what the browser said, cleaned (form.ts); its words take it, or the pass sweeps it within the hour
@@ -11,16 +11,6 @@ import {
11
11
  UPLOADS_PENDING_MAX,
12
12
  type UploadWire } from './types.ts'
13
13
 
14
- /** a row of the list as the port pages it: what it sorts and counts by; the rest as the builders made it */
15
- export interface PersonRow {
16
- head: string
17
- updated: string
18
- /** the thread's state as the person reads it (review/thread-state.ts personState): what the counts read */
19
- state: { turn: string; active: boolean }
20
- unread: boolean
21
- [k: string]: unknown
22
- }
23
-
24
14
  /** where the reader's cursor stands on a share: the port's own clock, a cell's time of that share's view */
25
15
  export interface ReadCursor {
26
16
  v: 1
@@ -61,25 +51,6 @@ export function wordsIn(v: unknown, out: string[] = [], depth = 0): string[] {
61
51
  return out
62
52
  }
63
53
 
64
- /** the list's page over the rows a reader may see, as the hub's own list answers it */
65
- export function pageOfRows(rows: PersonRow[], q: URLSearchParams): unknown {
66
- rows.sort((a, b) => b.updated.localeCompare(a.updated))
67
- const limit = Math.max(1, Math.min(500, Number(q.get('limit')) || 50))
68
- const offset = Math.max(0, Number(q.get('offset')) || 0)
69
- return {
70
- rows: rows.slice(offset, offset + limit),
71
- total: rows.length,
72
- offset,
73
- limit,
74
- counts: { threads: rows.length, active: rows.filter((r) => r.state.active).length, waiting: rows.filter((r) => r.state.turn === 'yours').length, unread: rows.filter((r) => r.unread).length },
75
- byWait: {},
76
- subjects: [],
77
- lanes: [],
78
- broken: [],
79
- since: null,
80
- }
81
- }
82
-
83
54
  /** the staged files of some words moved under their entry, in their order: what the record names, or why not */
84
55
  export async function takeStaged(bucket: Bucket, scope: 's' | 'p', id: string, tokens: readonly string[], entry: string): Promise<UploadWire[] | string> {
85
56
  const out: UploadWire[] = []
@@ -113,8 +113,8 @@ export interface ProjectedItems {
113
113
  masked: Masked[]
114
114
  /** each id of the view and the store's id it stands for: an advice names the view's */
115
115
  ids: Map<string, string>
116
- /** the thread's title as the view may say it: its kept head's, else its own when the scan passes it, else neutral;
117
- * never the title of an older version that happened to pass */
116
+ /** the thread's name as the owner's hub says it (review/threads.ts threadTitle), its hits masked: one name on both
117
+ * sides, never a version's own caption */
118
118
  title: string
119
119
  /** each version of the view by its id and the thread's own number of it: v3 reads « v3 » whatever the view holds before it */
120
120
  numbers: Map<string, number>
@@ -217,7 +217,7 @@ export function projectItems(input: ItemsInput): ProjectedItems {
217
217
  const headKept = kept.has(headId)
218
218
  const head = headKept ? opaqueItem(share, headId) : (items.at(-1)?.item.id ?? opaqueItem(share, headId))
219
219
  const own = threadTitle(input.thread)
220
- const title = headKept ? (items.find((x) => x.item.id === head)?.item.title ?? own) : mask(own, maskHits(own, input.scan))
220
+ const title = mask(own, maskHits(own, input.scan))
221
221
  const shown = input.thread.versions.filter((x) => kept.has(x.item.id)).length
222
222
  return { items, head, masked, ids, title, numbers, versions: input.thread.versions.length, shown, headKept }
223
223
  }
@@ -7,7 +7,7 @@ import { createHash } from 'node:crypto'
7
7
  import { existsSync, readFileSync, statSync } from 'node:fs'
8
8
  import { HOUSE_LAYOUT } from '../core/house-layout.ts'
9
9
  import { identitiesFile } from '../core/identities-root.ts'
10
- import { imageFile, readAll, storeDir, threadFile } from '../review/store.ts'
10
+ import { imageFile, readAll, storeDir, threadCodeOf, threadFile } from '../review/store.ts'
11
11
  import { isGallery, verdictOf, type ReviewItem } from '../review/model.ts'
12
12
  import type { ReplyCell } from '../review/cells.ts'
13
13
  import { namedFiles } from '../review/file-tags.ts'
@@ -26,7 +26,8 @@ import { keepLogins } from './login.ts'
26
26
  import { identityOfRoot } from './speaks.ts'
27
27
  import { ownerNameOf } from './owner-name.ts'
28
28
  import { displayOf, isLive, startPlacesOf, readState, servedShares, withState, type OwnerState, type Share, type ShareRead } from './owner-store.ts'
29
- import { threadState } from '../review/thread-state.ts'
29
+ import { bandOf, threadState } from '../review/thread-state.ts'
30
+ import { partiesOfStore } from '../review/store-parties.ts'
30
31
 
31
32
  /** a picture as the advisor gets it: re-encoded, no metadata (EXIF, PNG text) survives */
32
33
  export type Encode = (path: string) => Promise<Bytes>
@@ -203,7 +204,10 @@ export async function prepare(s: OwnerState, x: Share, o: { words: string[]; now
203
204
  }
204
205
  const answers = rightsOf(s.rights, { person: x.advisor, project: x.repo, thread: x.address }).answers
205
206
  const items = projectItems({ thread, share: x.id, advisor: x.advisor, answers, scan, include: x.include, picture: (itemId, name, of) => nameOf(resolve(itemId, name, of)) })
206
- const theirs = advisorThread(items, { scan, now: o.now, owner, cursor: cursorOf(thread, o.now), names: storeNames(thread), real: threadState(thread, o.now), deferred: x.deferred === true })
207
+ const real = threadState(thread, o.now)
208
+ // the band his hub draws: a live agent works it now, read of his parties (never theirs to read)
209
+ const works = real.turn === 'agents' && bandOf(real, (await partiesOfStore(storeDir(x.root))).parties, o.now) === 'working'
210
+ const theirs = advisorThread(items, { scan, now: o.now, owner, cursor: cursorOf(thread, o.now), names: storeNames(thread), real, deferred: x.deferred === true, code: threadCodeOf(storeDir(x.root))(thread), works })
207
211
  if (theirs !== null) {
208
212
  // their words at their own time among the thread's cells, as the owner's hub draws them (a stable sort keeps the
209
213
  // builders' order of cells of one time)
@@ -10,7 +10,8 @@
10
10
  // terminal (tests/advisors-users-caller.test.ts walks the graph)
11
11
  import { landAdvice, landProposal } from './advice.ts'
12
12
  import { advisorBundle, type AppBundle } from './app.ts'
13
- import { dropEntry, dropStaged, etag, ID_RE, MSG_RE, NAME_RE, PARTIES, pageOfRows, readCursor, SPEC, stageFile, takeStaged, TOKEN, tokensOf, wordsIn, type PersonRow, type ReadCursor } from './edge/api.ts'
13
+ import { dropEntry, dropStaged, etag, ID_RE, MSG_RE, NAME_RE, PARTIES, readCursor, SPEC, stageFile, takeStaged, TOKEN, tokensOf, wordsIn, type ReadCursor } from './edge/api.ts'
14
+ import { personPage, personSince, type PersonEntry } from './advisor-view.ts'
14
15
  import type { Bytes } from './edge/bucket.ts'
15
16
  import { APP_HEADER, BASE, bytesB64url, csrfOf, CSRF_HEADER, NOT_FOUND, status, type EdgeEnv } from './edge/handler.ts'
16
17
  import { bytesOf } from './edge/form.ts'
@@ -265,21 +266,22 @@ export async function liveAnswer(req: Request, caller: Caller, env: UsersEnv): P
265
266
  return x === undefined || p === null || !p.manifest!.ids.includes(id) ? null : { x, p }
266
267
  }
267
268
  if (read && path === '/api/review/threads') {
268
- const url = new URL(req.url)
269
- const ws = (url.searchParams.get('q') ?? '').toLowerCase().split(/\s+/).filter(Boolean)
270
- const rows: PersonRow[] = []
269
+ // the hub's own page over the rows the person may see: its order, search (words, `#code`), filters and counts
270
+ const rows: PersonEntry[] = []
271
+ const read: Parameters<typeof personSince>[0][number][] = []
271
272
  for (const x of caller.shares) {
272
273
  const p = await liveOf(x, env, now)
273
274
  if (p === null) continue
274
- const row = p.theirs!.row as unknown as PersonRow
275
- if (ws.length > 0) {
276
- const text = wordsIn([row, p.theirs!.view]).join('\n')
277
- if (!ws.every((w) => text.includes(w))) continue
278
- }
275
+ const row = p.theirs!.row
279
276
  const cursor = await readCursor(env.bucket, x.id)
280
- rows.push({ ...row, unread: cursor === null || row.updated > cursor.upTo })
277
+ rows.push({ row: { ...row, unread: cursor === null || row.updated > cursor.upTo }, text: wordsIn([row, p.theirs!.view]).join('\n') })
278
+ read.push({ row, view: p.theirs!.view })
281
279
  }
282
- return json(pageOfRows(rows, url.searchParams), 200, api)
280
+ // their last act: a word, a pick, a verdict, a thread they started, as his own line counts his
281
+ const s = readState(env.dir)
282
+ const ids = new Set(caller.shares.map((x) => x.advisor))
283
+ const left = [...s.advice.filter((a) => ids.has(a.advisor)), ...s.proposals.filter((p) => ids.has(p.advisor))].map((a) => a.at).sort().at(-1) ?? null
284
+ return json(personPage(rows, new URL(req.url).searchParams, personSince(read, left)), 200, api)
283
285
  }
284
286
  const one = new RegExp(`^/api/review/threads/(${ID})$`).exec(path)
285
287
  if (read && one !== null) {
@@ -1,5 +1,7 @@
1
1
  // sk capacity: how many lanes this repo runs now. Report only, exit 0 always: the orchestrator decides.
2
2
  import { Command, Option } from './clip.ts'
3
+ import { whoLines } from '../core/admission.ts'
4
+ import { readWho } from '../gate/admit-heavy.ts'
3
5
  import { capacityLines, readCapacity } from '../core/capacity.ts'
4
6
 
5
7
  export class CapacityCommand extends Command {
@@ -9,7 +11,7 @@ export class CapacityCommand extends Command {
9
11
  static override usage = Command.Usage({
10
12
  category: 'Health',
11
13
  description: 'how many lanes this repo runs now: the machine\'s cores, the cores in use, the lanes live on it',
12
- details: 'reads the cores, the cores really in use (the CPU times, smoothed over 20 s by the daemon, else a 0.4 s sample), the 1 minute load and the agents whose transcript moved in the last 3 minutes, every account and repo. A free core is one neither in use nor held by a live agent; the load counts only once every core is taken, and alone where the machine gives no CPU times. The answer is this repo\'s live lanes plus one a free core, never under one. --max <n> is the maximum the owner gave: it replaces the number. Only a dying machine (85% of its cores in use and a load of twice its cores, or critical memory) stops a lane, the maximum included. Run it before a lane starts. Report only, exit 0 always.',
14
+ details: 'reads the cores, the cores really in use (the CPU times, smoothed over 20 s by the daemon, else a 0.4 s sample), the 1 minute load and the agents whose transcript moved in the last 3 minutes, every account and repo. A free core is one neither in use nor held by a live agent; the load counts only once every core is taken, and alone where the machine gives no CPU times. The answer is this repo\'s live lanes plus one a free core, never under one. --max <n> is the maximum the owner gave: it replaces the number. Only a dying machine (85% of its cores in use and a load of twice its cores, or critical memory) stops a lane, the maximum included. Run it before a lane starts. Then who uses the CPU, one ps grouped by repo (the Claude session above a process, else a path of its command) with the commands that lead each and its sessions: the same names a heavy command prints while it waits on a full machine. Report only, exit 0 always.',
13
15
  examples: [
14
16
  ['before a lane starts', 'sk capacity'],
15
17
  ['with the maximum the owner gave', 'sk capacity --max 5'],
@@ -23,8 +25,10 @@ export class CapacityCommand extends Command {
23
25
  async execute(): Promise<number> {
24
26
  const max = this.max == null ? null : Number(this.max)
25
27
  if (max != null && !(Number.isInteger(max) && max >= 1)) { this.context.stdout.write(`FAIL: --max takes a whole number of lanes, 1 or more, got ${this.max}\n`); return 2 }
28
+ const reading = readWho()
26
29
  const { capacity, live, repo } = readCapacity(process.cwd(), max)
27
- this.context.stdout.write(this.json ? `${JSON.stringify({ ...capacity, repo, live })}\n` : `${capacityLines(capacity, live, repo).join('\n')}\n`)
30
+ const who = await reading
31
+ this.context.stdout.write(this.json ? `${JSON.stringify({ ...capacity, repo, live, who })}\n` : `${[...capacityLines(capacity, live, repo), ...whoLines(who)].join('\n')}\n`)
28
32
  return 0
29
33
  }
30
34
  }
package/src/cli/cmd_Ci.ts CHANGED
@@ -79,7 +79,7 @@ export class CiCommand extends Command {
79
79
 
80
80
  private async gate(root: string): Promise<number> {
81
81
  const print = (l: string): void => { this.context.stdout.write(`${l}\n`) }
82
- const sel = { bail: this.bail, json: this.json, skipGroups: this.skip, withIds: this.withIds, onlyIds: listFlag(this.only), fresh: this.fresh, verbose: this.verbose, ...(this.full ? { tests: 'full' as const } : {}), print }
82
+ const sel = { admit: true, bail: this.bail, json: this.json, skipGroups: this.skip, withIds: this.withIds, onlyIds: listFlag(this.only), fresh: this.fresh, verbose: this.verbose, ...(this.full ? { tests: 'full' as const } : {}), print }
83
83
  if (this.headCheckout) return await (await import('../gate/head-gate.ts')).gateHeadCheckout(root, sel)
84
84
  if (this.head) return await (await import('../gate/head-gate.ts')).runHeadGate(root, sel)
85
85
  // a stale toolkit updates itself and restarts this exact invocation
@@ -87,6 +87,7 @@ export class CiCommand extends Command {
87
87
  await (await import('../core/self-update.ts')).maybeSelfUpdateAndRestart(root, { fresh: this.fresh })
88
88
  try {
89
89
  const opts = {
90
+ admit: true,
90
91
  bail: this.bail,
91
92
  json: this.json,
92
93
  fix: true,
@@ -16,7 +16,7 @@ export const renderShot = (r: ShotResult, cwd: string): string[] => {
16
16
  const rel = relative(cwd, f)
17
17
  return rel.startsWith('..') ? f : rel
18
18
  }
19
- const lines = [`ok ${shown(r.out)} in ${r.ms} ms (${phases}; ${r.via}) ${r.note}`]
19
+ const lines = [`ok ${shown(r.out)} in ${r.ms} ms (${phases}; ${r.on != null ? `on ${r.on}, ` : ''}${r.via}) ${r.note}`]
20
20
  for (const f of r.tiles?.slice(1) ?? []) lines.push(`ok ${shown(f)} (next tile)`)
21
21
  for (const e of r.errors.slice(0, 10)) lines.push(`WARN page ${e}`)
22
22
  if (r.errors.length > 10) lines.push(`WARN page ${r.errors.length - 10} more errors`)
@@ -30,6 +30,16 @@ export const fileUrlOf = (s: string, cwd: string): string => {
30
30
  return statSync(p, { throwIfNoEntry: false })?.isFile() ? pathToFileURL(p).href : s
31
31
  }
32
32
 
33
+ /** the house checkout's path under the home: a place runs its shot from its own at the same place */
34
+ async function houseRelHere(cwd: string): Promise<string> {
35
+ const { homedir } = await import('os')
36
+ const { houseRootOf } = await import('../home/home-start.ts')
37
+ const { installedHouseRoot } = await import('../home/home-launchd.ts')
38
+ const root = installedHouseRoot() ?? houseRootOf(cwd, homedir())
39
+ if (root == null || !root.startsWith(`${homedir()}/`)) throw new Error('FAIL shot --on: no house checkout under the home folder here, so the place has none to run from')
40
+ return relative(homedir(), root)
41
+ }
42
+
33
43
  export class ShotCommand extends Command {
34
44
  static override paths = [['shot']]
35
45
  static essential = { args: '<url>' }
@@ -38,7 +48,7 @@ export class ShotCommand extends Command {
38
48
  category: 'Serve',
39
49
  description: 'a webp of any url through the warm browser (a png with --out x.png), or an mp4 clip with --video',
40
50
  details:
41
- '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: one file while the page fits the tallest side of its format (webp 16383 px, jpg and png 65535), else tiles in that format, <name>-1, <name>-2… top to bottom, every one printed, so nothing of the page is lost and the format stays the one asked (a jpg instead of a webp would change what the caller asked for, a cut would drop the end of the page); a whole page stops at 131072 px, the cut said in the note. 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. A theme: --theme <hub theme> draws the page with that prefers-color-scheme and the hub reads its `hub:theme` as that theme, written nowhere, so the next shot keeps none; with no flag every shot of the machine takes serve.shotTheme of the house config.',
51
+ '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: one file while the page fits the tallest side of its format (webp 16383 px, jpg and png 65535), else tiles in that format, <name>-1, <name>-2… top to bottom, every one printed, so nothing of the page is lost and the format stays the one asked (a jpg instead of a webp would change what the caller asked for, a cut would drop the end of the page); a whole page stops at 131072 px, the cut said in the note. 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. A theme: --theme <hub theme> draws the page with that prefers-color-scheme and the hub reads its `hub:theme` as that theme, written nowhere, so the next shot keeps none; with no flag every shot of the machine takes serve.shotTheme of the house config. Another place: --on <place> runs the same shot on a machine that reports to the hq (sk machines), over ssh, by its own `sk shot` from its house checkout, so its warm browser draws the page and its localhost is its own; each file comes back to --out and leaves its /tmp. A place that does not answer ssh, has no shot service or runs a shipkit whose sk shot refuses the ask fails in one line with the fix. wm, the GPU box, runs no shipkit place (no daemon, no pm, no shot service): --on wm is refused; a repo whose repo.config.ts names it in browsers.box already films on it with a plain sk shot.',
42
52
  examples: [
43
53
  ['a still of a running dev server', 'sk shot localhost:5173/'],
44
54
  ['a whole tall page at a phone width', 'sk shot :5173/guest --viewport 390,844 --full --out shots/guest.png'],
@@ -46,6 +56,7 @@ export class ShotCommand extends Command {
46
56
  ['a 3 s clip', 'sk shot :4808/ --video 3 --out clips/walk.mp4'],
47
57
  ['a clip of a whole web app page, canvas or not', 'sk shot :5173/settings --video 3 --dom'],
48
58
  ['the hub in its dark theme, whatever the default', 'sk shot :4804/ --theme dark'],
59
+ ['the hub of another machine of the house, shot by its own browser, the file brought here', 'sk shot :4799/ --on studio --out shots/studio.webp'],
49
60
  ['a slow 3D page stepped frame by frame through window.__trailerStep(t)', 'sk shot :4808/ --video 3 --step __trailerStep --out clips/walk.mp4'],
50
61
  ],
51
62
  })
@@ -64,14 +75,25 @@ export class ShotCommand extends Command {
64
75
  step = Option.String('--step', { description: 'a window function the page draws time t (s) in: a clip steps it frame by frame, a still draws --at' })
65
76
  at = Option.String('--at', { description: 'with --step, the time a still is drawn at (default 0)' })
66
77
  theme = Option.String('--theme', { description: 'dark, dim, grey or light: the page drawn in that hub theme, this shot only (default the house config serve.shotTheme)' })
78
+ on = Option.String('--on', { description: 'another place of the house (sk machines): the shot runs in its own warm browser, its localhost is its own, the file comes back to --out; wm, a box with no shipkit place, is refused' })
67
79
  json = Option.Boolean('--json', false, { description: 'one json line: out, ms, phases, errors, note, via, and tiles when a whole page is tiled' })
68
80
 
69
81
  async execute(): Promise<number> {
70
82
  const cwd = process.cwd()
71
83
  const err = (l: string) => this.context.stderr.write(`${l}\n`)
72
84
  try {
73
- 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, theme: this.theme }, cwd)
74
- const r = isClip(a) ? await clipUrl(a, err) : await shotUrl(a, err)
85
+ const place = this.on == null ? 'here' : await (await import('../shot/on-place.ts')).lookPlace(this.on)
86
+ if (place !== 'here' && 'refused' in place) throw new Error(place.refused)
87
+ const a = askOf({ url: place === 'here' ? fileUrlOf(this.url, cwd) : this.url, 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, theme: this.theme }, cwd)
88
+ const r =
89
+ place !== 'here'
90
+ ? await (async () => {
91
+ const { placeSsh, shotOnPlace } = await import('../shot/on-place.ts')
92
+ return shotOnPlace(place, a, { ssh: placeSsh, houseRel: await houseRelHere(cwd), say: err })
93
+ })()
94
+ : isClip(a)
95
+ ? await clipUrl(a, err)
96
+ : await shotUrl(a, err)
75
97
  if (this.json) this.context.stdout.write(`${JSON.stringify(r)}\n`)
76
98
  else for (const l of renderShot(r, cwd)) this.context.stdout.write(`${l}\n`)
77
99
  return 0
package/src/cli.ts CHANGED
@@ -58,6 +58,14 @@ async function headGate(raw: string[]): Promise<number | null> {
58
58
  return o === null ? null : await m.runHeadGate(process.cwd(), { ...o, print: (l) => process.stdout.write(`${l}\n`) })
59
59
  }
60
60
 
61
+ /** a heavy line waits while the machine is full (gate/admit-heavy.ts; `sk ci` waits inside the gate, before its
62
+ * first heavy check that misses the cache); a module that fails to load lets it run */
63
+ async function admitHeavy(argv: readonly string[]): Promise<void> {
64
+ let m
65
+ try { m = await import('./gate/admit-heavy.ts') } catch { return }
66
+ await m.admitLine(argv, process.cwd())
67
+ }
68
+
61
69
  /** true for the one line the inbox hook is wired as, `sk thread inbox --hook`, nothing else on it */
62
70
  export const isInboxHookLine = (raw: readonly string[]): boolean => raw.length === 3 && raw[0] === 'thread' && raw[1] === 'inbox' && raw[2] === '--hook'
63
71
 
@@ -97,8 +105,10 @@ if (import.meta.main) {
97
105
  call.matched('line' in line ? commandPath(() => line.line.command) : 'help', performance.now() - t0)
98
106
  const pm = pmAsked(argv)
99
107
  await b.takeBackAtBoot()
100
- if ('line' in line) process.exitCode = await line.line.run()
101
- else console.log(line.version)
108
+ if ('line' in line) {
109
+ await admitHeavy(argv)
110
+ process.exitCode = await line.line.run()
111
+ } else console.log(line.version)
102
112
  await pm
103
113
  } else {
104
114
  let cli = b.cli!
@@ -112,6 +122,7 @@ if (import.meta.main) {
112
122
  call.matched(commandPath(() => cli.process(run)), performance.now() - t0)
113
123
  const pm = pmAsked(run)
114
124
  await b.takeBackAtBoot()
125
+ await admitHeavy(run)
115
126
  await cli.runExit(run)
116
127
  await pm
117
128
  }