rvlib-shipkit 2.22.1 → 2.24.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 (139) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/package.json +1 -1
  3. package/src/agent-time/render.ts +28 -14
  4. package/src/agent-time/report.ts +46 -25
  5. package/src/agent-time/store.ts +30 -10
  6. package/src/agent-time/timeline.ts +43 -15
  7. package/src/annex/annex.ts +3 -0
  8. package/src/annex/born.ts +464 -0
  9. package/src/annex/flush.ts +46 -0
  10. package/src/annex/offload.ts +171 -38
  11. package/src/annex/snapshots.ts +53 -0
  12. package/src/annex/tidy.ts +368 -0
  13. package/src/asks/asks-queue.ts +32 -11
  14. package/src/checks/SK041-annex-links.check.ts +4 -2
  15. package/src/checks/SK043-scratch-on-the-mac.check.ts +45 -0
  16. package/src/checks/SK044-behind-upstream.check.ts +38 -0
  17. package/src/cli/cmd_Annex.ts +60 -9
  18. package/src/cli/cmd_Asks.ts +2 -0
  19. package/src/cli/cmd_Backup.ts +7 -5
  20. package/src/cli/cmd_Bump.ts +1 -0
  21. package/src/cli/cmd_Capacity.ts +26 -0
  22. package/src/cli/cmd_Check.ts +1 -0
  23. package/src/cli/cmd_Checks.ts +1 -0
  24. package/src/cli/cmd_Ci.ts +1 -0
  25. package/src/cli/cmd_Commands.ts +50 -14
  26. package/src/cli/cmd_Home.ts +0 -1
  27. package/src/cli/cmd_Hooks.ts +1 -0
  28. package/src/cli/cmd_Mv.ts +1 -0
  29. package/src/cli/cmd_Rec.ts +17 -7
  30. package/src/cli/cmd_Reflect.ts +1 -0
  31. package/src/cli/cmd_Releases.ts +1 -0
  32. package/src/cli/cmd_Review.ts +124 -17
  33. package/src/cli/cmd_Secret.ts +41 -2
  34. package/src/cli/cmd_Shot.ts +1 -0
  35. package/src/cli/cmd_Status.ts +1 -0
  36. package/src/cli/cmd_Time.ts +3 -1
  37. package/src/cli/cmd_Tmp.ts +82 -0
  38. package/src/cli/cmd_Wiki.ts +1 -0
  39. package/src/cli/registry.ts +13 -1
  40. package/src/collections/pings.ts +1 -1
  41. package/src/core/capacity.ts +71 -0
  42. package/src/core/check-runner.ts +86 -15
  43. package/src/core/machine-db.ts +8 -0
  44. package/src/core/motherhome.ts +67 -9
  45. package/src/core/slots.ts +49 -12
  46. package/src/core/trace-audit.ts +4 -1
  47. package/src/drill/run.ts +5 -2
  48. package/src/home/daemon-jobs.ts +10 -3
  49. package/src/home/global-units.ts +3 -0
  50. package/src/home/gui-app/ShipkitGui.swift +1 -0
  51. package/src/home/home-launchd.ts +11 -3
  52. package/src/home/home-routes.ts +11 -4
  53. package/src/home/machine-host.ts +65 -0
  54. package/src/home/machine-stores.ts +30 -4
  55. package/src/home/machine-temp.ts +493 -0
  56. package/src/home/other-macs.ts +74 -0
  57. package/src/home/pm.ts +4 -1
  58. package/src/home/run-daemon.ts +10 -2
  59. package/src/home/run-pm.ts +1 -0
  60. package/src/home/serve-web.ts +2 -2
  61. package/src/home/via-hub.ts +6 -1
  62. package/src/identities/identities.ts +92 -24
  63. package/src/init-repo.ts +7 -3
  64. package/src/ledger/ledger.ts +6 -0
  65. package/src/ledger/store.ts +6 -0
  66. package/src/media-store/backup/keys.ts +21 -6
  67. package/src/media-store/backup/manifest.ts +52 -11
  68. package/src/media-store/backup/restore.ts +17 -10
  69. package/src/media-store/backup/run.ts +5 -2
  70. package/src/media-store/backup/sources.ts +2 -1
  71. package/src/media-store/daemon.ts +2 -2
  72. package/src/media-store/purge.ts +4 -0
  73. package/src/mv/mv-md.ts +121 -42
  74. package/src/recordings/load.ts +3 -3
  75. package/src/recordings/model.ts +7 -0
  76. package/src/recordings/open.ts +12 -0
  77. package/src/recordings/presets.ts +12 -5
  78. package/src/recordings/recorder-app/Capture.swift +34 -5
  79. package/src/recordings/recorder-app/Clip.swift +126 -17
  80. package/src/recordings/recorder-app/Editor.swift +177 -7
  81. package/src/recordings/recorder-app/Hud.swift +189 -0
  82. package/src/recordings/recorder-app/Tray.swift +179 -36
  83. package/src/recordings/recorder-app/icon.svg +16 -0
  84. package/src/recordings/recorder-app/main.swift +349 -18
  85. package/src/recordings/recorder-app.ts +8 -4
  86. package/src/recordings/recorder.shipkit.ts +2 -1
  87. package/src/recordings/routes.ts +52 -6
  88. package/src/recordings/run-recorder.ts +2 -1
  89. package/src/recordings/share.ts +27 -0
  90. package/src/recordings/take.ts +36 -4
  91. package/src/recordings/view.ts +11 -0
  92. package/src/reflect/transcript.ts +56 -11
  93. package/src/releases/from-card.ts +45 -3
  94. package/src/releases/model.ts +6 -0
  95. package/src/releases/store.ts +8 -1
  96. package/src/repo-config.ts +14 -4
  97. package/src/review/cells.ts +24 -3
  98. package/src/review/format.ts +33 -9
  99. package/src/review/media-kind.ts +14 -11
  100. package/src/review/media-read.ts +6 -5
  101. package/src/review/model.ts +104 -7
  102. package/src/review/paste.ts +2 -1
  103. package/src/review/previews.ts +123 -36
  104. package/src/review/routes.ts +29 -18
  105. package/src/review/store.ts +74 -12
  106. package/src/review/threads.ts +7 -5
  107. package/src/secrets/copy.ts +110 -0
  108. package/src/secrets/list.ts +17 -7
  109. package/src/serve/hub-app/home-strip.css +5 -0
  110. package/src/serve/hub-app/home-strip.tsx +18 -0
  111. package/src/serve/hub-app/hub-app.tsx +2 -1
  112. package/src/serve/hub-app/hub.css +18 -0
  113. package/src/serve/hub-app/inbox.css +1 -0
  114. package/src/serve/hub-app/pull-refresh.tsx +88 -0
  115. package/src/serve/hub-app/recordings-st.ts +135 -24
  116. package/src/serve/hub-app/recordings-view.tsx +293 -54
  117. package/src/serve/hub-app/recordings.css +77 -24
  118. package/src/serve/hub-app/review/review-cells.tsx +52 -13
  119. package/src/serve/hub-app/review/review-list.tsx +6 -1
  120. package/src/serve/hub-app/review/review-st.ts +6 -5
  121. package/src/serve/hub-app/review/review-thread.tsx +3 -1
  122. package/src/serve/hub-app/review/review-views.tsx +18 -11
  123. package/src/serve/hub-app/review/thread-st.ts +82 -14
  124. package/src/serve/hub-app/review.css +15 -2
  125. package/src/serve/hub-runtime.ts +2 -1
  126. package/src/serve/run-serve.ts +4 -2
  127. package/src/serve/serve-hub.ts +9 -2
  128. package/src/shipkit-files.ts +5 -0
  129. package/src/social/drafts.ts +4 -3
  130. package/src/social/load.ts +7 -2
  131. package/src/social/publish/discord.ts +10 -3
  132. package/src/suite/child-tools.ts +45 -0
  133. package/src/suite/judge-suites.ts +10 -22
  134. package/src/suite/select.ts +83 -8
  135. package/src/suite/suite-cli.ts +38 -14
  136. package/src/suite/suite-cores.ts +68 -0
  137. package/src/suite/suite-reads-preload.ts +8 -6
  138. package/src/ts/config.ts +44 -0
  139. package/src/ts/rename.ts +11 -1
@@ -3,7 +3,7 @@
3
3
  // to the cap. Every module loads inside execute: the cli registers this file on every `sk` call
4
4
  import { Command, Option } from 'clipanion'
5
5
 
6
- const DETAILS = `an annex is a folder on an external drive the house config lists (serve.annexes in the house repo config), present only while its root holds the marker sk annex init wrote. A media purge moves each file there before the Mac lets it go, a fetch back reads it before the Space, and sk annex offload moves a repo's .shipkit/cache or .shipkit/tmp folders there behind a symlink. No db, lock, worktree or backed up file ever goes. Page: wiki tools/shipkit/annex.md`
6
+ const DETAILS = `an annex is a folder on an external drive the house config lists (serve.annexes in the house repo config), present only while its root holds the marker sk annex init wrote. A media purge moves each file there before the Mac lets it go, a fetch back reads it before the Space, and sk annex offload moves a repo's .shipkit/cache or .shipkit/tmp folders there behind a symlink. The daemon's annex job does it by itself, in a repo that declares annex in its repo.config.ts: folders a config declares born live there from their first byte, stale scratch moves there when the disk is low or a repo over its cap, a local spill stands in while the drive is away. An offload, a stale folder and a born folder's first move refuse a db, a lock, a git worktree and a backed up file; what a tool writes into a born folder later lives on the annex. A merge never deletes a file that differs from its other copy: the loser is kept beside it and named here. Page: wiki tools/shipkit/annex.md`
7
7
 
8
8
  type Ctx = { stdout: NodeJS.WritableStream; stderr: NodeJS.WritableStream }
9
9
 
@@ -39,8 +39,11 @@ export class AnnexCommand extends Command {
39
39
  return run(this.context, async (out) => {
40
40
  const { annexSpecs, driveFree, isPresent, mediaFiles } = await import('../annex/annex.ts')
41
41
  const { drift, offloads } = await import('../annex/offload.ts')
42
+ const { SCRATCH_USE } = await import('../annex/tidy.ts')
43
+ const { machineGet } = await import('../core/machine-db.ts')
42
44
  const { existsSync } = await import('node:fs')
43
45
  const specs = await annexSpecs()
46
+ const use = machineGet<Record<string, { files: number; bytes: number; at: number }>>(SCRATCH_USE) ?? {}
44
47
  if (specs.length === 0) out('no annex: the house config lists none (serve.annexes)')
45
48
  for (const a of specs) {
46
49
  if (!isPresent(a)) {
@@ -49,18 +52,34 @@ export class AnnexCommand extends Command {
49
52
  }
50
53
  const m = mediaFiles(a)
51
54
  const bytes = m.reduce((s, f) => s + f.size, 0)
52
- out(`${a.path} present free ${gb(driveFree(a.path))} media ${m.length} files ${gb(bytes)}${a.maxGb !== undefined ? ` of ${a.maxGb} GB` : ''}`)
55
+ const u = use[a.path]
56
+ const scratch = u ? `${u.files} files ${gb(u.bytes)}${a.scratchMaxGb !== undefined ? ` of ${a.scratchMaxGb} GB` : ''} (measured ${new Date(u.at).toISOString().slice(0, 16)}Z)` : `not measured yet${a.scratchMaxGb !== undefined ? `, cap ${a.scratchMaxGb} GB` : ''}`
57
+ out(`${a.path} present free ${gb(driveFree(a.path))} media ${m.length} files ${gb(bytes)}${a.maxGb !== undefined ? ` of ${a.maxGb} GB` : ''} scratch ${scratch}`)
53
58
  }
59
+ const { annexAuto } = await import('../annex/tidy.ts')
60
+ const { held, heldWords, localSnapshots } = await import('../annex/snapshots.ts')
54
61
  const list = offloads()
62
+ out(`the daemon's annex job: ${annexAuto() ? 'on' : 'off (sk annex tidy --auto on turns it on)'}`)
63
+ const words = heldWords(held(list, localSnapshots()))
64
+ if (words) out(words)
65
+ const { waitingBorn } = await import('../annex/born.ts')
66
+ for (const l of waitingBorn()) out(` waits: ${l.replace(/^WARN annex: /, '')}`)
55
67
  for (const repo of [...new Set(list.map((x) => x.repo))]) {
56
68
  const bad = new Map((await drift(repo)).map((d) => [d.path, d] as const))
57
69
  for (const x of list.filter((y) => y.repo === repo)) {
58
70
  const d = bad.get(`${x.repo}/${x.rel}`)
59
- out(` ${repo}/${x.rel} ${gb(x.bytes)} ${d ? `${d.kind.toUpperCase()}: ${d.why}` : 'link holds'}`)
71
+ out(` ${repo}/${x.rel} ${x.born ? 'born' : `${gb(x.bytes)} moved`} ${d ? `${d.kind.toUpperCase()}: ${d.why}` : 'link holds'}`)
60
72
  }
61
- for (const d of bad.values()) if (d.kind === 'orphan') out(` ORPHAN ${d.path}: ${d.why}`)
73
+ for (const d of bad.values()) if (d.kind === 'orphan' || !list.some((x) => `${x.repo}/${x.rel}` === d.path)) out(` ${d.kind.toUpperCase()} ${d.path}: ${d.why}`)
62
74
  for (const d of bad.values()) out(` → ${d.fix}`)
63
75
  }
76
+ const { readdirSync } = await import('node:fs')
77
+ const { join } = await import('node:path')
78
+ for (const a of specs.filter(isPresent)) {
79
+ const trash = join(a.path, 'offload', '.trash')
80
+ const wiped = existsSync(trash) ? readdirSync(trash) : []
81
+ if (wiped.length > 0) out(`${trash}: ${wiped.length} wiped folders kept (the annex's scratch cap trims them): ${wiped.slice(-3).join(', ')}`)
82
+ }
64
83
  return 0
65
84
  })
66
85
  }
@@ -141,7 +160,7 @@ export class AnnexForgetCommand extends Command {
141
160
  static override usage = Command.Usage({
142
161
  category: 'Annex',
143
162
  description: 'drop an offload record the Mac no longer needs: a split, a dead link, or nothing left',
144
- details: `${DETAILS}\n\nA split (a real folder where the link was, after a cache reset) keeps the Mac folder and deletes the stale annex copy. A dangling link (the drive gone for good) loses the link and its record. Refused while the link holds (sk annex back brings a folder home), and when the link is gone while the annex copy is there (relink it).`,
163
+ details: `${DETAILS}\n\nA split (a real folder where the link was, after a cache reset) keeps the Mac folder and moves the stale annex copy to the annex's trash. A dangling link (the drive gone for good) loses the link and its record. Refused while the link holds (sk annex back brings a folder home), when the link is gone while the annex copy is there (relink it), for a born folder (drop it from annex.born first), a spill (plug the drive in) and a move in flight (the next pass finishes it).`,
145
164
  examples: [['settle a split', 'sk annex forget .shipkit/cache']],
146
165
  })
147
166
  folder = Option.String({ required: true })
@@ -159,21 +178,53 @@ export class AnnexSweepCommand extends Command {
159
178
  static override paths = [['annex', 'sweep']]
160
179
  static override usage = Command.Usage({
161
180
  category: 'Annex',
162
- description: "trim each annex's media to its cap, used longest ago first: the Space holds every one",
163
- details: `${DETAILS}\n\nThe purge runs it after each pass that kept a file on an annex. Offloaded folders never count and never leave.`,
181
+ description: "trim each annex's media and scratch to their caps, used longest ago first",
182
+ details: `${DETAILS}\n\nMedia: the Space holds every file, so any may go, used longest ago first; the purge runs it after each pass that kept a file on an annex. Scratch (offload/, born and offloaded folders): only files untouched for 14 days, oldest first, past the annex's scratchMaxGb or its keepFreeGb; the daemon's annex job runs it hourly.`,
164
183
  examples: [['what would go', 'sk annex sweep --dry']],
165
184
  })
166
185
  dry = Option.Boolean('--dry', false, { description: 'print what would go, delete nothing' })
167
186
  async execute(): Promise<number> {
168
187
  return run(this.context, async (out) => {
169
188
  const { annexSweep, presentAnnexes } = await import('../annex/annex.ts')
189
+ const { scratchSweep } = await import('../annex/tidy.ts')
170
190
  for (const a of await presentAnnexes()) {
171
191
  const s = annexSweep(a, { dry: this.dry })
172
- out(`${a.path} ${s.files} files ${gb(s.bytes)} ${this.dry ? 'would free' : 'freed'} ${s.freed.files} files ${gb(s.freed.bytes)}`)
192
+ out(`${a.path} media ${s.files} files ${gb(s.bytes)} ${this.dry ? 'would free' : 'freed'} ${s.freed.files} files ${gb(s.freed.bytes)}`)
193
+ const c = scratchSweep(a, { dry: this.dry })
194
+ out(`${a.path} scratch ${c.files} files ${gb(c.bytes)} ${this.dry ? 'would free' : 'freed'} ${c.freed.files} files ${gb(c.freed.bytes)}`)
173
195
  }
174
196
  return 0
175
197
  })
176
198
  }
177
199
  }
178
200
 
179
- export const ANNEX_COMMANDS = [AnnexCommand, AnnexInitCommand, AnnexOffloadCommand, AnnexBackCommand, AnnexForgetCommand, AnnexSweepCommand]
201
+ export class AnnexTidyCommand extends Command {
202
+ static override paths = [['annex', 'tidy']]
203
+ static override usage = Command.Usage({
204
+ category: 'Annex',
205
+ description: "the daemon's annex pass now, for this repo: born folders linked, spills merged, stale scratch moved",
206
+ details: `${DETAILS}\n\nThe daemon runs this pass by itself once the owner turned its switch on (--auto on; its annex job: the records every 30 s, the rest every 10 min). In every repo it keeps the records in line with the drive: a spill while it is away, taken back once it returns, a move a kill stopped finished. Only in a repo whose repo.config.ts declares annex (annex: {} takes the house defaults), it also links each folder the repo or house config declares born (annex.born, serve.annexScratch.born), keeps a born folder wiped on the Mac wiped (its old annex content to the annex's trash), and, when the disk is under its floor or the repo's scratch on the Mac over its cap, moves stale folders of .shipkit/tmp and .shipkit/cache to the annex, oldest first, through sk annex offload's own checks.`,
207
+ examples: [['what it would move', 'sk annex tidy --dry'], ['the pass now', 'sk annex tidy'], ['the daemon does it by itself from now on', 'sk annex tidy --auto on']],
208
+ })
209
+ dry = Option.Boolean('--dry', false, { description: 'print what the stale pass and the sweep would do, move nothing' })
210
+ auto = Option.String('--auto', { description: "on: the daemon's annex job runs this pass by itself, for every house repo; off stops it (off until the owner turns it on)" })
211
+ async execute(): Promise<number> {
212
+ return run(this.context, async (out) => {
213
+ const { annexAuto, annexTick, setAnnexAuto } = await import('../annex/tidy.ts')
214
+ if (this.auto !== undefined) {
215
+ if (this.auto !== 'on' && this.auto !== 'off') throw new Error(`--auto takes on or off, not ${this.auto}`)
216
+ if (!setAnnexAuto(this.auto === 'on')) throw new Error('the machine db does not open: the switch is not set')
217
+ out(`the daemon's annex job: ${annexAuto() ? 'on, every house repo, by itself' : 'off: nothing moves unless sk annex tidy runs by hand'}`)
218
+ return 0
219
+ }
220
+ const { findRepoRoot } = await import('../ts/config.ts')
221
+ const { houseRoot } = await import('../home/home-start.ts')
222
+ const root = findRepoRoot(process.cwd())
223
+ let warned = 0
224
+ await annexTick({ roots: [root], house: houseRoot(root), print: out, printErr: (l) => void (warned++, this.context.stderr.write(`${l}\n`)), full: true, dry: this.dry })
225
+ return warned > 0 ? 1 : 0
226
+ })
227
+ }
228
+ }
229
+
230
+ export const ANNEX_COMMANDS = [AnnexCommand, AnnexInitCommand, AnnexOffloadCommand, AnnexBackCommand, AnnexForgetCommand, AnnexSweepCommand, AnnexTidyCommand]
@@ -11,6 +11,7 @@ const asksDir = async (root: string): Promise<string> => join(root, (await loadR
11
11
 
12
12
  export class AsksCommand extends Command {
13
13
  static override paths = [['asks']]
14
+ static essential = {}
14
15
 
15
16
  static override usage = Command.Usage({
16
17
  category: 'Asks',
@@ -54,6 +55,7 @@ export class AsksCheckCommand extends Command {
54
55
 
55
56
  export class AskNewCommand extends Command {
56
57
  static override paths = [['ask'], ['asks', 'new']]
58
+ static essential = { args: '<title>' }
57
59
 
58
60
  static override usage = Command.Usage({
59
61
  category: 'Asks',
@@ -81,7 +81,7 @@ export class BackupRunsCommand extends Command {
81
81
  static override paths = [['backup', 'runs']]
82
82
  static override usage = Command.Usage({
83
83
  category: 'Media',
84
- description: 'every backup run the Space holds, oldest first: its time and manifest key',
84
+ description: 'every backup run the Space holds, oldest first: its time, machine and manifest key',
85
85
  details: DETAILS,
86
86
  examples: [['the runs', 'sk backup runs']],
87
87
  })
@@ -89,7 +89,7 @@ export class BackupRunsCommand extends Command {
89
89
  return run(this.context, async (h) => {
90
90
  const { runsOf } = await import('../media-store/backup/manifest.ts')
91
91
  const runs = await runsOf(h.space)
92
- for (const r of runs) h.out(`${r.at.toISOString()} ${r.key} ${(r.size / 1e3).toFixed(0)} kB`)
92
+ for (const r of runs) h.out(`${r.at.toISOString()} ${r.machine ?? '(host inside)'} ${r.key} ${(r.size / 1e3).toFixed(0)} kB`)
93
93
  h.out(`${runs.length} runs`)
94
94
  return 0
95
95
  })
@@ -101,18 +101,19 @@ export class BackupRestoreCommand extends Command {
101
101
  static override usage = Command.Usage({
102
102
  category: 'Media',
103
103
  description: 'a backup run written back, every sha checked: to an empty folder, or in place',
104
- details: `${DETAILS}\n\nThe run is the last one at or before --at (the last one when it is left out). --to writes every file under the folder, at its path under the home (the folder must be empty or new). --in-place writes over the live files: a live file with other bytes is copied to ~/.shipkit/backup-replaced/<time>/ first, and a sqlite lands beside its live file as <file>.restored (stop pm, then move it). --path keeps the files under one path of the home.`,
104
+ details: `${DETAILS}\n\nThe run is this Mac's last one at or before --at (the last one when it is left out); --host reads another Mac's runs, as a new Mac restoring the one it replaces. --to writes every file under the folder, at its path under the home (the folder must be empty or new). --in-place writes over the live files: a live file with other bytes is copied to ~/.shipkit/backup-replaced/<time>/ first, and a sqlite lands beside its live file as <file>.restored (stop pm, then move it). --path keeps the files under one path of the home.`,
105
105
  examples: [['the last run into a folder', 'sk backup restore --to ~/restore-1'], ['the veille logs as they were on a day, in place', 'sk backup restore --at 2026-11-04 --in-place --path .config/shipkit/home/veille']],
106
106
  })
107
107
  to = Option.String('--to', { description: 'an empty or new folder the files land under' })
108
108
  inPlace = Option.Boolean('--in-place', false, { description: 'over the live files, each one replaced copied aside first' })
109
109
  at = Option.String('--at', { description: 'the last run at or before this time: 2026-11-04T13:50Z, 2026-11-04 or 20261104T135000Z' })
110
110
  under = Option.String('--path', { description: 'only the files under this path of the home: .config/shipkit/home/veille' })
111
+ host = Option.String('--host', { description: "another Mac's runs, by the name `sk backup runs` prints: this Mac's when absent" })
111
112
  async execute(): Promise<number> {
112
113
  return run(this.context, async (h) => {
113
114
  const { restore } = await import('../media-store/backup/restore.ts')
114
115
  const { parseAt } = await import('../media-store/backup/keys.ts')
115
- const r = await restore(h.space, { home: h.home, ...(this.to !== undefined ? { to: this.to } : {}), inPlace: this.inPlace, ...(this.at ? { at: parseAt(this.at) } : {}), ...(this.under ? { only: this.under } : {}) })
116
+ const r = await restore(h.space, { home: h.home, ...(this.to !== undefined ? { to: this.to } : {}), inPlace: this.inPlace, ...(this.at ? { at: parseAt(this.at) } : {}), ...(this.under ? { only: this.under } : {}), ...(this.host ? { machine: this.host } : {}) })
116
117
  h.out(`run ${r.at} (${r.run}): ${r.files} files, ${r.written} written (${mb(r.bytes)})${this.inPlace ? `, ${r.same} already the same` : ''}`)
117
118
  if (r.aside.n > 0) h.out(`${r.aside.n} live files copied aside first, into ${r.aside.dir}`)
118
119
  for (const b of r.beside) h.out(` a sqlite landed beside its live file: ${b} (stop pm, then move it over)`)
@@ -132,12 +133,13 @@ export class BackupDrillCommand extends Command {
132
133
  })
133
134
  to = Option.String('--to', { description: 'restore into this empty or new folder, and keep it' })
134
135
  at = Option.String('--at', { description: 'the last run at or before this time, an older run: 2026-11-04T13:50Z or 20261104T135000Z' })
136
+ host = Option.String('--host', { description: "another Mac's runs, by the name `sk backup runs` prints: this Mac's when absent" })
135
137
  async execute(): Promise<number> {
136
138
  return run(this.context, async (h) => {
137
139
  const { drill } = await import('../media-store/backup/restore.ts')
138
140
  const { parseAt } = await import('../media-store/backup/keys.ts')
139
141
  const t0 = Date.now()
140
- const d = await drill(h.space, { home: h.home, ...(this.to !== undefined ? { to: this.to } : {}), ...(this.at ? { at: parseAt(this.at) } : {}) })
142
+ const d = await drill(h.space, { home: h.home, ...(this.to !== undefined ? { to: this.to } : {}), ...(this.at ? { at: parseAt(this.at) } : {}), ...(this.host ? { machine: this.host } : {}) })
141
143
  h.out(`run ${d.at} (${d.run}, version ${d.v}): ${d.files} files (${mb(d.bytes)}), ${d.restored} restored with their sha, in ${((Date.now() - t0) / 1000).toFixed(1)} s`)
142
144
  h.out(`against the live files: ${d.sameAsLive} the same, ${d.liveMoved.length} moved since the run, ${d.liveGone.length} gone from the disk, ${d.failed.length} failed`)
143
145
  for (const s of d.sqlite) h.out(` sqlite ~/${s.path}: restored ${JSON.stringify(s.restored)}, live now ${JSON.stringify(s.live)}`)
@@ -6,6 +6,7 @@ import { runBump, type BumpKind } from '../release/run-bump.ts'
6
6
 
7
7
  export class BumpCommand extends Command {
8
8
  static override paths = [['bump']]
9
+ static essential = { args: '[kind] [unit]' }
9
10
 
10
11
  static override usage = Command.Usage({
11
12
  category: 'Gate',
@@ -0,0 +1,26 @@
1
+ // sk capacity: how many more lanes the machine can take now. Report only, exit 0 always: the orchestrator decides.
2
+ import { Command, Option } from 'clipanion'
3
+ import { capacityLines, readCapacity } from '../core/capacity.ts'
4
+
5
+ export class CapacityCommand extends Command {
6
+ static override paths = [['capacity']]
7
+ static essential = {}
8
+
9
+ static override usage = Command.Usage({
10
+ category: 'Health',
11
+ description: 'how many more lanes the machine can take now: its cores, its load, the agents live on it',
12
+ details: 'reads the cores, the 1 and 5 minute load and the agents whose transcript moved in the last 3 minutes, every account and repo. A lane counts for the load the live agents share, never under one core. Run it before a lane starts: no room means the lane waits on the board. Report only, exit 0 always.',
13
+ examples: [
14
+ ['before a lane starts', 'sk capacity'],
15
+ ['machine readable', 'sk capacity --json'],
16
+ ],
17
+ })
18
+
19
+ json = Option.Boolean('--json', false, { description: 'the measure and the room as json' })
20
+
21
+ async execute(): Promise<number> {
22
+ const { capacity, live } = readCapacity()
23
+ this.context.stdout.write(this.json ? `${JSON.stringify({ ...capacity, live })}\n` : `${capacityLines(capacity, live).join('\n')}\n`)
24
+ return 0
25
+ }
26
+ }
@@ -11,6 +11,7 @@ import { runFix } from '../core/run-fix.ts'
11
11
 
12
12
  export class CheckCommand extends Command {
13
13
  static override paths = [['check'], ['doctor']]
14
+ static essential = {}
14
15
 
15
16
  static override usage = Command.Usage({
16
17
  category: 'Health',
@@ -17,6 +17,7 @@ import { classify } from '../ledger/git-key.ts'
17
17
 
18
18
  export class ChecksCommand extends Command {
19
19
  static override paths = [['checks']]
20
+ static essential = {}
20
21
 
21
22
  // widened so the hidden alias below can drop it: no usage, no help entry
22
23
  static override usage: Usage | undefined = Command.Usage({
package/src/cli/cmd_Ci.ts CHANGED
@@ -11,6 +11,7 @@ import { listFlag } from './list-flag.ts'
11
11
 
12
12
  export class CiCommand extends Command {
13
13
  static override paths = [['ci']]
14
+ static essential = { examples: 1 }
14
15
 
15
16
  static override usage = Command.Usage({
16
17
  category: 'Gate',
@@ -134,6 +134,40 @@ export function renderCompact(rows: CommandRow[], bin = 'sk', pages: Readonly<Re
134
134
  return out.join('\n').trim()
135
135
  }
136
136
 
137
+ /** one essential command's lines: its words with the arguments an agent types, its description, its examples */
138
+ const essentialLines = (r: CommandRow, bin: string, sep: string): string[] => {
139
+ const e = r.essential!
140
+ return [`- \`${bin} ${r.path}${e.args != null ? ` ${e.args}` : ''}\`${sep}${r.description}`, ...r.examples.slice(0, e.examples ?? 0).map(([label, cmd]) => ` - \`${cmd}\`: ${label}`)]
141
+ }
142
+
143
+ /** how to list the commands of a family the page does not show: one `--help` per first word, with its count */
144
+ const restOf = (all: CommandRow[], bin: string): string[] => {
145
+ const first = (r: CommandRow): string => r.path.split(' ')[0]!
146
+ return [...new Set(all.map(first))]
147
+ .map((w) => [w, all.filter((r) => first(r) === w && r.essential == null).length] as const)
148
+ .filter(([, n]) => n > 0)
149
+ .map(([w, n]) => `\`${bin} ${w} --help\` (${n})`)
150
+ }
151
+
152
+ /** the block of a page every session loads: the commands marked essential, then how to list the rest of each
153
+ * family, then every other family on one line with its owner page. The whole list is one command away */
154
+ export function renderEveryday(rows: CommandRow[], bin = 'sk', pages: Readonly<Record<string, string>> | null = null): string {
155
+ const out: string[] = []
156
+ const quiet: string[] = []
157
+ for (const category of [...new Set(rows.map((r) => r.category))]) {
158
+ const all = rows.filter((r) => r.category === category)
159
+ const mine = all.filter((r) => r.essential != null)
160
+ const page = pages?.[category] != null ? ` → ${pages[category]}` : ''
161
+ const rest = restOf(all, bin)
162
+ if (mine.length === 0) { quiet.push(`- ${category}${page}: ${rest.join(', ')}`); continue }
163
+ out.push(`\n### ${category}${page}\n`)
164
+ for (const r of mine) out.push(...essentialLines(r, bin, ' — '))
165
+ if (rest.length > 0) out.push(`- more: ${rest.join(', ')}`)
166
+ }
167
+ if (quiet.length > 0) out.push('\n### The other families, each with the command that lists it and how many it holds\n', ...quiet)
168
+ return out.join('\n').trim()
169
+ }
170
+
137
171
  /** the page every session loads: per category its everyday commands, a few
138
172
  * examples, and how to list the rest. Generated whole */
139
173
  export function renderEssentials(rows: CommandRow[], bin: string, command: string): string {
@@ -149,11 +183,7 @@ export function renderEssentials(rows: CommandRow[], bin: string, command: strin
149
183
  const mine = all.filter((r) => r.essential != null)
150
184
  if (mine.length === 0) { quiet.push(...rest); continue }
151
185
  out.push('', `## ${category}${rest.length > 0 ? ` (more: ${rest.join(', ')})` : ''}`, '')
152
- for (const r of mine) {
153
- const e = r.essential!
154
- out.push(`- \`${bin} ${r.path}${e.args != null ? ` ${e.args}` : ''}\`: ${r.description}`)
155
- for (const [label, cmd] of r.examples.slice(0, e.examples ?? 0)) out.push(` - \`${cmd}\`: ${label}`)
156
- }
186
+ for (const r of mine) out.push(...essentialLines(r, bin, ': '))
157
187
  }
158
188
  if (quiet.length > 0) out.push('', `## The other families: ${quiet.join(', ')}`)
159
189
  return `${out.join('\n')}\n`
@@ -214,14 +244,17 @@ export class CommandsCommand extends Command {
214
244
  ['markdown index', 'sk commands'],
215
245
  ['machine-readable', 'sk commands --json'],
216
246
  ['write into a docs page between the markers', 'sk commands --out docs/commands.md'],
217
- ['one line per command, for a page every session loads', 'sk commands --compact --out wiki/tools/shipkit/commands.md'],
218
- ['fail if that page is stale (lint mode)', 'sk commands --compact --out wiki/tools/shipkit/commands.md --check'],
247
+ ['the everyday commands, for a page every session loads', 'sk commands --everyday --out wiki/tools/shipkit/commands.md'],
248
+ ['every command, one line each, on demand', 'sk commands --compact'],
249
+ ['fail if that page is stale (lint mode)', 'sk commands --everyday --out wiki/tools/shipkit/commands.md --check'],
219
250
  ],
220
251
  })
221
252
 
222
253
  /** a project CLI holds its rows to shapeProblems (--out and --check fail on
223
254
  * a breach), and its --out creates a missing page */
224
255
  static shapeRule = false
256
+ /** the classes of the cli this command is registered in, set by its registry: their marks (essential, film) */
257
+ static registered: readonly { paths?: string[][] }[] = []
225
258
 
226
259
  /** each family's owner page, named in the compact page's headings; a project CLI has none */
227
260
  static familyPages: Readonly<Record<string, string>> | null = FAMILY_PAGES
@@ -230,11 +263,12 @@ export class CommandsCommand extends Command {
230
263
  out = Option.String('--out', { description: 'host file carrying the <bin>:commands markers. The block between them is rewritten' })
231
264
  check = Option.Boolean('--check', false, { description: 'with --out or --essentials: exit 1 if a page is stale, write nothing' })
232
265
  compact = Option.Boolean('--compact', false, { description: 'one line per command: no flags, no examples (they are `<bin> <command> --help`)' })
266
+ everyday = Option.Boolean('--everyday', false, { description: 'the compact form of a page every session loads: only the commands marked essential, then every other family on one line' })
233
267
  essentials = Option.String('--essentials', { description: 'the everyday commands page, rewritten whole from the commands marked essential' })
234
268
 
235
269
  async execute(): Promise<number> {
236
270
  const bin = this.cli.binaryName
237
- const classes = (this.context as { classes?: { paths?: string[][] }[] }).classes ?? []
271
+ const classes = (this.context as { classes?: { paths?: string[][] }[] }).classes ?? (this.constructor as typeof CommandsCommand).registered
238
272
  const rows = commandRows(
239
273
  this.cli.definitions() as Definition[],
240
274
  (this.cli.definitions as (o?: { detailed?: boolean }) => Definition[])({ detailed: true }),
@@ -243,12 +277,13 @@ export class CommandsCommand extends Command {
243
277
  )
244
278
  const write = (s: string): void => void this.context.stdout.write(s)
245
279
  const pages = (this.constructor as typeof CommandsCommand).familyPages
246
- const render = (): string => (this.compact ? renderCompact(rows, bin, pages) : renderMarkdown(rows, bin))
280
+ // --everyday is a compact form: it never falls back to the full markdown
281
+ const render = (): string => (this.everyday ? renderEveryday(rows, bin, pages) : this.compact ? renderCompact(rows, bin, pages) : renderMarkdown(rows, bin))
247
282
  if (this.out == null && this.essentials == null) {
248
283
  write(this.json ? `${JSON.stringify(rows)}\n` : `${render()}\n`)
249
284
  return 0
250
285
  }
251
- if (this.out != null && this.compact && pages != null) {
286
+ if (this.out != null && (this.compact || this.everyday) && pages != null) {
252
287
  const bad = familyProblems(rows, pages)
253
288
  for (const b of bad) write(`FAIL: ${b}\n`)
254
289
  if (bad.length > 0) { write(' fix: one row per family in src/cli/family-pages.ts, the wiki page that owns it\n'); return 1 }
@@ -276,14 +311,15 @@ export class CommandsCommand extends Command {
276
311
  const host = existsSync(this.out) ? readFileSync(this.out, 'utf8') : newCommandsPage(bin, this.out)
277
312
  const next = spliceBlock(host, render(), bin)
278
313
  if (next == null) { write(`FAIL: ${this.out} has no ${begin} / ${end} markers\n`); return 1 }
279
- if (next === host) { write(`ok: ${this.out} command index current (${rows.length} commands)\n`); return code }
314
+ const shown = this.everyday ? `${rows.filter((r) => r.essential != null).length} everyday commands of ${rows.length}` : `${rows.length} commands`
315
+ if (next === host) { write(`ok: ${this.out} command index current (${shown})\n`); return code }
280
316
  if (this.check) {
281
- write(`FAIL: ${this.out} command index is STALE — the binary registers commands the page does not list\n`)
282
- write(` fix: ${bin === 'sk' ? 'shipkit' : bin} commands${this.compact ? ' --compact' : ''} --out ${this.out}\n`)
317
+ write(`FAIL: ${this.out} command index is STALE — ${this.everyday ? 'the everyday commands, a description or a family count moved in the binary' : 'the binary registers commands the page does not list'}\n`)
318
+ write(` fix: ${bin === 'sk' ? 'shipkit' : bin} commands${this.everyday ? ' --everyday' : this.compact ? ' --compact' : ''} --out ${this.out}\n`)
283
319
  return 1
284
320
  }
285
321
  writeFileSync(this.out, next)
286
- write(`ok: ${this.out} command index rewritten (${rows.length} commands)\n`)
322
+ write(`ok: ${this.out} command index rewritten (${shown})\n`)
287
323
  return code
288
324
  }
289
325
  }
@@ -101,7 +101,6 @@ export class DaemonJobCommand extends Command {
101
101
  })
102
102
 
103
103
  id = Option.String({ required: true, name: 'id' })
104
-
105
104
  async execute(): Promise<number> {
106
105
  const { isJobId, DAEMON_JOBS, runJobBody } = await import('../home/daemon-jobs.ts')
107
106
  if (!isJobId(this.id)) {
@@ -58,6 +58,7 @@ export class HooksCommitMsgCommand extends Command {
58
58
 
59
59
  export class HooksListCommand extends Command {
60
60
  static override paths = [['hooks', 'list']]
61
+ static essential = {}
61
62
  static override usage = Command.Usage({
62
63
  category: 'Gate',
63
64
  description: 'what blocks a commit in this repo, built-ins and repo-declared',
package/src/cli/cmd_Mv.ts CHANGED
@@ -10,6 +10,7 @@ import { renameCli } from '../ts/rename.ts'
10
10
 
11
11
  export class MvCommand extends Command {
12
12
  static override paths = [['mv']]
13
+ static essential = { args: '<old> <new>' }
13
14
 
14
15
  static override usage = Command.Usage({
15
16
  category: 'Refactor',
@@ -57,8 +57,10 @@ export class RecCommand extends Command {
57
57
  async execute(): Promise<number> {
58
58
  return run(this.context, async (io) => {
59
59
  const { listRecordings } = await import('../recordings/model.ts')
60
+ const { webpPath } = await import('../recordings/share.ts')
60
61
  const all = await listRecordings(this.repo === undefined ? {} : { repo: this.repo })
61
- for (const r of all) io.out(this.json ? JSON.stringify(r) : line(r))
62
+ // webp: where the app keeps the WebP a copy makes of what plays
63
+ for (const r of all) io.out(this.json ? JSON.stringify({ ...r, webp: webpPath(r) }) : line(r))
62
64
  if (!this.json && all.length === 0) io.out('no recording yet: a hotkey of the menu bar app records one (sk rec presets lists them)')
63
65
  return 0
64
66
  })
@@ -120,7 +122,9 @@ export class RecImportCommand extends Command {
120
122
  } catch (e) {
121
123
  failed = (e as Error).message
122
124
  }
123
- if (this.json) io.out(JSON.stringify({ ok: failed === null, recording: rec, said, ...(failed ? { error: failed } : {}), ...(warn ? { warn } : {}) }))
125
+ // webp: where the app keeps the WebP its shot made of this take
126
+ const { webpPath } = await import('../recordings/share.ts')
127
+ if (this.json) io.out(JSON.stringify({ ok: failed === null, recording: { ...rec, webp: webpPath(rec) }, said, ...(failed ? { error: failed } : {}), ...(warn ? { warn } : {}) }))
124
128
  else if (failed) io.err(`FAIL: ${failed}; the take is filed: ${rec.dir}`)
125
129
  return failed ? 1 : 0
126
130
  })
@@ -165,7 +169,7 @@ export class RecPresetsCommand extends Command {
165
169
  static override usage = Command.Usage({
166
170
  category: 'Record',
167
171
  description: 'the presets the menu bar app runs: hotkey, what it shoots, its options, what runs after',
168
- details: `${DETAILS}\n\nThe house config's recorder.presets (shipkit's own video and still when it names none), then each repo's own as <repo>/<name>. A wrong preset or a hotkey two presets claim is printed and exits 1. --json is what the app reads: presets, problems, the house repos and the one a take goes to by default.`,
172
+ details: `${DETAILS}\n\nThe house config's recorder.presets (shipkit's own video and still when it names none), then each repo's own as <repo>/<name>. A wrong preset or a hotkey two presets claim is printed and exits 1. --json is what the app reads: presets, the tray's hotkeys, problems, the house repos and the one a take goes to by default.`,
169
173
  examples: [['what the hotkeys do', 'sk rec presets']],
170
174
  })
171
175
  json = Option.Boolean('--json', false, { description: 'the app\'s read: presets, problems, repos, the default repo' })
@@ -182,6 +186,7 @@ export class RecPresetsCommand extends Command {
182
186
  const opts = [p.still ? 'still' : 'video', p.mic && 'mic', p.systemAudio && 'system sound', p.clicks && 'clicks', p.countdown && `countdown ${p.countdown}s`, p.seconds && `${p.seconds}s`].filter(Boolean).join(', ')
183
187
  io.out(`${p.id.padEnd(18)} ${p.keys.join(' ').padEnd(28)} ${shoot}; ${opts}; then ${(p.after ?? []).join(', ') || 'nothing'} (${p.from})`)
184
188
  }
189
+ if (s.trayKeys.length > 0) io.out(`${'tray'.padEnd(18)} ${s.trayKeys.join(' ').padEnd(28)} shows or hides the recent captures`)
185
190
  io.out(`takes go to ${s.repo} (the menu's pick)`)
186
191
  for (const p of s.problems) io.err(`FAIL: ${p}`)
187
192
  return s.problems.length > 0 ? 1 : 0
@@ -301,7 +306,7 @@ export class RecEditCommand extends Command {
301
306
  static override usage = Command.Usage({
302
307
  category: 'Record',
303
308
  description: 'a recording\'s edit as text: printed, or set and exported (keep, speed, crop, mute)',
304
- details: `${DETAILS}\n\nOne line a verb: \`keep 0:01.5-0:12, 0:15-0:40\`, \`speed 2x 0:20-0:30\`, \`crop 1280x720+40+80\`, \`mute\`. Times are the take's. Setting it exports out.mp4 in one ffmpeg pass; an empty text removes the edit, and the take plays again. The take itself never changes.`,
309
+ details: `${DETAILS}\n\nOne line a verb: \`keep 0:01.5-0:12, 0:15-0:40\`, \`speed 2x 0:20-0:30\`, \`crop 1280x720+40+80\`, \`mute\`. Times are the take's. Setting it exports out.mp4 in one ffmpeg pass as a new version; the same text again changes nothing. An empty text removes the edit, and the take plays again. The take itself never changes.`,
305
310
  examples: [['what it is now', 'sk rec edit boss-fight'], ['trim both ends', 'sk rec edit boss-fight --set "keep 0:02-0:31"']],
306
311
  })
307
312
  ref = Option.String()
@@ -309,14 +314,19 @@ export class RecEditCommand extends Command {
309
314
  set = Option.String('--set', { description: 'the whole edit, lines split by a newline or a semicolon' })
310
315
  async execute(): Promise<number> {
311
316
  return run(this.context, async (io) => {
312
- const { editText, saveEdit } = await import('../recordings/take.ts')
317
+ const { editText, sameEdit, saveEdit, versionsOf } = await import('../recordings/take.ts')
313
318
  const r = await find(this.ref, this.repo)
314
319
  if (this.set === undefined) {
315
320
  io.out(editText(r) || '(no edit: the take plays whole)')
316
321
  return 0
317
322
  }
318
- const after = await saveEdit(r, this.set.replace(/;\s*/g, '\n'))
319
- io.out(`ok: ${line(after)}`)
323
+ const text = this.set.replace(/;\s*/g, '\n')
324
+ if (sameEdit(r, text)) {
325
+ io.out(`ok: nothing changed since v${versionsOf(r).at(-1)?.n ?? 0}: no new save`)
326
+ return 0
327
+ }
328
+ const after = await saveEdit(r, text)
329
+ io.out(`ok: v${versionsOf(after).at(-1)?.n ?? 0} ${line(after)}`)
320
330
  return 0
321
331
  })
322
332
  }
@@ -14,6 +14,7 @@ export type RepoDoc = { repo: string; prompts: PromptEntry[]; error?: string }
14
14
 
15
15
  export class ReflectCommand extends Command {
16
16
  static override paths = [['reflect']]
17
+ static essential = {}
17
18
 
18
19
  static override usage = Command.Usage({
19
20
  category: 'Health',
@@ -44,6 +44,7 @@ export class ReleasesCommand extends Command {
44
44
 
45
45
  export class ReleasesAddCommand extends Command {
46
46
  static override paths = [['releases', 'add']]
47
+ static essential = {}
47
48
 
48
49
  static override usage = Command.Usage({
49
50
  category: 'Gate',