rvlib-shipkit 2.29.0 → 2.30.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 (512) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/package.json +2 -1
  3. package/src/advisors/app-graph.ts +1 -1
  4. package/src/advisors/expose.ts +5 -1
  5. package/src/advisors/r2.ts +7 -9
  6. package/src/advisors/routes.ts +29 -2
  7. package/src/advisors/scan.ts +11 -0
  8. package/src/agent-time/accounts-usage.ts +8 -0
  9. package/src/agent-time/claude-sessions.ts +32 -0
  10. package/src/agent-time/hooks.ts +1 -1
  11. package/src/agent-time/live.ts +5 -2
  12. package/src/agent-time/registry.ts +186 -89
  13. package/src/agent-time/store.ts +6 -4
  14. package/src/asks/ask-doc.ts +2 -2
  15. package/src/asks/ask-store.ts +22 -7
  16. package/src/check.ts +9 -1
  17. package/src/checks/SK001-package-json-shape.check.ts +1 -0
  18. package/src/checks/SK003-claude-md-shape.check.ts +1 -0
  19. package/src/checks/SK004-gitignore-policy.check.ts +12 -6
  20. package/src/checks/SK008-reviewer-agent.check.ts +4 -7
  21. package/src/checks/SK013-one-way-in-policy.check.ts +1 -0
  22. package/src/checks/SK017-vscode-hub-task.check.ts +1 -0
  23. package/src/checks/SK024-identity-colors.check.ts +1 -1
  24. package/src/checks/SK027-agent-wiki-links.check.ts +2 -1
  25. package/src/checks/SK033-global-contribution.check.ts +1 -0
  26. package/src/checks/SK034-commit-gates-armed.check.ts +1 -0
  27. package/src/checks/SK039-vscode-watch-generated.check.ts +1 -0
  28. package/src/checks/SK049-thread-answers-hook.check.ts +9 -5
  29. package/src/checks/SK050-retired-commands.check.ts +1 -0
  30. package/src/checks/SK051-no-formatter.check.ts +1 -0
  31. package/src/cli/channel-run.ts +17 -0
  32. package/src/cli/cmd_Advisors.ts +28 -7
  33. package/src/cli/cmd_Asks.ts +2 -2
  34. package/src/cli/cmd_Backup.ts +5 -1
  35. package/src/cli/cmd_CacheAudit.ts +1 -1
  36. package/src/cli/cmd_Channel.ts +43 -0
  37. package/src/cli/cmd_GlobalProcesses.ts +1 -0
  38. package/src/cli/cmd_Home.ts +12 -5
  39. package/src/cli/cmd_Hooks.ts +1 -1
  40. package/src/cli/cmd_Hq.ts +43 -0
  41. package/src/cli/cmd_Lanes.ts +15 -3
  42. package/src/cli/cmd_Media.ts +8 -3
  43. package/src/cli/cmd_Orchestrator.ts +253 -84
  44. package/src/cli/cmd_OrchestratorRole.ts +163 -0
  45. package/src/cli/cmd_Review.ts +142 -165
  46. package/src/cli/cmd_Secret.ts +44 -14
  47. package/src/cli/cmd_Shot.ts +2 -4
  48. package/src/cli/cmd_Sound.ts +1 -0
  49. package/src/cli/cmd_Urls.ts +3 -3
  50. package/src/cli/inbox-hook-run.ts +109 -0
  51. package/src/cli/registry.ts +6 -2
  52. package/src/cli/review-here.ts +136 -0
  53. package/src/cli.ts +45 -14
  54. package/src/collections/actions.ts +5 -4
  55. package/src/collections/checks.ts +5 -0
  56. package/src/collections/collection-types.ts +4 -3
  57. package/src/collections/pings.ts +4 -1
  58. package/src/collections/providers.ts +6 -4
  59. package/src/collections/tests.ts +7 -4
  60. package/src/core/app-icon-frame.ts +62 -0
  61. package/src/core/app-icon.ts +179 -17
  62. package/src/core/archived.ts +10 -7
  63. package/src/core/check-ctx.ts +38 -4
  64. package/src/core/check-pass.ts +7 -0
  65. package/src/core/foreign.ts +87 -0
  66. package/src/core/gui-color.ts +75 -0
  67. package/src/core/hub-theme.ts +1 -3
  68. package/src/core/layout.ts +3 -0
  69. package/src/core/machine-commit.ts +9 -1
  70. package/src/core/one-lib.ts +2 -1
  71. package/src/core/one-way-in-policy.ts +17 -12
  72. package/src/core/owner-word-policy.ts +123 -0
  73. package/src/core/panel-shades.ts +140 -0
  74. package/src/core/repo-gui-color.ts +16 -0
  75. package/src/core/role-policy.ts +17 -0
  76. package/src/core/scope.ts +6 -3
  77. package/src/core/tmux-policy.ts +264 -0
  78. package/src/core/unit-icon.ts +43 -0
  79. package/src/fleet/push-fleet.ts +2 -0
  80. package/src/fleet/scan-fleet.ts +3 -0
  81. package/src/gate/cache-audit.ts +7 -1
  82. package/src/gate/gate-checks.ts +14 -9
  83. package/src/gate/run-fix.ts +30 -5
  84. package/src/gate/run-fixers.ts +8 -3
  85. package/src/home/activity-shape.ts +2 -0
  86. package/src/home/activity.ts +2 -1
  87. package/src/home/daemon-guard.ts +20 -2
  88. package/src/home/daemon-jobs.ts +26 -18
  89. package/src/home/gui-app/ShipkitGui.swift +2012 -144
  90. package/src/home/gui-app/icon.svg +8 -0
  91. package/src/home/gui-app.ts +94 -30
  92. package/src/home/home-routes.ts +53 -9
  93. package/src/home/home-start.ts +27 -3
  94. package/src/home/inbox-shape.ts +7 -3
  95. package/src/home/log-follow.ts +117 -0
  96. package/src/home/machine-fold.ts +1 -1
  97. package/src/home/open-app.ts +9 -3
  98. package/src/home/page-build.ts +5 -1
  99. package/src/home/page-held.ts +1 -1
  100. package/src/home/pm-config.ts +0 -8
  101. package/src/home/pm.ts +62 -5
  102. package/src/home/process-apps.ts +70 -23
  103. package/src/home/process-rows.ts +16 -1
  104. package/src/home/push-sources.ts +18 -13
  105. package/src/home/resources.ts +16 -7
  106. package/src/home/run-daemon.ts +4 -1
  107. package/src/home/run-pm.ts +1 -1
  108. package/src/home/serve-daemon.ts +13 -4
  109. package/src/home/serve-web.ts +141 -17
  110. package/src/home/space-page.ts +3 -3
  111. package/src/home/space-route.ts +2 -2
  112. package/src/home/supervise.ts +2 -1
  113. package/src/home/vault-page.ts +2 -1
  114. package/src/home/web-places.ts +239 -0
  115. package/src/home/widgets.ts +16 -2
  116. package/src/hooks/commit-message.ts +11 -9
  117. package/src/hooks/one-way-in-guard.ts +145 -68
  118. package/src/hooks/run-hooks.ts +15 -5
  119. package/src/hooks/shared-file.ts +273 -83
  120. package/src/hooks/shell-writes.ts +620 -0
  121. package/src/hooks/write-log.ts +149 -0
  122. package/src/hq/door-route.ts +63 -7
  123. package/src/hq/door.ts +45 -12
  124. package/src/hq/history-send.ts +3 -1
  125. package/src/hq/hq-db.ts +10 -3
  126. package/src/hq/hq-local.ts +24 -5
  127. package/src/hq/hq-routes.ts +3 -1
  128. package/src/hq/hq-store.ts +9 -3
  129. package/src/hq/kinds/index.ts +2 -1
  130. package/src/hq/kinds/kind.ts +9 -4
  131. package/src/hq/kinds/presence-rule.ts +56 -0
  132. package/src/hq/kinds/presence.ts +210 -0
  133. package/src/hq/kinds/report.ts +8 -5
  134. package/src/hq/lead-order.ts +68 -0
  135. package/src/hq/outbox.ts +7 -0
  136. package/src/hq/replica.ts +5 -7
  137. package/src/hq/report-facts.ts +14 -7
  138. package/src/hq/report.ts +47 -2
  139. package/src/hq/switch.ts +1 -0
  140. package/src/hq/terminal-hop.ts +64 -0
  141. package/src/hq/thread-sync.ts +13 -6
  142. package/src/http/door-forward.ts +10 -12
  143. package/src/http/door-names.ts +9 -0
  144. package/src/http/hop-caller.ts +23 -0
  145. package/src/http/hop-names.ts +14 -0
  146. package/src/http/loopback-serve.ts +28 -6
  147. package/src/http/owner-word.ts +128 -0
  148. package/src/http/same-origin.ts +12 -0
  149. package/src/{serve → http}/secret-gate.ts +3 -3
  150. package/src/ledger/run-log.ts +25 -1
  151. package/src/media-store/backup/sources.ts +53 -6
  152. package/src/media-store/backup/thread-copy.ts +9 -5
  153. package/src/media-store/copy/config.ts +10 -9
  154. package/src/media-store/daemon.ts +5 -2
  155. package/src/media-store/put.ts +3 -0
  156. package/src/media-store/space.ts +14 -16
  157. package/src/media-store/upload.ts +4 -0
  158. package/src/messages/collection.ts +2 -2
  159. package/src/messages/model.ts +6 -1
  160. package/src/messages/routes.ts +3 -0
  161. package/src/orchestrator/brief.md +8 -6
  162. package/src/orchestrator/channel-declare.ts +58 -0
  163. package/src/orchestrator/channel.ts +226 -0
  164. package/src/orchestrator/guards.ts +12 -3
  165. package/src/orchestrator/host.ts +35 -0
  166. package/src/orchestrator/lead-shape.ts +86 -0
  167. package/src/orchestrator/now.ts +88 -0
  168. package/src/orchestrator/phone.ts +4 -1
  169. package/src/orchestrator/places-file.ts +38 -0
  170. package/src/orchestrator/places-look.ts +180 -0
  171. package/src/orchestrator/places-shape.ts +151 -0
  172. package/src/orchestrator/places.ts +50 -0
  173. package/src/orchestrator/presence-shape.ts +13 -2
  174. package/src/orchestrator/presence.ts +26 -15
  175. package/src/orchestrator/push.ts +5 -10
  176. package/src/orchestrator/role-shape.ts +270 -0
  177. package/src/orchestrator/role.ts +242 -0
  178. package/src/orchestrator/routes.ts +136 -31
  179. package/src/orchestrator/sessions-shape.ts +78 -0
  180. package/src/orchestrator/sessions.ts +86 -0
  181. package/src/orchestrator/share.ts +71 -0
  182. package/src/orchestrator/start-notice.ts +61 -0
  183. package/src/orchestrator/start.ts +137 -0
  184. package/src/orchestrator/started.ts +55 -0
  185. package/src/orchestrator/stuck.ts +196 -0
  186. package/src/orchestrator/unheard.ts +18 -7
  187. package/src/pages/frame-client.ts +44 -6
  188. package/src/problems/failure-words.ts +80 -0
  189. package/src/release/run-bump.ts +26 -5
  190. package/src/release/run-release.ts +34 -14
  191. package/src/repo-config.ts +37 -9
  192. package/src/review/aside-at.ts +19 -0
  193. package/src/review/band.ts +3 -3
  194. package/src/review/doc-save.ts +1 -1
  195. package/src/review/inbox-hook.ts +12 -4
  196. package/src/review/inbox-read.ts +20 -7
  197. package/src/review/instruction-guards.ts +137 -0
  198. package/src/review/instructions.ts +14 -2
  199. package/src/review/item-db.ts +52 -2
  200. package/src/review/mentions.ts +6 -4
  201. package/src/review/model.ts +3 -2
  202. package/src/review/parties.ts +88 -19
  203. package/src/review/push.ts +32 -15
  204. package/src/review/routes.ts +12 -4
  205. package/src/review/secret-route.ts +5 -5
  206. package/src/review/snooze.ts +1 -16
  207. package/src/review/store-parties.ts +4 -2
  208. package/src/review/take-back.ts +2 -1
  209. package/src/review/threads.ts +13 -2
  210. package/src/review/unit.ts +3 -2
  211. package/src/review/view-layout.ts +8 -1
  212. package/src/review/watchers.ts +25 -4
  213. package/src/secrets/key-pair.ts +14 -0
  214. package/src/secrets/lapse.ts +3 -3
  215. package/src/secrets/manager.ts +5 -1
  216. package/src/secrets/name-template.ts +83 -0
  217. package/src/secrets/name.ts +3 -0
  218. package/src/secrets/read.ts +10 -6
  219. package/src/secrets/secrets-view.ts +299 -0
  220. package/src/secrets/who-reads.ts +2 -1
  221. package/src/serve/frame-part.ts +49 -0
  222. package/src/serve/hub-app/accounts-line.tsx +33 -45
  223. package/src/serve/hub-app/activity-st.ts +6 -5
  224. package/src/serve/hub-app/activity-view.tsx +10 -9
  225. package/src/serve/hub-app/advice-box.tsx +6 -5
  226. package/src/serve/hub-app/advisor-app.tsx +2 -0
  227. package/src/serve/hub-app/advisor-face.tsx +3 -2
  228. package/src/serve/hub-app/advisor.html +1 -0
  229. package/src/serve/hub-app/advisors-view.tsx +52 -10
  230. package/src/serve/hub-app/advisors.css +4 -0
  231. package/src/serve/hub-app/app-bridge.ts +31 -5
  232. package/src/serve/hub-app/asked-page.ts +24 -0
  233. package/src/serve/hub-app/asks-page.tsx +10 -6
  234. package/src/serve/hub-app/auto-text.tsx +7 -5
  235. package/src/serve/hub-app/card-head.tsx +3 -2
  236. package/src/serve/hub-app/check-view.tsx +10 -9
  237. package/src/serve/hub-app/checks-svc.ts +96 -32
  238. package/src/serve/hub-app/clock-svc.ts +24 -8
  239. package/src/serve/hub-app/code-copy.ts +1 -1
  240. package/src/serve/hub-app/col-card.tsx +2 -1
  241. package/src/serve/hub-app/col-list-page.tsx +12 -6
  242. package/src/serve/hub-app/col-list-st.ts +12 -2
  243. package/src/serve/hub-app/col-tables-view.tsx +8 -44
  244. package/src/serve/hub-app/col-tables.ts +0 -14
  245. package/src/serve/hub-app/cols-svc.ts +6 -12
  246. package/src/serve/hub-app/columns.ts +94 -0
  247. package/src/serve/hub-app/comfy-view.tsx +8 -7
  248. package/src/serve/hub-app/commands/commands-page.tsx +4 -3
  249. package/src/serve/hub-app/commands/commands-st.ts +2 -2
  250. package/src/serve/hub-app/controls.css +69 -23
  251. package/src/serve/hub-app/cycle-button.tsx +2 -1
  252. package/src/serve/hub-app/database-st.ts +1 -1
  253. package/src/serve/hub-app/database-view.tsx +4 -2
  254. package/src/serve/hub-app/deaf.tsx +27 -0
  255. package/src/serve/hub-app/dock-st.ts +21 -16
  256. package/src/serve/hub-app/dock-view.tsx +19 -12
  257. package/src/serve/hub-app/empty-section.tsx +30 -0
  258. package/src/serve/hub-app/entry-bar.css +1 -1
  259. package/src/serve/hub-app/entry-bar.tsx +11 -6
  260. package/src/serve/hub-app/entry-list.css +32 -0
  261. package/src/serve/hub-app/entry-list.tsx +123 -0
  262. package/src/serve/hub-app/entry-pick.ts +1 -1
  263. package/src/serve/hub-app/entry-sections.ts +140 -0
  264. package/src/serve/hub-app/event-stream-reader.ts +56 -0
  265. package/src/serve/hub-app/floating.tsx +68 -14
  266. package/src/serve/hub-app/geometry-view.tsx +3 -2
  267. package/src/serve/hub-app/git-view.tsx +3 -2
  268. package/src/serve/hub-app/hash-route.ts +14 -2
  269. package/src/serve/hub-app/header-bar.tsx +53 -36
  270. package/src/serve/hub-app/home-st.ts +131 -14
  271. package/src/serve/hub-app/home-strip.css +24 -13
  272. package/src/serve/hub-app/home-strip.tsx +131 -66
  273. package/src/serve/hub-app/home.html +5 -0
  274. package/src/serve/hub-app/hub-app.tsx +94 -102
  275. package/src/serve/hub-app/hub.css +61 -94
  276. package/src/serve/hub-app/icons.tsx +16 -0
  277. package/src/serve/hub-app/identities-st.ts +19 -54
  278. package/src/serve/hub-app/identities-view.tsx +25 -24
  279. package/src/serve/hub-app/identity-address.ts +2 -2
  280. package/src/serve/hub-app/in-sight.ts +10 -0
  281. package/src/serve/hub-app/inbox-st.ts +20 -2
  282. package/src/serve/hub-app/inbox-view.tsx +16 -9
  283. package/src/serve/hub-app/inbox.css +1 -0
  284. package/src/serve/hub-app/index.html +5 -0
  285. package/src/serve/hub-app/insights-view.tsx +6 -5
  286. package/src/serve/hub-app/instructions.css +4 -1
  287. package/src/serve/hub-app/kept-cols.tsx +83 -20
  288. package/src/serve/hub-app/kept-width.tsx +76 -0
  289. package/src/serve/hub-app/keys.ts +116 -38
  290. package/src/serve/hub-app/layout-st.ts +109 -99
  291. package/src/serve/hub-app/lightbox-zoom.css +36 -0
  292. package/src/serve/hub-app/list-filter.tsx +15 -6
  293. package/src/serve/hub-app/list-head.tsx +29 -0
  294. package/src/serve/hub-app/list-row.ts +8 -0
  295. package/src/serve/hub-app/list-walk.ts +26 -105
  296. package/src/serve/hub-app/live-socket.ts +274 -0
  297. package/src/serve/hub-app/live-sources.ts +189 -0
  298. package/src/serve/hub-app/live-svc.ts +2 -2
  299. package/src/serve/hub-app/machine-st.ts +75 -14
  300. package/src/serve/hub-app/main-panel.css +211 -0
  301. package/src/serve/hub-app/main-panel.tsx +259 -0
  302. package/src/serve/hub-app/md.ts +4 -4
  303. package/src/serve/hub-app/media-svc.ts +5 -5
  304. package/src/serve/hub-app/media-view.tsx +13 -12
  305. package/src/serve/hub-app/messages/messages-page.tsx +8 -7
  306. package/src/serve/hub-app/messages/messages-st.ts +5 -2
  307. package/src/serve/hub-app/new-thread-st.ts +170 -0
  308. package/src/serve/hub-app/new-thread.tsx +133 -107
  309. package/src/serve/hub-app/orchestrator-line.tsx +115 -45
  310. package/src/serve/hub-app/orchestrator-places.tsx +86 -0
  311. package/src/serve/hub-app/orchestrator.css +57 -5
  312. package/src/serve/hub-app/page-keys.ts +107 -68
  313. package/src/serve/hub-app/page-reload.ts +46 -6
  314. package/src/serve/hub-app/pages-frames.tsx +40 -3
  315. package/src/serve/hub-app/pages-svc.ts +3 -1
  316. package/src/serve/hub-app/palette-st.ts +198 -43
  317. package/src/serve/hub-app/palette-view.tsx +32 -8
  318. package/src/serve/hub-app/panel-head-action.tsx +39 -0
  319. package/src/serve/hub-app/panel-head.tsx +70 -0
  320. package/src/serve/hub-app/panel-repo.ts +42 -0
  321. package/src/serve/hub-app/panel-source.ts +195 -0
  322. package/src/serve/hub-app/panel-tint.css +6 -0
  323. package/src/serve/hub-app/panel-tint.ts +23 -0
  324. package/src/serve/hub-app/panel-walk.ts +107 -0
  325. package/src/serve/hub-app/pill-row.tsx +2 -1
  326. package/src/serve/hub-app/place-path.ts +4 -0
  327. package/src/serve/hub-app/places-svc.ts +75 -0
  328. package/src/serve/hub-app/plan-view.tsx +3 -2
  329. package/src/serve/hub-app/polled.ts +11 -1
  330. package/src/serve/hub-app/presence-st.ts +66 -32
  331. package/src/serve/hub-app/processes-view.tsx +2 -2
  332. package/src/serve/hub-app/project-bar.tsx +116 -0
  333. package/src/serve/hub-app/project-list.css +20 -173
  334. package/src/serve/hub-app/project-list.tsx +30 -298
  335. package/src/serve/hub-app/projects-svc.ts +59 -32
  336. package/src/serve/hub-app/push-sign.tsx +2 -1
  337. package/src/serve/hub-app/push-svc.ts +86 -69
  338. package/src/serve/hub-app/quiet-st.ts +5 -3
  339. package/src/serve/hub-app/rail-groups.ts +144 -0
  340. package/src/serve/hub-app/reader-chips.tsx +2 -1
  341. package/src/serve/hub-app/recordings-st.ts +2 -1
  342. package/src/serve/hub-app/recordings-view.tsx +19 -47
  343. package/src/serve/hub-app/recordings.css +0 -2
  344. package/src/serve/hub-app/reflections-page.tsx +10 -6
  345. package/src/serve/hub-app/releases/releases-page.tsx +6 -5
  346. package/src/serve/hub-app/repo-sections.ts +127 -38
  347. package/src/serve/hub-app/repo-st.ts +57 -36
  348. package/src/serve/hub-app/review/advisor-bar.tsx +3 -2
  349. package/src/serve/hub-app/review/ask-proof.tsx +79 -0
  350. package/src/serve/hub-app/review/attach-view.tsx +11 -10
  351. package/src/serve/hub-app/review/box-view.ts +479 -0
  352. package/src/serve/hub-app/review/box-zoom.tsx +70 -0
  353. package/src/serve/hub-app/review/diff-view.tsx +3 -2
  354. package/src/serve/hub-app/review/doc-body.tsx +2 -1
  355. package/src/serve/hub-app/review/dock.tsx +3 -2
  356. package/src/serve/hub-app/review/draft-body.tsx +4 -3
  357. package/src/serve/hub-app/review/faces.tsx +0 -8
  358. package/src/serve/hub-app/review/group-block.tsx +8 -7
  359. package/src/serve/hub-app/review/heard-line.tsx +4 -3
  360. package/src/serve/hub-app/review/instructions-view.tsx +3 -2
  361. package/src/serve/hub-app/review/item-verdict.tsx +40 -40
  362. package/src/serve/hub-app/review/kind-states.tsx +5 -4
  363. package/src/serve/hub-app/review/kit.tsx +24 -4
  364. package/src/serve/hub-app/review/lane-bar.tsx +30 -28
  365. package/src/serve/hub-app/review/lightbox.tsx +6 -4
  366. package/src/serve/hub-app/review/live-bar.tsx +7 -6
  367. package/src/serve/hub-app/review/live-view.tsx +6 -5
  368. package/src/serve/hub-app/review/object-card.tsx +2 -1
  369. package/src/serve/hub-app/review/object-panel.tsx +11 -10
  370. package/src/serve/hub-app/review/pano-view.tsx +3 -2
  371. package/src/serve/hub-app/review/question-views.tsx +6 -5
  372. package/src/serve/hub-app/review/review-cells.tsx +21 -20
  373. package/src/serve/hub-app/review/review-host.ts +3 -0
  374. package/src/serve/hub-app/review/review-kit.ts +7 -5
  375. package/src/serve/hub-app/review/review-list.tsx +98 -52
  376. package/src/serve/hub-app/review/review-page.tsx +3 -3
  377. package/src/serve/hub-app/review/review-st.ts +70 -14
  378. package/src/serve/hub-app/review/review-thread.tsx +234 -138
  379. package/src/serve/hub-app/review/review-views.tsx +166 -191
  380. package/src/serve/hub-app/review/space3d.tsx +17 -9
  381. package/src/serve/hub-app/review/thread-close.tsx +24 -32
  382. package/src/serve/hub-app/review/thread-st.ts +39 -25
  383. package/src/serve/hub-app/review/trailer-body.tsx +5 -4
  384. package/src/serve/hub-app/review/trailer-page.tsx +18 -16
  385. package/src/serve/hub-app/review/trailer-st.ts +3 -2
  386. package/src/serve/hub-app/review/trailer-timeline.tsx +10 -9
  387. package/src/serve/hub-app/review/trailer-voices.tsx +29 -28
  388. package/src/serve/hub-app/review.css +159 -42
  389. package/src/serve/hub-app/row-acts.tsx +126 -0
  390. package/src/serve/hub-app/row-face.tsx +29 -0
  391. package/src/serve/hub-app/running-rows.tsx +142 -0
  392. package/src/serve/hub-app/running-st.ts +110 -0
  393. package/src/serve/hub-app/search-view.tsx +3 -2
  394. package/src/serve/hub-app/secrets-page.tsx +290 -0
  395. package/src/serve/hub-app/secrets-st.ts +181 -0
  396. package/src/serve/hub-app/secrets.css +65 -0
  397. package/src/serve/hub-app/section-head.tsx +3 -2
  398. package/src/serve/hub-app/session-chips.tsx +55 -0
  399. package/src/serve/hub-app/shell.ts +56 -0
  400. package/src/serve/hub-app/site/site-part.tsx +6 -5
  401. package/src/serve/hub-app/site/site-st.ts +0 -6
  402. package/src/serve/hub-app/site.css +0 -1
  403. package/src/serve/hub-app/social/calendar.tsx +7 -6
  404. package/src/serve/hub-app/social/comms-page.tsx +29 -26
  405. package/src/serve/hub-app/social/group-editor.tsx +2 -1
  406. package/src/serve/hub-app/social/kit.tsx +12 -11
  407. package/src/serve/hub-app/social/next-release.tsx +3 -2
  408. package/src/serve/hub-app/social/post-card.tsx +21 -20
  409. package/src/serve/hub-app/social/post-page.tsx +2 -1
  410. package/src/serve/hub-app/social/problems.tsx +3 -2
  411. package/src/serve/hub-app/social/social-page.tsx +29 -27
  412. package/src/serve/hub-app/social/social-st.ts +4 -2
  413. package/src/serve/hub-app/social/stage-popup.tsx +11 -10
  414. package/src/serve/hub-app/social.css +7 -5
  415. package/src/serve/hub-app/source-acts.ts +79 -0
  416. package/src/serve/hub-app/source-page.tsx +17 -0
  417. package/src/serve/hub-app/space-view.tsx +5 -4
  418. package/src/serve/hub-app/stores/stores-page.tsx +21 -19
  419. package/src/serve/hub-app/stores/stores-st.ts +1 -1
  420. package/src/serve/hub-app/stores.css +1 -1
  421. package/src/serve/hub-app/terminal-history-st.ts +112 -0
  422. package/src/serve/hub-app/terminal-keys.ts +79 -0
  423. package/src/serve/hub-app/terminal-lib.ts +110 -0
  424. package/src/serve/hub-app/terminal-links.ts +55 -0
  425. package/src/serve/hub-app/terminal-list-st.ts +304 -0
  426. package/src/serve/hub-app/terminal-log-st.ts +242 -0
  427. package/src/serve/hub-app/terminal-out.ts +135 -0
  428. package/src/serve/hub-app/terminal-pages.tsx +115 -0
  429. package/src/serve/hub-app/terminal-panel.tsx +60 -9
  430. package/src/serve/hub-app/terminal-sources.tsx +335 -0
  431. package/src/serve/hub-app/terminal-st.ts +447 -167
  432. package/src/serve/hub-app/terminal-stream.ts +233 -0
  433. package/src/serve/hub-app/terminal-tab.tsx +64 -0
  434. package/src/serve/hub-app/terminal-widths.ts +30 -0
  435. package/src/serve/hub-app/terminal.css +50 -4
  436. package/src/serve/hub-app/test-view.tsx +5 -3
  437. package/src/serve/hub-app/tests-view.tsx +16 -15
  438. package/src/serve/hub-app/theme-st.ts +5 -0
  439. package/src/serve/hub-app/thread-row.tsx +39 -31
  440. package/src/serve/hub-app/time-ago.tsx +3 -2
  441. package/src/serve/hub-app/time-view.tsx +2 -1
  442. package/src/serve/hub-app/time.css +1 -1
  443. package/src/serve/hub-app/timeline-chart.tsx +5 -4
  444. package/src/serve/hub-app/timeline-view.tsx +10 -9
  445. package/src/serve/hub-app/tips.ts +247 -0
  446. package/src/serve/hub-app/tree-build.ts +40 -8
  447. package/src/serve/hub-app/tree-svc.ts +167 -134
  448. package/src/serve/hub-app/unit-icons.ts +26 -0
  449. package/src/serve/hub-app/url-address.ts +154 -0
  450. package/src/serve/hub-app/url-faces.ts +88 -0
  451. package/src/serve/hub-app/url-forms.tsx +183 -0
  452. package/src/serve/hub-app/urls-svc.ts +167 -5
  453. package/src/serve/hub-app/urls-view.tsx +56 -20
  454. package/src/serve/hub-app/urls.css +26 -0
  455. package/src/serve/hub-app/vault-view.tsx +5 -4
  456. package/src/serve/hub-app/veille/veille-page.tsx +34 -33
  457. package/src/serve/hub-app/veille/veille-st.ts +6 -3
  458. package/src/serve/hub-app/view-layout.css +3 -3
  459. package/src/serve/hub-app/when-view.tsx +5 -4
  460. package/src/serve/hub-app/wikis-view.tsx +6 -5
  461. package/src/serve/hub-app/words.tsx +9 -2
  462. package/src/serve/hub-runtime.ts +3 -2
  463. package/src/serve/orchestrator-host.ts +58 -0
  464. package/src/serve/page-live.ts +147 -0
  465. package/src/serve/project-gutter-route.ts +63 -2
  466. package/src/serve/read-worker.ts +7 -2
  467. package/src/serve/runs-stamp.ts +33 -0
  468. package/src/serve/secrets-read.ts +156 -0
  469. package/src/serve/serve-hub.ts +71 -22
  470. package/src/serve/terminal-claudes.ts +185 -0
  471. package/src/serve/terminal-guard.ts +10 -5
  472. package/src/serve/terminal-host.ts +517 -0
  473. package/src/serve/terminal-record.ts +104 -0
  474. package/src/serve/terminal-route.ts +466 -103
  475. package/src/serve/terminal-shells.ts +3 -0
  476. package/src/serve/terminal-watch.ts +102 -0
  477. package/src/shipkit-files.ts +9 -4
  478. package/src/shot/client.ts +4 -9
  479. package/src/shot/shooter.ts +2 -4
  480. package/src/shot/shot-ask.ts +2 -7
  481. package/src/shot/shot-theme.ts +6 -17
  482. package/src/social/routes.ts +2 -2
  483. package/src/social/writes.ts +3 -0
  484. package/src/suite/test-units.ts +6 -2
  485. package/src/trailer/sound/eleven.ts +1 -0
  486. package/src/urls/added.ts +111 -0
  487. package/src/urls/icons.ts +294 -0
  488. package/src/urls/places.ts +139 -0
  489. package/src/urls/routes.ts +17 -7
  490. package/src/urls/rows.ts +48 -15
  491. package/src/urls/unit.ts +57 -3
  492. package/src/urls/write-routes.ts +207 -0
  493. package/src/vault/vault-destroy.ts +2 -1
  494. package/src/vault/vault-import.ts +4 -11
  495. package/src/vault/vault-restore.ts +3 -2
  496. package/src/veille/chrome.ts +18 -3
  497. package/src/veille/identity.ts +6 -0
  498. package/src/view3d/cam.ts +30 -46
  499. package/src/view3d/lib.ts +20 -2
  500. package/src/view3d/viewer.ts +62 -88
  501. package/src/wiki/agent-paths.ts +2 -1
  502. package/src/orchestrator/deliver.ts +0 -81
  503. package/src/orchestrator/drill.ts +0 -129
  504. package/src/orchestrator/keeper.ts +0 -332
  505. package/src/orchestrator/pm.ts +0 -20
  506. package/src/orchestrator/state.ts +0 -92
  507. package/src/orchestrator/switch.ts +0 -86
  508. package/src/orchestrator/tmux.ts +0 -82
  509. package/src/serve/hub-app/rail-fly.tsx +0 -95
  510. package/src/serve/hub-app/side-lists.ts +0 -72
  511. package/src/serve/hub-app/sidebar.tsx +0 -62
  512. package/src/serve/hub-app/tree-row.tsx +0 -125
@@ -0,0 +1,64 @@
1
+ // a terminal hop, the daemon's half (wiki tools/shipkit/hub.md, A terminal of another place): this machine's terminals
2
+ // typed into from the hq Mac's page. Its web brings the hop (http/hop-caller.ts: the whois, the tags); here every hop
3
+ // is judged again, at the check its web asks, at the socket's upgrade and at each request of the terminal routes.
4
+ // The one constraint a reader breaks first: the web's tags are headers, and a program of this Mac can write them to
5
+ // the daemon's port; the door key is what it cannot write (this machine keeps its hash only), so no hop passes
6
+ // without it, whatever its tags say
7
+ import { machineGet, machineSet } from '../core/machine-db.ts'
8
+ import { DOOR_KEY_HEADER } from '../http/door-forward.ts'
9
+ import { HOP_DEVICE_HEADER, HOP_HEADER, HOP_REPO_HEADER } from '../http/hop-caller.ts'
10
+ import { hostName, REACH_HEADER } from '../http/same-origin.ts'
11
+ import { doorKeyOk } from './door.ts'
12
+
13
+ /** this machine's terminals to the hq Mac's page: off by default, set on this machine only, never from afar */
14
+ export const MACHINE_TERMINALS = 'machine-terminals'
15
+ export const terminalsOn = (): boolean => machineGet<boolean>(MACHINE_TERMINALS) === true
16
+ /** false when the machine db does not open */
17
+ export const setTerminalsOn = (on: boolean): boolean => machineSet(MACHINE_TERMINALS, on)
18
+
19
+ /** the hq this machine joined, by its tailnet name: hq-local.ts HQ_URL (a test holds the two names alike); null
20
+ * on the machine that carries the hq, which hops to no one's terminals but its own */
21
+ export function hqHostOf(): string | null {
22
+ const url = machineGet<string>('hq-url')
23
+ if (url == null) return null
24
+ try {
25
+ return hostName(new URL(url).host)
26
+ } catch {
27
+ return null
28
+ }
29
+ }
30
+
31
+ /** what a test replaces: the hq's tailnet name, the key check, the switch */
32
+ export type HopDeps = { hqHost?: () => string | null; keyOk?: (key: string | null) => boolean; on?: () => boolean }
33
+
34
+ /** why a hop may not reach this machine's terminals, null when it may: the switch on, the door key the hq gave this
35
+ * machine, and the device tailscale named the hq's own Mac */
36
+ export function hopCheckRefusal(h: { key: string | null; device: string | null }, o: HopDeps = {}): string | null {
37
+ if (!(o.on ?? terminalsOn)()) return 'this machine keeps its terminals to itself: its switch machine-terminals is off (sk hq terminals on, on this machine)'
38
+ if (!(o.keyOk ?? doorKeyOk)(h.key)) return "this machine's terminals open to the hq's home only, with the key the hq gave this machine"
39
+ const hq = (o.hqHost ?? hqHostOf)()
40
+ if (hq == null) return 'this machine carries the hq: its terminals are typed into from its own page only'
41
+ if (h.device == null || hostName(h.device) !== hq) return `a terminal of this machine is typed into from the hq's Mac (${hq}) only, not from ${h.device ?? 'an unknown device'}`
42
+ return null
43
+ }
44
+
45
+ /** the request is a hop its web brought (by its tag: what decides is terminalHopRefusal) */
46
+ export const isTerminalHop = (req: Request): boolean => req.headers.get(HOP_HEADER) === 'terminal'
47
+
48
+ /** why a request the web tagged as a hop may not reach a terminal here, null when it may */
49
+ export function terminalHopRefusal(req: Request, o: HopDeps = {}): string | null {
50
+ if (!isTerminalHop(req)) return 'not a terminal hop'
51
+ if (req.headers.get(REACH_HEADER) !== 'tailnet') return 'a terminal hop comes over the tailnet, through this machine\'s web'
52
+ return hopCheckRefusal({ key: req.headers.get(DOOR_KEY_HEADER), device: req.headers.get(HOP_DEVICE_HEADER) }, o)
53
+ }
54
+
55
+ /** a page's socket the web brought as a hop (page-live.ts): why it may not reach a terminal, the one repo it is bound
56
+ * to (this machine's name of it), and its judge: the same check again with the key and the device it opened with,
57
+ * which the socket runs for as long as it is open (the switch turned off, the key forgotten: it closes); null for
58
+ * any other socket */
59
+ export function hopOfSocket(req: Request, o: HopDeps = {}): { refusal: string | null; scope: string; judge: () => string | null } | null {
60
+ if (!isTerminalHop(req)) return null
61
+ const scope = req.headers.get(HOP_REPO_HEADER) ?? ''
62
+ const held = { key: req.headers.get(DOOR_KEY_HEADER), device: req.headers.get(HOP_DEVICE_HEADER) }
63
+ return { refusal: scope === '' ? 'a terminal hop names its repo' : terminalHopRefusal(req, o), scope, judge: () => hopCheckRefusal(held, o) }
64
+ }
@@ -21,6 +21,7 @@ import { withItemsDb } from '../review/item-db.ts'
21
21
 
22
22
  import { machineDelete, machineGet, machineSet, openMachineFile } from '../core/machine-db.ts'
23
23
  import { threadsInDb, threadsOn } from './switch.ts'
24
+ import { isForeign } from '../core/foreign.ts'
24
25
 
25
26
  export { threadsOn, HQ_THREADS, setThreadsOn } from './switch.ts'
26
27
 
@@ -31,16 +32,18 @@ export const OUT_CHUNK = 1000
31
32
  export type HeldRepo = { id: string; name: string; path: string }
32
33
 
33
34
  /** each repo of this machine by its key, its remote as host and path. Two folders of one key (two clones of one remote)
34
- * are carried by neither: a row of the feed would have two homes. A repo with no remote is not carried (`left`) */
35
- export async function heldRepos(repos: readonly { name: string; path: string }[], keyOf: (path: string) => Promise<string | undefined> = repoKey): Promise<{ held: HeldRepo[]; twice: string[]; left: string[] }> {
36
- const keyed = await Promise.all(repos.map(async (r) => ({ key: await keyOf(r.path), name: r.name, path: r.path })))
35
+ * are carried by neither: a row of the feed would have two homes. A repo with no remote is not carried (`left`), nor a
36
+ * foreign one, whose items never leave this Mac (`foreign`, core/foreign.ts) */
37
+ export async function heldRepos(repos: readonly { name: string; path: string }[], keyOf: (path: string) => Promise<string | undefined> = repoKey): Promise<{ held: HeldRepo[]; twice: string[]; left: string[]; foreign: string[] }> {
38
+ const outside = repos.filter((r) => isForeign(r.path))
39
+ const keyed = await Promise.all(repos.filter((r) => !outside.includes(r)).map(async (r) => ({ key: await keyOf(r.path), name: r.name, path: r.path })))
37
40
  // a repo with no remote has no name two machines share: two repos of one folder name would share their items
38
41
  const left = keyed.filter((r) => r.key == null).map((r) => r.name)
39
42
  const all = keyed.flatMap((r) => (r.key == null ? [] : [{ id: r.key, name: r.name, path: r.path }]))
40
43
  const count = new Map<string, number>()
41
44
  for (const r of all) count.set(r.id, (count.get(r.id) ?? 0) + 1)
42
45
  const twice = [...count].filter(([, n]) => n > 1).map(([id]) => id)
43
- return { held: all.filter((r) => count.get(r.id) === 1), twice, left }
46
+ return { held: all.filter((r) => count.get(r.id) === 1), twice, left, foreign: outside.map((r) => r.name) }
44
47
  }
45
48
 
46
49
  /** may a node of this grant write and read that repo: `all`, or a repo grant that names it exactly. A grant not
@@ -411,9 +414,9 @@ async function oneLook(o: { repos: { name: string; path: string }[]; print: (l:
411
414
  return 1
412
415
  }
413
416
  try {
414
- const { held, twice, left } = await heldRepos(o.repos)
417
+ const { held, twice, left, foreign } = await heldRepos(o.repos)
415
418
  // said when it changes: the job runs every 30 s
416
- const leftLine = left.length === 0 ? '' : `the repos with no remote stay on this machine: ${left.join(', ')}`
419
+ const leftLine = [left.length === 0 ? '' : `the repos with no remote stay on this machine: ${left.join(', ')}`, foreign.length === 0 ? '' : `the foreign repos stay on this machine: ${foreign.join(', ')}`].filter((l) => l !== '').join('; ')
417
420
  if (!dry && new Ledger(db, new Map()).word('cards-left') !== leftLine) {
418
421
  if (leftLine !== '') o.print(`ok: hq threads: ${leftLine}`)
419
422
  new Ledger(db, new Map()).setWord('cards-left', leftLine)
@@ -421,6 +424,7 @@ async function oneLook(o: { repos: { name: string; path: string }[]; print: (l:
421
424
  const now = Date.now()
422
425
  const stores = held.map((r) => storeDir(r.path))
423
426
  if (!dry && JSON.stringify(machineGet<string[]>(STORES) ?? []) !== JSON.stringify(stores)) machineSet(STORES, stores)
427
+ if (!dry && JSON.stringify(machineGet<HeldRepo[]>(HELD_REPOS) ?? []) !== JSON.stringify(held)) machineSet(HELD_REPOS, held)
424
428
  const w = walkSet(stores, new Ledger(db, new Map()), now)
425
429
  const t = await threadsTick({ db, link: hq, repos: held, now, dry, ...(w.walk == null ? {} : { walk: w.walk }) })
426
430
  if (!dry && t.warns.length === 0) w.done()
@@ -484,6 +488,9 @@ export function waitingRows(path: string = daemonDbPath()): { n: number; since:
484
488
  const dueHeld = { stamps: new Map<string, string>(), at: 0 }
485
489
  /** the machine db word of the review folders the job holds: what the due looks at */
486
490
  const STORES = 'hq-cards-stores'
491
+ /** the machine db word of the repos the job holds, by their keys: what the look of places sends the facts of
492
+ * (orchestrator/places-look.ts) */
493
+ export const HELD_REPOS = 'hq-held-repos'
487
494
 
488
495
  /** the machine db rows that tell the job which review folders moved since its last look, one a folder, its stamp the
489
496
  * value: the daemon's watch writes them, the job walks those folders and takes away the rows it walked */
@@ -4,7 +4,7 @@
4
4
  // (wiki tools/shipkit/urls.md). Light on purpose: the web imports it. The one constraint a reader breaks first: the
5
5
  // target's origin always comes from a lookup (hq/door.ts, urls/frame.ts), never from the request; the request gives a
6
6
  // path and names, never an address
7
- import { DNS_LABEL, doorOrigin, loopbackOrigin, machineLabel, urlFrameLabel, urlFrameOrigin } from './door-names.ts'
7
+ import { DNS_LABEL, doorOrigin, loopbackOrigin, machineLabel, urlFrameOrigin, urlLabelOf } from './door-names.ts'
8
8
  import { createHmac } from 'crypto'
9
9
  import { readFileSync } from 'fs'
10
10
  import { join } from 'path'
@@ -39,29 +39,26 @@ export const doorPolicy = (host: string): string => `default-src 'self' 'unsafe-
39
39
  const LABEL = DNS_LABEL
40
40
  const PROCESS_ID = /^[a-z][a-z0-9-]*$/
41
41
 
42
- /** the process and machine a Host names, `<process>.<machine>.localhost[:port]`; null for any other name */
42
+ /** the process and machine a Host names, `<process>.<machine>.localhost[:port]`; null for any other name. A label
43
+ * with `--` is a url a place declares, `<url id>--<repo>` (urlLabelOf), never a process: `process` holds it whole */
43
44
  export function doorHostOf(host: string | null): { process: string; machine: string } | null {
44
45
  if (host == null) return null
45
46
  const name = host.trim().toLowerCase().replace(/:\d+$/, '').replace(/\.$/, '')
46
47
  const parts = name.split('.')
47
48
  if (parts.length !== 3 || parts[2] !== 'localhost') return null
48
49
  const [process, machine] = parts as [string, string]
49
- return LABEL.test(process) && PROCESS_ID.test(process) && LABEL.test(machine) ? { process, machine } : null
50
+ const named = process.includes('--') ? urlLabelOf(process) != null : PROCESS_ID.test(process)
51
+ return LABEL.test(process) && named && LABEL.test(machine) ? { process, machine } : null
50
52
  }
51
53
 
52
- export { doorOrigin, loopbackOrigin, machineLabel, urlFrameOrigin }
54
+ export { doorOrigin, loopbackOrigin, machineLabel, urlFrameOrigin, urlLabelOf }
53
55
 
54
56
  /** the declared url a Host names, `<url id>--<repo>.localhost[:port]` (urlFrameLabel); null for any other name */
55
57
  export function urlHostOf(host: string | null): { id: string; repo: string } | null {
56
58
  if (host == null) return null
57
59
  const parts = host.trim().toLowerCase().replace(/:\d+$/, '').replace(/\.$/, '').split('.')
58
60
  if (parts.length !== 2 || parts[1] !== 'localhost') return null
59
- const label = parts[0]!
60
- const cut = label.lastIndexOf('--')
61
- if (cut < 1) return null
62
- const id = label.slice(0, cut)
63
- const repo = label.slice(cut + 2)
64
- return urlFrameLabel(id, repo) === label && machineLabel(repo) === repo ? { id, repo } : null
61
+ return urlLabelOf(parts[0]!)
65
62
  }
66
63
 
67
64
  /** the hub page's own origins on a port: the three loopback names the home's page is opened by on this Mac */
@@ -114,9 +111,10 @@ export function loginHop(url: string, target: string): boolean {
114
111
  /** whether an answer asks for an http basic login */
115
112
  export const basicChallenge = (r: Response): boolean => r.status === 401 && /(^|,)\s*basic(\s|$|,)/i.test(r.headers.get('www-authenticate') ?? '')
116
113
 
117
- /** a door's `/door/<id>/<rest>` path read: the process id and the rest, which starts with `/`; null for another path */
114
+ /** a door's `/door/<id>/<rest>` path read: the process id (or a url's label, `<url id>--<repo>`) and the rest, which
115
+ * starts with `/`; null for another path */
118
116
  export function doorPathOf(path: string): { id: string; rest: string } | null {
119
- const m = /^\/door\/([a-z][a-z0-9-]*)(\/.*)?$/.exec(path)
117
+ const m = /^\/door\/([a-z0-9][a-z0-9-]*)(\/.*)?$/.exec(path)
120
118
  return m == null ? null : { id: m[1]!, rest: m[2] ?? '/' }
121
119
  }
122
120
 
@@ -22,6 +22,15 @@ export function urlFrameLabel(id: string, repo: string): string | null {
22
22
  return /^[a-z0-9][a-z0-9-]*$/.test(id) && machineLabel(repo) !== '' && DNS_LABEL.test(label) ? label : null
23
23
  }
24
24
 
25
+ /** the url id and repo label a url's label names, split at its last `--`; null for a label that is none */
26
+ export function urlLabelOf(label: string): { id: string; repo: string } | null {
27
+ const cut = label.lastIndexOf('--')
28
+ if (cut < 1) return null
29
+ const id = label.slice(0, cut)
30
+ const repo = label.slice(cut + 2)
31
+ return urlFrameLabel(id, repo) === label && machineLabel(repo) === repo ? { id, repo } : null
32
+ }
33
+
25
34
  /** the address of a declared url the home frames: `<url id>--<repo>.localhost` on the home's port */
26
35
  export function urlFrameOrigin(id: string, repo: string, port: number | string): string | null {
27
36
  const label = urlFrameLabel(id, repo)
@@ -0,0 +1,23 @@
1
+ // a terminal hop, its web half (wiki tools/shipkit/hub.md, A terminal of another place): the path a place's web
2
+ // answers the hq Mac's web on, the tags it writes on what it brings to its daemon, and who may call it. Light: the web
3
+ // imports it. The daemon's half, the key and the switch, is hq/terminal-hop.ts.
4
+ // The one constraint a reader breaks first: the caller is tailscale's whois of the address tailscaled wrote, never a
5
+ // header, and it must be the hq's Mac: a phone, a tagged device, another Mac of the owner and the place itself never type
6
+ import { isPhone, ownersDevice, servedCaller, type TailnetWho } from './tailnet-caller.ts'
7
+
8
+ export { HOP_DEVICE_HEADER, HOP_HEADER, HOP_PATH, HOP_REPO_HEADER, HOP_VERBS, type HopVerb, hopVerb } from './hop-names.ts'
9
+
10
+ /** the device that calls a hop, by tailscale's whois of the address tailscaled wrote: an untagged device of this
11
+ * Mac's owner that is a Mac, not this one. Whether it is the hq's Mac is the daemon's word (it knows the hq it
12
+ * joined): its MagicDNS name goes on as the tag */
13
+ export async function hopCaller(req: Request, who: TailnetWho): Promise<{ device: string } | { refused: string }> {
14
+ const caller = servedCaller(req.headers)
15
+ if ('refused' in caller) return { refused: `a terminal of this machine is reached over the tailnet only: ${caller.refused}` }
16
+ const self = await who.self()
17
+ if (self == null) return { refused: 'tailscale does not answer on this machine' }
18
+ const peer = await ownersDevice(who, self, caller)
19
+ if ('refused' in peer) return peer
20
+ if (peer.id === self.id) return { refused: 'a machine never hops into its own terminals' }
21
+ if (isPhone(peer)) return { refused: 'a phone never types into a terminal of another machine' }
22
+ return { device: peer.node.toLowerCase() }
23
+ }
@@ -0,0 +1,14 @@
1
+ // a terminal hop's names (wiki tools/shipkit/hq.md, A terminal hop), with no import: the Bash guard reads them
2
+ // (core/owner-word-policy.ts) as well as the webs (http/hop-caller.ts) and the daemon (hq/terminal-hop.ts)
3
+
4
+ /** the hop's paths on a place's web: `live` (its socket), `open`, `watch`, `close`, `window`, `history`. Under the
5
+ * door's `/door/`, never a process's (an id holds no `_`) */
6
+ export const HOP_PATH = '/door/_terminal/'
7
+ export const HOP_VERBS = ['live', 'open', 'watch', 'close', 'window', 'history'] as const
8
+ export type HopVerb = (typeof HOP_VERBS)[number]
9
+ export const hopVerb = (v: string): HopVerb | null => ((HOP_VERBS as readonly string[]).includes(v) ? (v as HopVerb) : null)
10
+
11
+ /** the place's web's tags on a hop it brings to its daemon: that it is one, the device tailscale named, the repo */
12
+ export const HOP_HEADER = 'x-shipkit-hop'
13
+ export const HOP_DEVICE_HEADER = 'x-shipkit-hop-device'
14
+ export const HOP_REPO_HEADER = 'x-shipkit-hop-repo'
@@ -1,8 +1,11 @@
1
1
  // the one way the house opens a server (wiki tools/shipkit/home.md, Every server on loopback): on 127.0.0.1, behind
2
- // the Host check and `sameOrigin` of same-origin.ts, and a write that came over the tailnet from an untagged device of
3
- // the owner only; RV040 refuses a bare Bun.serve. The one constraint a reader breaks first: every request passes
4
- // `fetch`, so a server never takes Bun's static `routes`, which skip it
5
- import { HOST_HEADER, hostName, loopbackName, REACH_HEADER, reachOfCaller, sameOrigin } from './same-origin.ts'
2
+ // the Host check, `sameOrigin` and `socketOrigin` of same-origin.ts (a write, and a socket's upgrade, from this
3
+ // server's own page), a write as the owner and a hub page's socket from a page of the hub only (owner-word.ts),
4
+ // and a write that came over the tailnet from an untagged device of the owner only; RV040 refuses a bare Bun.serve.
5
+ // The one constraint a reader breaks first: every request passes `fetch`, so a server never takes Bun's static
6
+ // `routes`, which skip it
7
+ import { ownerWordRefusal, type TestPage } from './owner-word.ts'
8
+ import { HOST_HEADER, hostName, loopbackName, REACH_HEADER, reachOfCaller, sameOrigin, socketOrigin } from './same-origin.ts'
6
9
  import { tailnetRefusal, type TailnetWho } from './tailnet-caller.ts'
7
10
 
8
11
  /** what a server adds to the loopback guard. `hosts`: the other names it answers by (the web's tailnet name, the hq
@@ -11,21 +14,40 @@ import { tailnetRefusal, type TailnetWho } from './tailnet-caller.ts'
11
14
  export type LoopbackGuard = {
12
15
  hosts?: (name: string) => boolean
13
16
  crossSite?: (req: Request) => boolean
17
+ /** a request the server hands whole to another app under a name of that app (a hop): its paths are that app's,
18
+ * so none is a route of the owner's (owner-word.ts) */
19
+ otherApp?: (req: Request) => boolean
20
+ /** the server a browser reaches first (the web): it decides a write as the owner on the browser's own headers,
21
+ * and a tag of the web on a request it receives is a client's own word, never read */
22
+ front?: true
23
+ /** a server no browser reaches (the daemon, behind the web): it reads a write as the owner by the web's tags
24
+ * alone, and what the web did not bring carries no mark of a browser, whatever headers it shows */
25
+ behind?: true
26
+ /** the server was started by a test: its clients stand in for a page of the hub with that test's token
27
+ * (owner-word.ts TestPage). No server the product starts has one */
28
+ testPage?: TestPage
14
29
  /** a write over the tailnet: from an untagged device of the owner (the default), or the server's own guard (the
15
30
  * hq port and the web's `/door/`: each node's token, the door key); a function decides per request */
16
31
  tailnetWrites?: TailnetWrites | ((req: Request) => TailnetWrites)
17
32
  /** who calls over the tailnet; absent, this Mac's tailscale (a test passes its own) */
18
33
  who?: TailnetWho
34
+ /** a terminal hop of the hq Mac's page that passed its own guard (hq/terminal-hop.ts): a word as the owner on a
35
+ * terminal's path or a page's socket that no browser of this machine brings (the daemon's) */
36
+ terminalHop?: (req: Request) => boolean
19
37
  }
20
38
 
21
39
  /** why a request does not reach a server of this machine, null when it does: a Host that is no loopback name nor one
22
- * the server declares is a page of another site rebound to 127.0.0.1; a write from another site's page is refused */
40
+ * the server declares is a page of another site rebound to 127.0.0.1; a write from another site's page is refused,
41
+ * a socket it opens too, and a write as the owner from anything but a page of the hub. `crossSite` never lifts that
42
+ * last one */
23
43
  export function loopbackRefusal(req: Request, g: LoopbackGuard = {}): string | null {
24
44
  const host = req.headers.get('host') ?? new URL(req.url).host
25
45
  const name = hostName(host)
26
46
  if (!loopbackName(name) && g.hosts?.(name) !== true) return `refused: this server answers to a loopback name, never to ${host === '' ? 'a request with no Host' : host.slice(0, 80)}`
27
47
  if (!sameOrigin(req) && g.crossSite?.(req) !== true) return "refused: a request that changes something comes from this server's own page"
28
- return null
48
+ // a hop to another app keeps that app's own rule on who opens its sockets
49
+ if (!socketOrigin(req) && g.crossSite?.(req) !== true && g.otherApp?.(req) !== true) return "refused: a socket is opened by this server's own page, never by another site's"
50
+ return g.otherApp?.(req) === true ? null : ownerWordRefusal(req, { front: g.front === true, behind: g.behind === true, ...(g.testPage == null ? {} : { testPage: g.testPage }), ...(g.terminalHop == null ? {} : { hop: g.terminalHop }) })
29
51
  }
30
52
 
31
53
  /** what a server of the house declares: no hostname (always 127.0.0.1), no static `routes` (every request passes
@@ -0,0 +1,128 @@
1
+ // the gate on the owner's own acts (wiki tools/shipkit/home.md, Every server on loopback): the routes that write a
2
+ // word as the owner (a reply, a verdict, an answer, a new thread, a confirm of an advisor's advice) take it from a
3
+ // page of the hub in a browser, and refuse a program's request. The routes are the data below; `loopbackRefusal`
4
+ // (loopback-serve.ts) runs the decision before every server's fetch, so no route file holds a copy.
5
+ // What he types into a terminal of the hub is a word as the owner too (a line typed into a Claude Code session is a
6
+ // prompt with his permissions): the terminal's routes are a family below, and a hub page's one socket (PAGE_SOCKET,
7
+ // on which his keys go) is opened under the same rule.
8
+ // It guards these routes and nothing else. A word as the owner has doors it does not hold: tmux itself (a command to
9
+ // its socket), the cli run with no agent variable, a browser a program drives, a write straight into the store.
10
+ // The one constraint a reader breaks first: the web drops the browser's Origin and Sec-Fetch-Site as it forwards, so
11
+ // the WEB is the hop that decides (`front`), on the browser's real headers, and it tags what it read (ORIGIN_HEADER,
12
+ // FETCH_SITE_HEADER). Behind it the daemon (`behind`) refuses a request the web did not bring; one the web brought it
13
+ // reads by those tags. The web's tags are headers too: a program that writes them by hand to the daemon's port
14
+ // passes, and the Bash guard is what refuses that command (core/owner-word-policy.ts)
15
+ import { HOST_HEADER, REACH_HEADER, reachOfCaller } from './same-origin.ts'
16
+
17
+ /** the web's tag of the browser's Origin on what it forwards to the daemon */
18
+ export const ORIGIN_HEADER = 'x-shipkit-origin'
19
+ /** the web's tag of the browser's Sec-Fetch-Site on what it forwards to the daemon */
20
+ export const FETCH_SITE_HEADER = 'x-shipkit-fetch-site'
21
+
22
+ /** a family of routes whose every write is the owner's act: `under` a path below a hub's base, `not` the paths under
23
+ * it a program calls by design, behind a guard of their own */
24
+ export type OwnerRoutes = { under: string; what: string; not?: readonly string[] }
25
+
26
+ export const OWNER_WORD_ROUTES: readonly OwnerRoutes[] = [
27
+ { under: '/api/review', what: 'a thread: his reply, answer, verdict, close, reopen, snooze, mute, attach, lane ask, note, raised item, rating, action, read mark, staged draft, file, share, secret' },
28
+ { under: '/api/trailer', what: 'a trailer: his note on a frame, its state and words, his voice takes' },
29
+ { under: '/api/act', what: "an ask's done, decline, proof and remark, his act on a reflection, a note on an asset" },
30
+ { under: '/api/docs', what: 'the editor: his save of a document, a picture he drops into it' },
31
+ { under: '/api/stores', what: 'a store page: his note in its thread, its texts, his paste ticks' },
32
+ { under: '/api/social', what: 'the social desk: publish, a draft moved or posted, a setup step, a secret', not: ['/api/social/tracker'] },
33
+ { under: '/api/veille', what: 'the Veille: his reply to a post, a review raised, a post handled', not: ['/api/veille/batch'] },
34
+ { under: '/api/messages', what: 'the messages store: his suggestion of a message or a phrasing' },
35
+ { under: '/api/home/orchestrators', what: "a session made the default, a project placed, a new thread's words, its files and the session it goes to" },
36
+ { under: '/api/home/advisors', what: "the advisors: one added or removed, a thread shared, an advisor's advice confirmed, a proposal accepted" },
37
+ { under: '/api/home/quiet', what: 'his quiet mode: no push to his phone' },
38
+ { under: '/api/urls', what: 'a url added, edited or removed, how it opens, a login typed, a url opened in Chrome', not: ['/api/urls/copy'] },
39
+ { under: '/api/terminal', what: "the terminal: a part asked on a page's socket (a terminal, a list), an act on a terminal (a new one, Claude Code started, one closed), its history" },
40
+ ]
41
+
42
+ /** a hub page's one socket (serve/page-live.ts), under a hub alone or under the home's `/r/<repo>`: what he types
43
+ * into a terminal goes on it, so it is opened as a word as the owner is written */
44
+ export const PAGE_SOCKET = /^(?:\/r\/[^/]+)?\/api\/live$/
45
+
46
+ /** a test's stand in for a page of the hub. A check's bun client sends none of a browser's marks, so a hub a TEST
47
+ * started takes this header with the token that test made, in place of the marks. A hub started with none (every
48
+ * hub the product starts) never reads the header. `from` is the one file that makes one: no code of the product
49
+ * can, and the value comes from no variable, file or flag a program could give a running hub
50
+ * (tests/test-page.test.ts reads the source for it) */
51
+ export const TEST_PAGE_HEADER = 'x-shipkit-test-page'
52
+ export type TestPage = { readonly token: string; readonly from: 'tests/test-hub.ts' }
53
+
54
+ const below = (path: string, under: string): boolean => path === under || path.startsWith(`${under}/`)
55
+ /** a path as a hub alone names it: the home's `/r/<repo>` gone */
56
+ const underHub = (path: string): string => path.replace(/^\/r\/[^/]+(?=\/api\/)/, '')
57
+
58
+ /** whether a path, under a hub alone or under the home's `/r/<repo>`, is one of the owner's routes */
59
+ export function ownerWordPath(path: string): boolean {
60
+ const p = underHub(path)
61
+ return OWNER_WORD_ROUTES.some((r) => below(p, r.under) && !(r.not ?? []).some((n) => below(p, n)))
62
+ }
63
+
64
+ const READS = new Set(['GET', 'HEAD', 'OPTIONS'])
65
+
66
+ /** `front`: the server a browser reaches first (the web). There a tag is a client's own word and is never read.
67
+ * `behind`: a server no browser reaches (the daemon): what the web did not bring carries no mark, whatever headers
68
+ * of a browser it shows. `testPage`: this server was started by a test */
69
+ export type Hop = { front?: boolean; behind?: boolean; testPage?: TestPage; /** a terminal hop that passed its own guard (the daemon's) */ hop?: (req: Request) => boolean }
70
+
71
+ /** whether tailscaled brought the request: by its own headers at the web, by the web's tag behind it. At the web the
72
+ * tag is whatever the client wrote, so it counts for nothing there */
73
+ export const broughtByTailnet = (req: Request, o: Hop = {}): boolean => (o.front !== true && req.headers.get(REACH_HEADER) === 'tailnet') || reachOfCaller(req) === 'tailnet'
74
+
75
+ /** what the browser said of the request, at the hop that sees the browser or behind the web: its Sec-Fetch-Site, its
76
+ * Origin, and the host it asked (a proxy that frames the page under its own origin passes that host on).
77
+ * `forwarded`: the web brought it, so its marks are the web's tags */
78
+ export function browserMarks(req: Request, o: Hop = {}): { site: string | null; origin: string | null; host: string; forwarded: boolean } {
79
+ const h = req.headers
80
+ const own = h.get('origin')
81
+ const ownSite = h.get('sec-fetch-site')
82
+ // the web strips both and tags what it read: a request that carries either is read by its own headers
83
+ const forwarded = o.front !== true && own == null && ownSite == null && h.has(REACH_HEADER)
84
+ const host = h.get('x-forwarded-host') ?? (forwarded ? h.get(HOST_HEADER) : null) ?? h.get('host') ?? new URL(req.url).host
85
+ if (o.behind === true && !forwarded) return { site: null, origin: null, host: host.toLowerCase(), forwarded }
86
+ return { site: forwarded ? h.get(FETCH_SITE_HEADER) : ownSite, origin: forwarded ? h.get(ORIGIN_HEADER) : own, host: host.toLowerCase(), forwarded }
87
+ }
88
+
89
+ /** whether a read came from a page of the hub: what a read must be before it writes anything in the owner's name (the
90
+ * secret field's read answers its question once the store holds the value). A browser sends no Origin on its page's
91
+ * own read, so its Sec-Fetch-Site decides; a request tailscaled brought keeps the rule it had */
92
+ export function ownerPageRead(req: Request): boolean {
93
+ const { site } = browserMarks(req)
94
+ return site === 'same-origin' || (broughtByTailnet(req) && (site == null || site === 'none'))
95
+ }
96
+
97
+ /** read by two: the owner, when the page itself is refused (it draws these words under what was written, which
98
+ * stays in its box), and a program */
99
+ export const OWNER_WORD_REFUSED = "refused: a word as the owner comes from a page of the hub in a browser, and this request carried no mark of one. At the page: reload it, or open the hub in its app; your words stay in the box. A program writes as itself: sk thread reply"
100
+
101
+ /** read by a program, and by the owner where a page shows why its terminal did not open */
102
+ export const PAGE_ONLY_REFUSED = "refused: a hub page's socket and its terminals answer a page of the hub in a browser, and this request carried no mark of one. At the page: reload it. A program reads the stores' notices with sk thread watch and runs its commands in its own shell"
103
+
104
+ /** whether the request carries the token of the test that started this server */
105
+ const fromTestPage = (req: Request, o: Hop): boolean => o.testPage != null && o.testPage.token.length >= 32 && req.headers.get(TEST_PAGE_HEADER) === o.testPage.token
106
+
107
+ /** why a request may not write as the owner, null when it may or when it is no write of his: a browser's own same
108
+ * origin request (Sec-Fetch-Site same-origin, and an Origin of the host it asked). A request tailscaled brought keeps
109
+ * the tailnet's rule (loopback-serve.ts `tailnetWriteRefusal`): the device is tailscale's word.
110
+ * A page's socket is judged at its upgrade, whatever its method and from any reach (over the tailnet it reaches no
111
+ * terminal, page-live.ts): an Origin of the host it asked, which a browser names on every socket; Sec-Fetch-Site
112
+ * only where the browser sent one (Chrome sends none on a socket) */
113
+ export function ownerWordRefusal(req: Request, o: Hop = {}): string | null {
114
+ const path = new URL(req.url).pathname
115
+ const socket = PAGE_SOCKET.test(path)
116
+ if (!socket && (READS.has(req.method) || !ownerWordPath(path))) return null
117
+ if (fromTestPage(req, o)) return null
118
+ const terminal = socket || below(underHub(path), '/api/terminal')
119
+ if (terminal && o.hop?.(req) === true) return null
120
+ if (!socket && broughtByTailnet(req, o)) return null
121
+ const refused = terminal ? PAGE_ONLY_REFUSED : OWNER_WORD_REFUSED
122
+ const { site, origin, host } = browserMarks(req, o)
123
+ if (origin == null || (socket && site == null ? false : site !== 'same-origin')) return refused
124
+ try {
125
+ if (new URL(origin).host === host) return null
126
+ } catch { /* a malformed origin is no page of the hub */ }
127
+ return refused
128
+ }
@@ -53,3 +53,15 @@ export function sameOrigin(req: Request): boolean {
53
53
  try { return new URL(origin).host === host } catch { return false }
54
54
  }
55
55
 
56
+
57
+ /** a WebSocket's upgrade is a GET that no same origin policy binds: a page of any site can open one to localhost and
58
+ * read what it says. A browser always names its page's origin on it, so the server reads it: true for the server's
59
+ * own page, and for a program, which names none (the web's pipe to the daemon, a client in a terminal). A hub
60
+ * page's own socket asks more: owner-word.ts. Bun upgrades on a list too (`websocket, x`), so the word is searched */
61
+ export function socketOrigin(req: Request): boolean {
62
+ if (!/\bwebsocket\b/i.test(req.headers.get('upgrade') ?? '')) return true
63
+ const origin = req.headers.get('origin')
64
+ if (origin == null) return true
65
+ const host = req.headers.get('x-forwarded-host') ?? new URL(req.url).host
66
+ try { return new URL(origin).host === host } catch { return false }
67
+ }
@@ -4,9 +4,9 @@
4
4
  // desk's setup step both pass it.
5
5
  // The one constraint a reader breaks first: a tailnet request passes on headers tailscaled wrote, so a relay to the
6
6
  // home that keeps a caller's headers and has no tailscaled in front of it lets that caller pass as the phone
7
- import { broughtByProxy } from '../http/door-forward.ts'
8
- import { loopbackHost, reachOf, sameOrigin } from '../http/same-origin.ts'
9
- import { tailnetRefusal, type TailnetWho } from '../http/tailnet-caller.ts'
7
+ import { broughtByProxy } from './door-forward.ts'
8
+ import { loopbackHost, reachOf, sameOrigin } from './same-origin.ts'
9
+ import { tailnetRefusal, type TailnetWho } from './tailnet-caller.ts'
10
10
 
11
11
  export const SECRET_WHERE = 'a secret is typed in the hub on the Mac that runs it, or on your phone over the tailnet'
12
12
 
@@ -23,7 +23,7 @@ import { Database } from 'bun:sqlite'
23
23
  import { existsSync } from 'fs'
24
24
  import type { Line } from '../core/wire.ts'
25
25
  import { BUSY_MS, dbPath, INSERT_RUN, openDb, UPSERT_INVOCATION, UPSERT_LAST, UPSERT_LIVE } from './db.ts'
26
- import { LIVE_BEAT_MS, liveRowDead, type LiveRow, type LiveState } from './live-runs.ts'
26
+ import { LIVE_BEAT_MS, liveRowDead, pidAlive, type LiveRow, type LiveState } from './live-runs.ts'
27
27
 
28
28
  export type RunStatus = 'pass' | 'warn' | 'fail' | 'skip'
29
29
 
@@ -344,6 +344,30 @@ export function readLiveReadonly(path: string): LiveRow[] {
344
344
  }
345
345
  }
346
346
 
347
+ /** what a page of runs draws anew, as one line: each run in flight with the checks it runs and how many it finished,
348
+ * then the last rows of the runs and of the invocations recorded. It moves when a run or a check starts or ends and
349
+ * on nothing else: a run's heartbeat and a row of another table move the file, never this. A run whose writer is
350
+ * gone (liveRowDead: its process, or its beat for 20 s) reads `x` where a live one reads `r`: a killed run writes no
351
+ * end. Read only, as readLiveReadonly; null when the record cannot be read now */
352
+ export function readTransitionsReadonly(path: string, now: number = Date.now(), alive: (pid: number) => boolean = pidAlive): string | null {
353
+ if (!existsSync(path)) return ''
354
+ let db: Database | null = null
355
+ try {
356
+ db = new Database(path, { readonly: true })
357
+ db.exec('pragma busy_timeout = 50')
358
+ const has = (t: string): boolean => db!.query("select 1 from sqlite_master where type = 'table' and name = ?").get(t) != null
359
+ const live = has('live') ? (db.query(LIVE_SELECT).all() as RawLive[]).map(liveRowOf).filter((r) => r != null) : []
360
+ const flying = live.map((r) => `${r.runId}:${r.ended != null ? 'e' : liveRowDead(r, now, alive) ? 'x' : 'r'}:${r.running.map((c) => c.id).sort().join(',')}:${r.finished.length}`).sort()
361
+ const lastRun = has('runs') ? ((db.query('select max(rowid) as n from runs').get() as { n: number | null }).n ?? 0) : 0
362
+ const lastInvocations = has('invocations') ? (db.query('select rowid as n, ended from invocations order by rowid desc limit 5').all() as { n: number; ended: number | null }[]).map((r) => `${r.n}${r.ended == null ? 'r' : 'e'}`) : []
363
+ return `${flying.join('|')}#${lastRun}#${lastInvocations.join(',')}`
364
+ } catch {
365
+ return null
366
+ } finally {
367
+ try { db?.close() } catch { /* already gone */ }
368
+ }
369
+ }
370
+
347
371
  /** every check's last outcome in a record, read only, for a hub that shows
348
372
  * ANOTHER repo's gate: `[]` when the record or the table is missing */
349
373
  export function readLastStatusReadonly(path: string): { id: string; status: string; at: number }[]
@@ -10,7 +10,8 @@ import { lstat, readdir } from 'node:fs/promises'
10
10
  import { existsSync, lstatSync, readdirSync, statSync } from 'node:fs'
11
11
  import { basename, dirname, join, relative, sep } from 'node:path'
12
12
  import { homeDir } from '../../home/home-paths.ts'
13
- import { isTombstone, machineDbPath, oldStorePath } from '../../core/machine-db.ts'
13
+ import { isTombstone, machineDbPath, oldStorePath, openMachineFile } from '../../core/machine-db.ts'
14
+ import { isForeign } from '../../core/foreign.ts'
14
15
  import { machinePath } from '../../core/machine-layout.ts'
15
16
  import { orderFile } from '../../serve/project-gutter-route.ts'
16
17
  import { mediaDbPath } from '../db.ts'
@@ -178,6 +179,48 @@ export async function backupOfRepo(repo: string): Promise<RepoBackup | null> {
178
179
  * daemon's file, or in the machine db once it is folded */
179
180
  export const THREAD_STORE_TABLES = ['review_cards', 'review_msgs', 'review_gone', 'review_replaced', 'review_repos', 'thread_events', 'thread_post_groups', 'thread_posts']
180
181
 
182
+ /** the repo ids the thread stores in `files` file a foreign repo's items under (core/foreign.ts), read from the
183
+ * stores themselves: `review_repos` names each one by its git common dir and its review folder, so a pass with no
184
+ * repo list (the thread copy, its drill) finds them too */
185
+ export function foreignThreadRepos(files: readonly string[]): string[] {
186
+ const out = new Set<string>()
187
+ for (const f of new Set(files)) {
188
+ if (!existsSync(f)) continue
189
+ let db: ReturnType<typeof openMachineFile> | null = null
190
+ try {
191
+ db = openMachineFile(f, { readonly: true })
192
+ if (db.query(`select 1 from sqlite_schema where name = 'review_repos'`).get() == null) continue
193
+ for (const r of db.query('select dir, repo from review_repos').all() as { dir: string; repo: string }[]) {
194
+ const common = r.dir.startsWith('git:') ? r.dir.slice(4) : null
195
+ const root = common != null ? (basename(common) === '.git' ? dirname(common) : null) : r.dir.endsWith(`${sep}${REVIEW_TAIL}`) ? r.dir.slice(0, -REVIEW_TAIL.length - 1) : null
196
+ if (root != null && isForeign(root)) out.add(r.repo)
197
+ }
198
+ } catch {
199
+ // a store that does not open holds no row to leave out
200
+ } finally {
201
+ db?.close()
202
+ }
203
+ }
204
+ return [...out].sort()
205
+ }
206
+
207
+ const REVIEW_TAIL = join('.shipkit', 'review')
208
+
209
+ /** the cut with every row of the thread tables filed under these repo ids left out */
210
+ export function withoutRepos(cut: SqliteCut, repos: readonly string[]): SqliteCut {
211
+ if (repos.length === 0) return cut
212
+ const clause = `repo in (${repos.map((r) => `'${r.replace(/'/g, "''")}'`).join(', ')})`
213
+ const except = { ...(cut.except ?? {}) }
214
+ for (const t of THREAD_STORE_TABLES) except[t] = except[t] ? `(${except[t]}) or ${clause}` : clause
215
+ return { ...cut, except }
216
+ }
217
+
218
+ /** the repos the backup holds, and the foreign ones it leaves out whole (core/foreign.ts) */
219
+ export function backupRepos(repos: readonly string[]): { kept: string[]; left: string[] } {
220
+ const left = repos.filter((r) => isForeign(r))
221
+ return { kept: repos.filter((r) => !left.includes(r)), left }
222
+ }
223
+
181
224
  /** the machine db as a run holds it. The Mac's own names stay out: a run restored on another Mac must not make it
182
225
  * take this one's name, nor its place in an hq (the hq it joined, the switch that opens its own, its key:
183
226
  * hq/hq-local.ts). The backup's own records stay out too (kept.ts): else every run differs. Its tables are named:
@@ -217,12 +260,15 @@ export async function collect(o: Collect): Promise<Source[]> {
217
260
  const files: string[] = []
218
261
  const add = (abs: string): void => void files.push(abs)
219
262
  // the backup's own objects and records, and the pids, move by themselves: left out, else every run differs
263
+ // a foreign repo is left out whole: its files, its memories, and its rows of the thread store
264
+ const held = backupRepos(o.repos).kept
265
+ const foreign = foreignThreadRepos([machineDbPath(), daemonDbPath()])
220
266
  const sqlite = new Map<string, SqliteCut>([
221
267
  [mediaDbPath(), mediaCut],
222
- [machineDbPath(), machineCut],
268
+ [machineDbPath(), withoutRepos(machineCut, foreign)],
223
269
  ])
224
270
  // the daemon's file until it is folded: then its items are tables of the machine db, in its cut
225
- if (daemonDbPath() !== machineDbPath()) sqlite.set(daemonDbPath(), threadStoreCut)
271
+ if (daemonDbPath() !== machineDbPath()) sqlite.set(daemonDbPath(), withoutRepos(threadStoreCut, foreign))
226
272
  const unfolded = unfoldedMedia()
227
273
  if (unfolded != null) sqlite.set(unfolded, unfoldedMediaCut)
228
274
  await walk(join(homeDir(), 'veille'), () => true, files, undefined, scope)
@@ -230,8 +276,8 @@ export async function collect(o: Collect): Promise<Source[]> {
230
276
  // the rows forgotten at the hq, ids only: neither the hq's replica nor a restore of it carries them
231
277
  add(forgottenLogPath(hqDbPath()))
232
278
  await walk(machinePath('private', o.home), () => true, files, undefined, scope)
233
- for (const root of await agentRoots(o.home)) for (const repo of o.repos) await walk(join(root, sessionName(repo), 'memory'), () => true, files, undefined, scope)
234
- const repos = scope ? o.repos.filter((r) => scope.reaches(r)) : o.repos
279
+ for (const root of await agentRoots(o.home)) for (const repo of held) await walk(join(root, sessionName(repo), 'memory'), () => true, files, undefined, scope)
280
+ const repos = scope ? held.filter((r) => scope.reaches(r)) : held
235
281
  // the git walks of ignored trees take seconds each: all at once
236
282
  const locals = new Map(await Promise.all(repos.map(async (r) => [r, await (o.locals ?? ((x: string) => localFiles(x, o.git)))(r)] as const)))
237
283
  const whole = new Set<string>()
@@ -372,7 +418,8 @@ export interface WatchRoot {
372
418
  }
373
419
 
374
420
  /** `named` gives a repo's `backup.paths` as the last look read them: asked at each event, so a new name counts at once */
375
- export async function watchRoots(home: string, repos: readonly string[], named: (repo: string) => readonly string[] = () => []): Promise<WatchRoot[]> {
421
+ export async function watchRoots(home: string, all: readonly string[], named: (repo: string) => readonly string[] = () => []): Promise<WatchRoot[]> {
422
+ const repos = backupRepos(all).kept
376
423
  const order = orderFile(home)
377
424
  const memory = new Set(repos.map(sessionName))
378
425
  return [