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
@@ -32,6 +32,7 @@ export const GIT_PAGE_MS = 7 * 24 * 3600_000
32
32
  import type { HouseView } from '../ledger/house-runs.ts'
33
33
  import { identitiesRoute } from '../identities/machine-route.ts'
34
34
  import { siteRoutes } from '../site/routes.ts'
35
+ import type { OtherMac } from './other-macs.ts'
35
36
 
36
37
  /** how often the daemon looks at every repo */
37
38
  export const TICK_MS = 2_000
@@ -48,6 +49,10 @@ export type HomeAnswer = {
48
49
  modernize: Record<string, ModernizeView>
49
50
  /** the daemon runs older code than its tree, and why (core/last-good.ts) */
50
51
  held?: string | null
52
+ /** the other Macs whose home answers on the tailnet (other-macs.ts) */
53
+ otherMacs?: OtherMac[]
54
+ /** this Mac's short tailnet name, shown beside them */
55
+ here?: string | null
51
56
  }
52
57
 
53
58
  export type HomeDeps = {
@@ -70,8 +75,10 @@ export type HomeDeps = {
70
75
  widgets?: Widgets
71
76
  /** brings a repo current (modernizeCmd); resolves to its exit code */
72
77
  modernize?: (repo: WiredRepo, log: string) => Promise<number>
73
- /** the machine's tailnet name, the house config's serve.publicHost: the one name besides localhost the web answers to */
74
- publicHost?: string
78
+ /** this Mac's tailnet name (machine-host.ts, serve.publicHost overriding it): the one name besides localhost the web answers to */
79
+ publicHost?: () => string | null
80
+ /** the other Macs' homes, the last answer at once */
81
+ otherMacs?: () => OtherMac[]
75
82
  }
76
83
 
77
84
  /** the sizes the app icon is drawn at: the phone's home screen, the manifest's two */
@@ -165,7 +172,7 @@ export function homeRoutes(d: HomeDeps) {
165
172
  const modernize: Record<string, ModernizeView> = {}
166
173
  for (const [k, m] of modernizing) modernize[k] = { status: m.status, code: m.code, tail: tailLines(m.log, 40) }
167
174
  const h = heldNow()
168
- return { version: LIB_VERSION, workers: d.hubs.views(repos), active: d.state.data.active, behind, modernize, held: h == null ? null : heldText(h) }
175
+ return { version: LIB_VERSION, workers: d.hubs.views(repos), active: d.state.data.active, behind, modernize, held: h == null ? null : heldText(h), otherMacs: d.otherMacs?.() ?? [], here: d.publicHost?.()?.split('.')[0] ?? null }
169
176
  }
170
177
 
171
178
  const icons = new Map<number, Promise<Uint8Array<ArrayBuffer> | null>>()
@@ -219,7 +226,7 @@ export function homeRoutes(d: HomeDeps) {
219
226
  // the web asks which page routes to serve: one per house repo
220
227
  if (path === '/api/home/repos.json') {
221
228
  if (repos.length === 0) await refresh()
222
- return Response.json({ repos: d.hubs.names(), hosts: d.publicHost == null ? [] : [d.publicHost] })
229
+ return Response.json({ repos: d.hubs.names(), hosts: [d.publicHost?.()].filter((h): h is string => h != null) })
223
230
  }
224
231
  // everything that waits on the owner in every repo, one list (inbox.ts)
225
232
  if (path === '/api/inbox') {
@@ -0,0 +1,65 @@
1
+ // this Mac's two names. `machineName` keys what one Mac writes beside another's in a store they share
2
+ // (a backup run, its block of a tracked page); `machinePublicHost` is the name its other devices reach it by.
3
+ // Two Macs never share a value of either, so neither is ever written in a repo both check out
4
+ // (tools/shipkit/home.md, Two machines). Both live in the machine db once read.
5
+ import { hostname } from 'os'
6
+ import { machineGet, machineSet } from '../core/machine-db.ts'
7
+
8
+ /** a host name without the `.local` of its Bonjour form */
9
+ export const hostLabel = (raw: string): string => raw.replace(/\.local$/i, '')
10
+
11
+ const NAME = 'machine-name'
12
+
13
+ /** this Mac's name, fixed the first time it is read (the system's host name then): macOS renames a host it meets
14
+ * twice on a network, and a block or a run keyed by a new name would orphan the old one */
15
+ export function machineName(): string {
16
+ const held = machineGet<string>(NAME)
17
+ if (held) return held
18
+ const name = hostLabel(hostname())
19
+ if (!/[A-Za-z0-9]/.test(name)) throw new Error(`this Mac's host name (${JSON.stringify(hostname())}) has no letter or digit to key its backups and blocks by: set one in System Settings, Sharing`)
20
+ machineSet(NAME, name)
21
+ return name
22
+ }
23
+
24
+ /** the tailscale cli: on PATH when its wrapper is installed, else inside the app */
25
+ export const TAILSCALE = ['tailscale', '/Applications/Tailscale.app/Contents/MacOS/Tailscale']
26
+
27
+ /** `Self.DNSName` of `tailscale status --json`, without its final dot; null when no tailscale answers */
28
+ export function readTailnetName(bins: string[] = TAILSCALE): string | null {
29
+ for (const bin of bins) {
30
+ try {
31
+ const p = Bun.spawnSync([bin, 'status', '--json'], { stdout: 'pipe', stderr: 'ignore', timeout: 3000 })
32
+ if (p.exitCode !== 0) continue
33
+ const name = (JSON.parse(p.stdout.toString()) as { Self?: { DNSName?: string } }).Self?.DNSName?.replace(/\.$/, '')
34
+ if (name) return name
35
+ } catch {
36
+ // a missing binary throws: the next one is tried
37
+ }
38
+ }
39
+ return null
40
+ }
41
+
42
+ const TAILNET = 'tailnet-name'
43
+ /** how long a process keeps "tailscale did not answer" before it asks again */
44
+ export const TAILNET_RETRY_MS = 60_000
45
+ let asked: { name: string | null; at: number } | undefined
46
+
47
+ /** this Mac's tailnet name: tailscale's answer, read once a process, else the last name it gave (kept in the machine
48
+ * db, since a device keeps its name while tailscale is stopped), asked again a minute later.
49
+ * `SHIPKIT_TAILNET_NAME` sets it, empty for none */
50
+ export function tailnetName(now: number = Date.now(), read: () => string | null = readTailnetName): string | null {
51
+ const env = process.env['SHIPKIT_TAILNET_NAME']
52
+ if (env !== undefined) return env === '' ? null : env
53
+ if (asked === undefined || (asked.name == null && now - asked.at >= TAILNET_RETRY_MS)) {
54
+ asked = { name: read(), at: now }
55
+ if (asked.name != null && machineGet<string>(TAILNET) !== asked.name) machineSet(TAILNET, asked.name)
56
+ }
57
+ return asked.name ?? machineGet<string>(TAILNET)
58
+ }
59
+
60
+ /** forget what this process asked, for a test */
61
+ export const forgetTailnetAnswer = (): void => void (asked = undefined)
62
+
63
+ /** the name a phone or another Mac uses for this one: the config's `serve.publicHost` (a single Mac's override), else
64
+ * its tailnet name */
65
+ export const machinePublicHost = (c: { serve?: { publicHost?: string } }): string | null => c.serve?.publicHost ?? tailnetName()
@@ -1,5 +1,5 @@
1
1
  // the machine's own stores and their caps (core/retention.ts owns the model):
2
- // every log under the home dir, and the gui window's Chrome profile. And the
2
+ // the temp folders, every log under the home dir, and the gui window's Chrome profile. And the
3
3
  // daemon's retention job that sweeps every store, the repos' and these, in a
4
4
  // child process (daemon-jobs.ts).
5
5
  import { existsSync, lstatSync, readdirSync, rmSync, statSync } from 'fs'
@@ -7,6 +7,7 @@ import { join } from 'path'
7
7
  import { repoStores, sweepStores, walkUse, type Store } from '../core/retention.ts'
8
8
  import { capLog, LOG_MAX_BYTES } from './supervise.ts'
9
9
  import { machineSet } from '../core/machine-db.ts'
10
+ import { sweepTemp, tempAuto, tempAutoAt, tempRoots, tempUse } from './machine-temp.ts'
10
11
 
11
12
  /** a log nothing wrote for this long belongs to a process that is gone (a
12
13
  * repo removed, a resource dropped) */
@@ -53,7 +54,30 @@ const profileInUse = (profile: string): boolean => {
53
54
  try { return lstatSync(join(profile, 'SingletonLock')).isSymbolicLink() } catch { return false }
54
55
  }
55
56
 
56
- export function machineStores(dir: string): Store[] {
57
+ /** a temp pass this old stopped running: the sweep is hourly */
58
+ export const TEMP_PASS_MAX_MS = 6 * 60 * 60 * 1000
59
+
60
+ /** the machine's temp folders, once the owner's switch is on (machine-temp.ts): one store for the three roots, since
61
+ * one pass sweeps them all. It reads what the last pass kept, with no walk, and its age is the last pass's (the
62
+ * switch's, before the first one), so a sweep that stopped or never started is loud */
63
+ function temp(o: { print: (l: string) => void; printErr: (l: string) => void }): Store[] {
64
+ if (!tempAuto()) return []
65
+ return [{
66
+ id: 'temp folders',
67
+ where: `${tempRoots().map((r) => r.path).join(', ')} (the age is the last pass's: sk tmp)`,
68
+ cap: { maxAgeMs: TEMP_PASS_MAX_MS },
69
+ measure: () => {
70
+ const use = tempUse()
71
+ const kept = use?.passes ?? []
72
+ return { count: kept.reduce((n, p) => n + p.kept, 0), oldestAt: use?.at ?? tempAutoAt() ?? Date.now(), bytes: kept.reduce((n, p) => n + p.keptBytes, 0), largestFile: 0 }
73
+ },
74
+ sweep: (now) => { sweepTemp({ now, print: o.print, printErr: o.printErr }) },
75
+ }]
76
+ }
77
+
78
+ const stderr = (l: string): void => void process.stderr.write(`${l}\n`)
79
+
80
+ export function machineStores(dir: string, o: { print?: (l: string) => void; printErr?: (l: string) => void } = {}): Store[] {
57
81
  const profile = join(dir, 'gui-profile')
58
82
  return [
59
83
  {
@@ -82,6 +106,8 @@ export function machineStores(dir: string): Store[] {
82
106
  for (const d of GUI_CACHE_DIRS) rmSync(join(profile, d), { recursive: true, force: true })
83
107
  },
84
108
  },
109
+ // last: its walk is the long one, and the stores above never wait on it
110
+ ...temp({ print: o.print ?? stderr, printErr: o.printErr ?? stderr }),
85
111
  ]
86
112
  }
87
113
 
@@ -92,12 +118,12 @@ export const SWEEP_EVERY_MS = 60 * 60 * 1000
92
118
  export const SWEPT_AT = 'retention-swept-at'
93
119
  /** one sweep of the daemon's retention job, in its child process: every repo, then the machine, then `also`; its
94
120
  * end time kept, so the daemon's next look waits SWEEP_EVERY_MS whatever restarts in between */
95
- export async function sweepTick(o: { roots: string[]; dir: string; printErr: (l: string) => void; now?: () => number; also?: (now: number) => void }): Promise<void> {
121
+ export async function sweepTick(o: { roots: string[]; dir: string; print?: (l: string) => void; printErr: (l: string) => void; now?: () => number; also?: (now: number) => void }): Promise<void> {
96
122
  const now = (o.now ?? Date.now)()
97
123
  for (const root of o.roots) {
98
124
  for (const r of await sweepStores(repoStores(root), now)) if (r.error != null) o.printErr(`WARN retention sweep of ${r.id} in ${root} failed: ${r.error}`)
99
125
  }
100
- for (const r of await sweepStores(machineStores(o.dir), now)) if (r.error != null) o.printErr(`WARN retention sweep of ${r.id} failed: ${r.error}`)
126
+ for (const r of await sweepStores(machineStores(o.dir, { print: o.print, printErr: o.printErr }), now)) if (r.error != null) o.printErr(`WARN retention sweep of ${r.id} failed: ${r.error}`)
101
127
  o.also?.(now)
102
128
  machineSet(SWEPT_AT, (o.now ?? Date.now)())
103
129
  }