rvlib-shipkit 2.22.0 → 2.23.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 (52) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/package.json +1 -1
  3. package/src/annex/annex.ts +3 -0
  4. package/src/annex/born.ts +464 -0
  5. package/src/annex/flush.ts +46 -0
  6. package/src/annex/offload.ts +171 -38
  7. package/src/annex/snapshots.ts +53 -0
  8. package/src/annex/tidy.ts +368 -0
  9. package/src/checks/SK041-annex-links.check.ts +4 -2
  10. package/src/checks/SK043-scratch-on-the-mac.check.ts +45 -0
  11. package/src/cli/cmd_Annex.ts +60 -9
  12. package/src/cli/cmd_Home.ts +28 -0
  13. package/src/cli/cmd_Rec.ts +17 -7
  14. package/src/cli/cmd_Review.ts +27 -3
  15. package/src/core/machine-db.ts +8 -0
  16. package/src/home/claude-temp.ts +139 -0
  17. package/src/home/daemon-jobs.ts +10 -3
  18. package/src/home/global-units.ts +3 -0
  19. package/src/home/machine-stores.ts +27 -3
  20. package/src/home/pm.ts +4 -1
  21. package/src/home/run-pm.ts +1 -0
  22. package/src/identities/identities.ts +92 -24
  23. package/src/media-store/daemon.ts +2 -2
  24. package/src/media-store/purge.ts +4 -0
  25. package/src/recordings/load.ts +3 -3
  26. package/src/recordings/model.ts +7 -0
  27. package/src/recordings/open.ts +12 -0
  28. package/src/recordings/presets.ts +12 -5
  29. package/src/recordings/recorder-app/Capture.swift +34 -5
  30. package/src/recordings/recorder-app/Clip.swift +218 -54
  31. package/src/recordings/recorder-app/Editor.swift +177 -7
  32. package/src/recordings/recorder-app/Hud.swift +189 -0
  33. package/src/recordings/recorder-app/Tray.swift +179 -36
  34. package/src/recordings/recorder-app/icon.svg +16 -0
  35. package/src/recordings/recorder-app/main.swift +363 -29
  36. package/src/recordings/recorder-app.ts +8 -4
  37. package/src/recordings/recorder.shipkit.ts +2 -1
  38. package/src/recordings/routes.ts +52 -6
  39. package/src/recordings/run-recorder.ts +2 -1
  40. package/src/recordings/share.ts +27 -0
  41. package/src/recordings/take.ts +36 -4
  42. package/src/recordings/view.ts +11 -0
  43. package/src/repo-config.ts +9 -1
  44. package/src/review/model.ts +33 -4
  45. package/src/serve/hub-app/hub.css +4 -0
  46. package/src/serve/hub-app/recordings-st.ts +135 -24
  47. package/src/serve/hub-app/recordings-view.tsx +293 -54
  48. package/src/serve/hub-app/recordings.css +77 -24
  49. package/src/shipkit-files.ts +5 -0
  50. package/src/social/drafts.ts +4 -3
  51. package/src/social/load.ts +7 -2
  52. package/src/social/publish/discord.ts +10 -3
@@ -1,7 +1,8 @@
1
- // the recent captures tray (wiki tools/shipkit/recordings.md, The recorder): an easy place, always on after a capture,
2
- // to see and reach the recent ones. A small floating panel, on every Space, draggable (it remembers where): the newest captures as thumbs, a click opens one in the
3
- // hub's editor, a right click copies the file or a link or shows it in the Finder. It shows after each capture and
4
- // stays until closed; the menu brings it back
1
+ // the recent captures (wiki tools/shipkit/recordings.md, The recorder): an easy place, always on after a capture, to
2
+ // see and reach the recent ones: the newest captures as thumbs, a click opens one in the editor, a right click copies
3
+ // the file or a link or shows it in the Finder. One window at a time holds them: while the editor window is open they
4
+ // sit under it, else they are a small floating panel of their own, on every Space, draggable (it remembers where).
5
+ // They show after each capture and stay until switched off; the menu and the tray's hotkey switch them
5
6
  import AppKit
6
7
 
7
8
  struct RecentItem: Decodable {
@@ -11,11 +12,23 @@ struct RecentItem: Decodable {
11
12
  var still: Bool
12
13
  var seconds: Double
13
14
  var dir: String
15
+ /** where the WebP a copy makes of what plays is kept */
16
+ var webp: String?
17
+ }
18
+
19
+ /** the copy modes' colours, the editor page's own (hub.css, --recfile, --recwebp, --reclink): dark enough for the
20
+ * white text and pictures on them */
21
+ enum Tint {
22
+ static let file = NSColor(srgbRed: 0x0b / 255, green: 0x63 / 255, blue: 0xce / 255, alpha: 1)
23
+ static let webp = NSColor(srgbRed: 0x1a / 255, green: 0x7f / 255, blue: 0x43 / 255, alpha: 1)
24
+ static let link = NSColor(srgbRed: 0x8a / 255, green: 0x3f / 255, blue: 0xc4 / 255, alpha: 1)
25
+ static let plain = NSColor(white: 0.36, alpha: 1)
14
26
  }
15
27
 
16
28
  @MainActor
17
29
  final class RecentTray: NSObject {
18
30
  static let SHOWN = "recentTrayShown"
31
+ static let DOCK_OFF = "recentUnderEditorOff"
19
32
  static let MAX = 5
20
33
  /** a cell's width: its poster, its name and its button bar */
21
34
  static let W: CGFloat = 140
@@ -28,28 +41,67 @@ final class RecentTray: NSObject {
28
41
  var pending = Set<String>()
29
42
  /** a capture opened in the recorder's editor window */
30
43
  var onEdit: ((String, String) -> Void)?
44
+ /** every capture as a grid, in the recorder's window */
45
+ var onGallery: (() -> Void)?
46
+ /** the × clicked once: red, a second click within ARM_SECONDS deletes for good */
47
+ private weak var armed: NSButton?
48
+ static let ARM_SECONDS = 3.0
31
49
 
32
- var shown: Bool { panel?.isVisible == true }
50
+ /** the owner's switch of where the recent captures are now: their panel (off until a capture or the owner turns
51
+ * it on), or the band under the editor (on until the owner turns it off) */
52
+ var on: Bool {
53
+ get { host != nil ? !UserDefaults.standard.bool(forKey: RecentTray.DOCK_OFF) : UserDefaults.standard.bool(forKey: RecentTray.SHOWN) }
54
+ set { if host != nil { UserDefaults.standard.set(!newValue, forKey: RecentTray.DOCK_OFF) } else { UserDefaults.standard.set(newValue, forKey: RecentTray.SHOWN) } }
55
+ }
56
+ /** set while the editor window is open: the strip goes to it (nil takes it away) and the panel stays hidden, so
57
+ * the captures and the editor are one window */
58
+ var host: ((NSView?) -> Void)? { didSet { render() } }
59
+ /** the capture the editor shows, `<repo>/<id>`: its thumb is ringed under the editor */
60
+ var current: String? { didSet { if host != nil, current != oldValue { render() } } }
61
+ /** the strip drawn last: what a proof's hover reaches */
62
+ private var row: NSStackView?
33
63
 
34
- /** the newest captures read again; the tray shown when `show`, or kept as it was */
64
+ /** the newest captures read again; switched on when `show`, else left as the owner has them */
35
65
  func refresh(show: Bool) async {
36
66
  guard let sk else { return }
37
67
  let r = await sk(["rec", "--json"])
38
68
  items = r.out.split(separator: "\n").prefix(RecentTray.MAX).compactMap { try? JSONDecoder().decode(RecentItem.self, from: Data($0.utf8)) }
39
- if show || shown { open() }
69
+ if show { on = true }
70
+ render()
40
71
  }
41
72
 
42
73
  func open() {
43
- let p = panel ?? makePanel()
44
- panel = p
45
- p.contentView = content()
46
- p.setContentSize(p.contentView!.fittingSize)
47
- if !p.isVisible && p.frameAutosaveName.isEmpty == false && !p.setFrameUsingName(p.frameAutosaveName) { place(p) }
48
- p.orderFrontRegardless()
49
- UserDefaults.standard.set(true, forKey: RecentTray.SHOWN)
74
+ on = true
75
+ render()
76
+ }
77
+
78
+ /** the strip drawn where it belongs now: under the editor while it is open, else in its own panel; nowhere when
79
+ * switched off */
80
+ func render() {
81
+ if let host {
82
+ panel?.orderOut(nil)
83
+ host(on ? content() : nil)
84
+ } else if on {
85
+ let p = panel ?? makePanel()
86
+ panel = p
87
+ p.contentView = content()
88
+ p.setContentSize(p.contentView!.fittingSize)
89
+ if !p.isVisible && p.frameAutosaveName.isEmpty == false && !p.setFrameUsingName(p.frameAutosaveName) { place(p) }
90
+ p.orderFrontRegardless()
91
+ } else {
92
+ panel?.orderOut(nil)
93
+ }
50
94
  onChange?()
51
95
  }
52
96
 
97
+ /** a proof's hover: cell `i` shows its ×, armed when `armed`, as the pointer and a first click would leave it */
98
+ func hover(_ i: Int, armed: Bool) {
99
+ guard let cells = row?.arrangedSubviews, cells.indices.contains(i),
100
+ let poster = (cells[i] as? NSStackView)?.arrangedSubviews.first as? HoverThumb else { return }
101
+ poster.close.isHidden = false
102
+ if armed { deleteClicked(poster.close) }
103
+ }
104
+
53
105
  /** the open tray drawn to a png, title bar included, on its dark ground: a layout's proof, no screen grant needed */
54
106
  func snapshot(to: URL) throws {
55
107
  guard let p = panel, p.isVisible, let v = p.contentView?.superview ?? p.contentView else { throw Err("the tray is not open") }
@@ -66,9 +118,8 @@ final class RecentTray: NSObject {
66
118
  }
67
119
 
68
120
  func close() {
69
- panel?.orderOut(nil)
70
- UserDefaults.standard.set(false, forKey: RecentTray.SHOWN)
71
- onChange?()
121
+ on = false
122
+ render()
72
123
  }
73
124
 
74
125
  private func place(_ p: NSPanel) {
@@ -93,6 +144,7 @@ final class RecentTray: NSObject {
93
144
 
94
145
  private func content() -> NSView {
95
146
  let row = NSStackView()
147
+ self.row = row
96
148
  row.orientation = .horizontal
97
149
  row.spacing = 8
98
150
  row.edgeInsets = NSEdgeInsets(top: 8, left: 8, bottom: 8, right: 8)
@@ -100,7 +152,10 @@ final class RecentTray: NSObject {
100
152
  row.addArrangedSubview(NSTextField(labelWithString: "no capture yet: a hotkey of the menu takes one"))
101
153
  }
102
154
  for (i, it) in items.enumerated() { row.addArrangedSubview(cell(it, i)) }
103
- let all = NSButton(title: "All…", target: self, action: #selector(RecentTray.openAll))
155
+ let all = NSButton(title: "All captures", target: self, action: #selector(RecentTray.openAll))
156
+ all.image = NSImage(systemSymbolName: "square.grid.2x2", accessibilityDescription: "all captures")
157
+ all.imagePosition = .imageLeading
158
+ all.toolTip = "Every capture as a grid of thumbnails, in the Capture window"
104
159
  all.bezelStyle = .rounded
105
160
  all.controlSize = .small
106
161
  // what a new capture puts on the clipboard, changed here as in the menu
@@ -148,6 +203,17 @@ final class RecentTray: NSObject {
148
203
  menu.addItem(mi)
149
204
  }
150
205
  thumb.menu = menu
206
+ let del = NSButton(image: NSImage(systemSymbolName: "xmark", accessibilityDescription: "delete")!.withSymbolConfiguration(.init(pointSize: 8, weight: .bold))!, target: self, action: #selector(RecentTray.deleteClicked(_:)))
207
+ del.tag = i
208
+ disarm(del)
209
+ let poster = HoverThumb(thumb: thumb, close: del)
210
+ if host != nil, ref(it) == current {
211
+ poster.wantsLayer = true
212
+ poster.layer?.borderWidth = 2
213
+ poster.layer?.borderColor = NSColor.controlAccentColor.cgColor
214
+ poster.layer?.cornerRadius = 3
215
+ }
216
+ poster.onExit = { [weak self, weak del] in if let del, self?.armed === del { self?.disarm(del) } }
151
217
  let len = it.still ? "still" : String(format: "%d:%02d", Int(it.seconds) / 60, Int(it.seconds) % 60)
152
218
  let name = NSTextField(labelWithString: "\(it.name) · \(len)")
153
219
  name.font = NSFont.systemFont(ofSize: 10)
@@ -157,13 +223,13 @@ final class RecentTray: NSObject {
157
223
  name.widthAnchor.constraint(equalToConstant: RecentTray.W).isActive = true
158
224
  // a still copies as either format, whatever the menu's choice for a new capture; a video copies its file
159
225
  let copy: [NSButton] = it.still
160
- ? [labeled("PNG", "Copy as PNG: a paste attaches the file, or pastes the image", #selector(RecentTray.copyPng(_:)), i, .systemBlue),
161
- labeled("WebP", "Copy as WebP HQ (high quality): about a tenth of the PNG", #selector(RecentTray.copyWebp(_:)), i, .systemGreen)]
162
- : [action("doc.on.doc", "Copy the file: a paste attaches it", #selector(RecentTray.copyFile(_:)), i, .systemBlue)]
163
- let acts = NSStackView(views: [action("folder", "Show in Finder", #selector(RecentTray.reveal(_:)), i, .systemGray)] + copy + [action("link", "Copy a link: it plays in a browser for 7 days", #selector(RecentTray.copyLink(_:)), i, .systemPurple)])
164
- acts.spacing = 1
226
+ ? [labeled("PNG", "Copy as PNG: a paste attaches the file, or pastes the image", #selector(RecentTray.copyPng(_:)), i, Tint.file),
227
+ labeled("WebP", "Copy as WebP HQ (high quality): about a tenth of the PNG, made on its first copy and kept", #selector(RecentTray.copyWebp(_:)), i, Tint.webp)]
228
+ : [action("doc.on.doc", "Copy the file: a paste attaches it", #selector(RecentTray.copyFile(_:)), i, Tint.file)]
229
+ let acts = NSStackView(views: [action("folder", "Show in Finder", #selector(RecentTray.reveal(_:)), i, Tint.plain)] + copy + [action("link", "Copy a link: it plays in a browser for 7 days", #selector(RecentTray.copyLink(_:)), i, Tint.link)])
230
+ acts.spacing = 2
165
231
  acts.distribution = .fill
166
- var rows: [NSView] = [thumb, name, acts]
232
+ var rows: [NSView] = [poster, name, acts]
167
233
  if pending.contains(it.id) {
168
234
  let spin = NSProgressIndicator()
169
235
  spin.style = .spinning
@@ -187,10 +253,10 @@ final class RecentTray: NSObject {
187
253
  // drawn by its own layer: the panel never takes focus, and a bezel colour shows only in a focused window
188
254
  b.isBordered = false
189
255
  b.wantsLayer = true
190
- b.layer?.backgroundColor = color.withAlphaComponent(0.85).cgColor
256
+ b.layer?.backgroundColor = color.cgColor
191
257
  b.layer?.cornerRadius = 4
192
258
  b.contentTintColor = .white
193
- b.heightAnchor.constraint(equalToConstant: 18).isActive = true
259
+ b.heightAnchor.constraint(equalToConstant: 20).isActive = true
194
260
  b.tag = i
195
261
  b.toolTip = tip
196
262
  b.widthAnchor.constraint(equalToConstant: width).isActive = true
@@ -198,15 +264,15 @@ final class RecentTray: NSObject {
198
264
  }
199
265
 
200
266
  private func action(_ symbol: String, _ tip: String, _ sel: Selector, _ i: Int, _ color: NSColor) -> NSButton {
201
- let img = NSImage(systemSymbolName: symbol, accessibilityDescription: tip)!.withSymbolConfiguration(.init(pointSize: 9, weight: .semibold))!
202
- return tinted(NSButton(image: img, target: self, action: sel), color, 26, tip, i)
267
+ let img = NSImage(systemSymbolName: symbol, accessibilityDescription: tip)!.withSymbolConfiguration(.init(pointSize: 10, weight: .semibold))!
268
+ return tinted(NSButton(image: img, target: self, action: sel), color, 28, tip, i)
203
269
  }
204
270
 
205
271
  private func labeled(_ title: String, _ tip: String, _ sel: Selector, _ i: Int, _ color: NSColor) -> NSButton {
206
272
  let b = NSButton(title: title, target: self, action: sel)
207
- b.font = NSFont.systemFont(ofSize: 9, weight: .semibold)
273
+ b.font = NSFont.systemFont(ofSize: 10, weight: .semibold)
208
274
  b.attributedTitle = NSAttributedString(string: title, attributes: [.foregroundColor: NSColor.white, .font: b.font!])
209
- return tinted(b, color, 36, tip, i)
275
+ return tinted(b, color, 38, tip, i)
210
276
  }
211
277
 
212
278
  /** a button says it is done: a checkmark for a second, then its own picture again */
@@ -230,6 +296,48 @@ final class RecentTray: NSObject {
230
296
 
231
297
  private func ref(_ it: RecentItem) -> String { "\(it.repo)/\(it.id)" }
232
298
 
299
+ /** the ×: a first click arms it (red, a bin), a second within ARM_SECONDS deletes the capture for good through
300
+ * `sk rec rm`, so a stray click never loses one */
301
+ @objc func deleteClicked(_ s: Any) {
302
+ guard let b = s as? NSButton, let it = item(s) else { return }
303
+ guard armed === b else {
304
+ if let was = armed { disarm(was) }
305
+ armed = b
306
+ b.image = NSImage(systemSymbolName: "trash.fill", accessibilityDescription: "delete for good")!.withSymbolConfiguration(.init(pointSize: 8, weight: .bold))!
307
+ b.layer?.backgroundColor = NSColor.systemRed.cgColor
308
+ b.toolTip = "Click again to delete it for good: off the Space, its folder to the Trash"
309
+ DispatchQueue.main.asyncAfter(deadline: .now() + RecentTray.ARM_SECONDS) { [weak self, weak b] in
310
+ if let b, self?.armed === b { self?.disarm(b) }
311
+ }
312
+ return
313
+ }
314
+ armed = nil
315
+ b.isEnabled = false
316
+ Task {
317
+ let r = await sk?(["rec", "rm", ref(it), "--yes"])
318
+ if r?.code == 0 {
319
+ say("ok: deleted \(ref(it)) from the tray")
320
+ await refresh(show: false)
321
+ } else {
322
+ say("FAIL: sk rec rm \(ref(it)): \(r?.err.trimmingCharacters(in: .whitespacesAndNewlines) ?? "no sk")")
323
+ b.isEnabled = true
324
+ disarm(b)
325
+ done(b, ok: false)
326
+ }
327
+ }
328
+ }
329
+
330
+ private func disarm(_ b: NSButton) {
331
+ if armed === b { armed = nil }
332
+ b.image = NSImage(systemSymbolName: "xmark", accessibilityDescription: "delete")!.withSymbolConfiguration(.init(pointSize: 8, weight: .bold))!
333
+ b.isBordered = false
334
+ b.wantsLayer = true
335
+ b.layer?.backgroundColor = NSColor(white: 0, alpha: 0.65).cgColor
336
+ b.layer?.cornerRadius = 9
337
+ b.contentTintColor = .white
338
+ b.toolTip = "Delete this capture"
339
+ }
340
+
233
341
  @objc func openItem(_ s: Any) {
234
342
  guard let it = item(s) else { return }
235
343
  onEdit?(it.repo, it.id)
@@ -240,10 +348,7 @@ final class RecentTray: NSObject {
240
348
  onChange?()
241
349
  }
242
350
 
243
- @objc func openAll() {
244
- guard let h = home, let u = URL(string: "\(h)/recordings") else { return }
245
- NSWorkspace.shared.open(u)
246
- }
351
+ @objc func openAll() { onGallery?() }
247
352
 
248
353
  @objc func copyPng(_ s: Any) { copyStill(s, .png) }
249
354
  @objc func copyWebp(_ s: Any) { copyStill(s, .webpHigh) }
@@ -258,7 +363,7 @@ final class RecentTray: NSObject {
258
363
  f = ["out.png", "raw.png"].map { "\(it.dir)/\($0)" }.first { FileManager.default.fileExists(atPath: $0) }
259
364
  }
260
365
  guard let f else { done(s, ok: false); return }
261
- let ok = (try? await Clip.put(try Clip.stage(URL(fileURLWithPath: f)), format)) != nil
366
+ let ok = Clip.copy(ClipJob(pngFile: URL(fileURLWithPath: f), format: format, keep: it.webp.map { URL(fileURLWithPath: $0) })) { say("FAIL: \($0)") }
262
367
  done(s, ok: ok)
263
368
  }
264
369
  }
@@ -291,8 +396,46 @@ final class RecentTray: NSObject {
291
396
  extension RecentTray: NSWindowDelegate {
292
397
  nonisolated func windowWillClose(_ notification: Notification) {
293
398
  MainActor.assumeIsolated {
294
- UserDefaults.standard.set(false, forKey: RecentTray.SHOWN)
399
+ on = false
295
400
  onChange?()
296
401
  }
297
402
  }
298
403
  }
404
+
405
+ /** a capture's poster with its × in the top right corner, shown while the pointer is over it. The panel never takes
406
+ * the focus, so the hover tracks whether it is key or not */
407
+ final class HoverThumb: NSView {
408
+ let close: NSButton
409
+ var onExit: (() -> Void)?
410
+
411
+ init(thumb: NSButton, close: NSButton) {
412
+ self.close = close
413
+ super.init(frame: thumb.frame)
414
+ for v in [thumb, close] {
415
+ v.translatesAutoresizingMaskIntoConstraints = false
416
+ addSubview(v)
417
+ }
418
+ close.isHidden = true
419
+ NSLayoutConstraint.activate([
420
+ thumb.leadingAnchor.constraint(equalTo: leadingAnchor), thumb.trailingAnchor.constraint(equalTo: trailingAnchor),
421
+ thumb.topAnchor.constraint(equalTo: topAnchor), thumb.bottomAnchor.constraint(equalTo: bottomAnchor),
422
+ close.topAnchor.constraint(equalTo: topAnchor, constant: 4), close.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -4),
423
+ close.widthAnchor.constraint(equalToConstant: 18), close.heightAnchor.constraint(equalToConstant: 18),
424
+ ])
425
+ }
426
+
427
+ required init?(coder: NSCoder) { nil }
428
+
429
+ override func updateTrackingAreas() {
430
+ super.updateTrackingAreas()
431
+ for t in trackingAreas { removeTrackingArea(t) }
432
+ addTrackingArea(NSTrackingArea(rect: .zero, options: [.mouseEnteredAndExited, .activeAlways, .inVisibleRect], owner: self))
433
+ }
434
+
435
+ override func mouseEntered(with e: NSEvent) { close.isHidden = false }
436
+
437
+ override func mouseExited(with e: NSEvent) {
438
+ close.isHidden = true
439
+ onExit?()
440
+ }
441
+ }
@@ -0,0 +1,16 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 512 512">
2
+ <defs>
3
+ <linearGradient id="g" x1="0" y1="0" x2="0" y2="1">
4
+ <stop offset="0" stop-color="#ff6a5c"/>
5
+ <stop offset="1" stop-color="#d3202a"/>
6
+ </linearGradient>
7
+ </defs>
8
+ <rect width="512" height="512" fill="url(#g)"/>
9
+ <g fill="none" stroke="#ffffff" stroke-width="34" stroke-linecap="round" stroke-linejoin="round">
10
+ <path d="M112 196v-56a28 28 0 0 1 28-28h56"/>
11
+ <path d="M316 112h56a28 28 0 0 1 28 28v56"/>
12
+ <path d="M400 316v56a28 28 0 0 1-28 28h-56"/>
13
+ <path d="M196 400h-56a28 28 0 0 1-28-28v-56"/>
14
+ </g>
15
+ <circle cx="256" cy="256" r="78" fill="#ffffff"/>
16
+ </svg>