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
@@ -1,5 +1,5 @@
1
- // what the orchestrator may never run without his yes, as Claude Code deny rules (its `--settings`): a machine guard,
2
- // never a promise in a prompt. The samples beside each rule are the guard's proof (tests/orchestrator-guards.test.ts):
1
+ // what a session started with sk session start may never run without his yes, as Claude Code deny rules (its `--settings`): a machine guard,
2
+ // never a promise in a prompt. The samples beside each rule are the guard's proof (tests/orchestrator.test.ts):
3
3
  // what it refuses, and the lookalikes it lets through. The one constraint a reader breaks first: a prefix rule takes
4
4
  // its words to a word boundary, so `sk release` must never refuse `sk releases add`
5
5
  const RULES: readonly string[] = [
@@ -34,7 +34,16 @@ const RULES: readonly string[] = [
34
34
  'Bash(sk vault:*)',
35
35
  'Bash(sk thread delete:*)',
36
36
  'Bash(sk db drop:*)',
37
- 'Bash(sk orchestrator:*)',
37
+ // being the default (default, leave) and who hears are its own; starting or ending a session is his act
38
+ 'Bash(sk session start:*)',
39
+ 'Bash(sk session stop:*)',
40
+ 'Bash(sk orchestrator on:*)',
41
+ 'Bash(sk orchestrator off:*)',
42
+ // the order of a project's places picks the lead: the owner's pick, never a default session's
43
+ 'Bash(sk session lead:*)',
44
+ 'Bash(sk orchestrator lead:*)',
45
+ // where a project runs is the owner's pick too
46
+ 'Bash(sk place:*)',
38
47
  'Bash(bun run up:*)',
39
48
  'Bash(wrangler:*)',
40
49
  'AskUserQuestion',
@@ -0,0 +1,35 @@
1
+ // what an orchestrator needs of shipkit's own tmux server and of the Claude Code processes on it, as a port: the
2
+ // orchestrator stands below the hub's server in the layers of shipkit's source (the RV041 check), so the server
3
+ // implements it (serve/orchestrator-host.ts, through serve/terminal-host.ts, the one door to tmux) and a surface hands
4
+ // it in. Types only.
5
+ // The one constraint a reader breaks first: no act here types into a pane or starts a program again by itself
6
+ import type { ClaudeStart } from '../serve/terminal-host.ts'
7
+
8
+ /** a terminal opened for an orchestrator: its window, its group (`sk-<repo>`), its pane ended or the pid of its process */
9
+ export type OrchWindow = { window: string; group: string; dead: boolean; pid: number | null; status: string }
10
+
11
+ /** the Claude Code that runs in a window: its process, its full session id, its account (cc3), Claude Code's own
12
+ * busy word, and its transcript */
13
+ export type ClaudeInWindow = { pid: number; session: string; account: string; busy: boolean; transcript: string | null }
14
+
15
+ /** what runs Claude Code as an account with these arguments, or why it cannot */
16
+ export type ClaudeAs = (account: string | undefined, args: readonly string[]) => ClaudeStart | string
17
+
18
+ export type Ran = { ok: true; window: string } | { ok: false; why: string }
19
+
20
+ export interface OrchestratorHost {
21
+ /** the group of a repo's terminals on the server */
22
+ group(repo: string): string
23
+ /** every orchestrator terminal of the server, in one command, each window once; `failed`: tmux did not answer, a
24
+ * doubt; no server running is no terminal */
25
+ windows(): OrchWindow[] | { failed: string }
26
+ /** what a window's pane shows now, its blank lines dropped: a read, never a key */
27
+ capture(window: string): string
28
+ /** the Claude Code whose terminal is that window, among the sessions at work in `root`; null when none is */
29
+ claudeIn(group: string, root: string, window: string): ClaudeInWindow | null
30
+ /** `argv` started in the repo's orchestrator terminal at `root`: its ended one used again, else a new one */
31
+ run(repo: string, root: string, argv: readonly string[], window: string | null): Ran
32
+ /** the repo's orchestrator terminal closed, its program with it; false when none was open */
33
+ close(repo: string): boolean
34
+ claude: ClaudeAs
35
+ }
@@ -0,0 +1,86 @@
1
+ // the lead of a project that runs on several places, as the places and the page say it (wiki
2
+ // tools/shipkit/sessions.md, The lead): the one place whose orchestrator answers the owner's word on a thread
3
+ // nobody holds. The rule is hq/kinds/presence-rule.ts, settled by the hq on its own clock (hq/kinds/presence.ts), so
4
+ // every place reads the same answer. Pure and browser safe: the page draws its places from here.
5
+ // The one constraint a reader breaks first: a place reads the lead, it never settles one
6
+ import { PRESENCE_FRESH_MS, PRESENCE_OLD_MS, SILENT_NAMED_MS, type PlacedPlace, type PlacesView } from './places-shape.ts'
7
+ export { LEAD_GRACE_MS, LEAD_MAX_PLACES, leadOf, type LeadCandidate, type LeadState } from '../hq/kinds/presence-rule.ts'
8
+
9
+ /** a repo's lead as a place reads it from the hq: the owner's order, the node that leads (null: no place leads), and
10
+ * whether the lead holds no role now, so the owner's word waits for it */
11
+ export interface LeadSeen {
12
+ order: string[]
13
+ lead: string | null
14
+ waits: boolean
15
+ /** the places the owner placed the repo on (node ids); absent: every place that has it. With no order of his, it
16
+ * picks the lead */
17
+ placed?: string[]
18
+ }
19
+
20
+ /** one place of a project as the page and the commands say it */
21
+ export interface PlaceLine {
22
+ node: string
23
+ name: string
24
+ here: boolean
25
+ /** its orchestrator hears; holds the role with no ear now; no orchestrator there; the hq has not heard it */
26
+ state: 'hears' | 'held' | 'none' | 'silent'
27
+ /** the name of its role's holder */
28
+ holder: string | null
29
+ /** silent since (ms, this place's clock) */
30
+ since: number | null
31
+ }
32
+
33
+ /** a project on several places: the owner's order, the lead, each place in the order a lead is picked */
34
+ export interface ProjectPlaces {
35
+ order: string[]
36
+ /** the places the owner placed the project on; none: every place that has it */
37
+ placed: PlacedPlace[]
38
+ lead: string | null
39
+ places: PlaceLine[]
40
+ /** this hub sets the owner's order: its machine carries the hq */
41
+ canSet: boolean
42
+ }
43
+
44
+ /** the places of `repo` (this place's name of it) as a fresh view says them, this place with its own facts; null while
45
+ * the view is not fresh, or when no other place holds the repo */
46
+ export function projectPlaces(v: PlacesView | null, repo: string, here: { holder: string | null; hears: boolean }, now: number, canSet: boolean): ProjectPlaces | null {
47
+ if (v === null || !(now - v.at < PRESENCE_FRESH_MS) || now < v.at - PRESENCE_FRESH_MS) return null
48
+ const drift = Math.max(0, now - v.at)
49
+ const rows = v.rows.filter((r) => r.name === repo)
50
+ const others = rows.filter((r) => r.place.node !== v.you && r.age < SILENT_NAMED_MS)
51
+ if (others.length === 0) return null
52
+ const seen = v.leads?.[repo] ?? null
53
+ const order = seen?.order ?? []
54
+ const mine = rows.find((r) => r.place.node === v.you)
55
+ const claimed = new Map(rows.map((r) => [r.place.node, r.facts.holder?.since ?? '']))
56
+ const lines: PlaceLine[] = [
57
+ { node: v.you, name: mine?.place.name ?? 'this machine', here: true, state: here.holder === null ? 'none' : here.hears ? 'hears' : 'held', holder: here.holder, since: null },
58
+ ...others.map((r): PlaceLine => {
59
+ const fresh = r.age + drift < PRESENCE_FRESH_MS && r.old + drift < PRESENCE_OLD_MS
60
+ const h = r.facts.holder
61
+ const state = !fresh ? 'silent' : h === null ? 'none' : h.ear !== null ? 'hears' : 'held'
62
+ return { node: r.place.node, name: r.place.name, here: false, state, holder: fresh ? (h?.name ?? null) : null, since: fresh ? null : v.at - r.age }
63
+ }),
64
+ ]
65
+ // two nodes of one machine (two OS users) are told apart by their user
66
+ const twice = new Set(lines.map((l) => l.name).filter((n, i, all) => all.indexOf(n) !== i))
67
+ const osUser = new Map(rows.map((r) => [r.place.node, r.place.osUser]))
68
+ const rank = (n: string): number => (order.includes(n) ? order.indexOf(n) : order.length)
69
+ const lead = seen?.lead ?? null
70
+ const first = (n: string): string => claimed.get(n) || '~'
71
+ const places = lines
72
+ .sort((a, b) => rank(a.node) - rank(b.node) || Number(b.node === lead) - Number(a.node === lead) || first(a.node).localeCompare(first(b.node)) || a.name.localeCompare(b.name))
73
+ .map((l) => (twice.has(l.name) && osUser.has(l.node) ? { ...l, name: `${l.name}/${osUser.get(l.node)}` } : l))
74
+ return { order, placed: v.placed?.[repo] ?? [], lead, places, canSet }
75
+ }
76
+
77
+ /** the places in a line of words: « laptop leads, tower hears, studio silent since 10:42 »; `clock` says a time */
78
+ export function placesWords(p: ProjectPlaces, clock: (ms: number) => string): string {
79
+ const one = (l: PlaceLine): string => {
80
+ const state = l.state === 'silent' ? `silent since ${l.since === null ? '?' : clock(l.since)}` : l.state === 'hears' ? 'hears' : l.state === 'held' ? 'its default has no ear now' : 'no default session'
81
+ const name = l.here ? `${l.name} (here)` : l.name
82
+ return l.node === p.lead ? `${name} leads${l.state === 'hears' ? '' : `, ${state}`}` : `${name} ${state}`
83
+ }
84
+ const runs = p.placed.length === 0 ? '' : `. Placed on ${p.placed.map((l) => l.name).join(', ')}`
85
+ return `${p.places.map(one).join(', ')}${runs}${p.order.length > 0 ? '. Your order' : p.placed.length > 0 ? '. Its placement' : '. First claim'} picks the lead`
86
+ }
@@ -0,0 +1,88 @@
1
+ // where each project's orchestrator stands, read ON DEMAND when a page or a command asks (wiki
2
+ // tools/shipkit/sessions.md, What he sees): its terminal (the role window), the Claude Code in it, a dialog its
3
+ // pane shows, a usage limit its transcript ends on, its live watch of every thread. Nothing here runs between two asks.
4
+ // The one constraint a reader breaks first: every read is a read: no key, no start, no signal, whatever it finds
5
+ import { closeSync, openSync, readSync, statSync } from 'node:fs'
6
+ import type { Watcher } from '../review/model.ts'
7
+ import type { OrchestratorHost, OrchWindow } from './host.ts'
8
+ import type { HolderView } from './role-shape.ts'
9
+ import { readStarts, type Start } from './started.ts'
10
+ import { dialogOf, limitInTranscript, type OrchState } from './stuck.ts'
11
+
12
+ /** one project as a surface reads it. `hears`: a live watch of every thread runs in it (its orchestrator's, or any
13
+ * session's). `orch`: its orchestrator, null when nobody holds its role and no terminal of that role is open; a
14
+ * holder in a terminal the hub did not start is it, with no window */
15
+ export interface OrchView {
16
+ repo: string
17
+ hears: boolean
18
+ orch: (OrchState & { window: string | null; pid: number | null }) | null
19
+ }
20
+
21
+ /** a watch of every thread of a store: no session, no lane */
22
+ export const bareWatch = (w: Pick<Watcher, 'session' | 'lane'>): boolean => w.session === null && w.lane === null
23
+
24
+ export interface NowSources {
25
+ host: OrchestratorHost | null
26
+ /** the live watches of a repo's store (review/watchers.ts liveWatchers on its store) */
27
+ watchers(root: string): readonly Watcher[]
28
+ /** each project's role holder now, hearing or not (orchestrator/role.ts roleHolders) */
29
+ holders?: () => readonly HolderView[]
30
+ starts?: Record<string, Start>
31
+ /** the last lines of a transcript */
32
+ tail?(path: string): string[]
33
+ }
34
+
35
+ /** the last `bytes` of a file, as its whole lines */
36
+ function tailLines(path: string, bytes = 64_000): string[] {
37
+ try {
38
+ const size = statSync(path).size
39
+ const from = Math.max(0, size - bytes)
40
+ const fd = openSync(path, 'r')
41
+ try {
42
+ const buf = Buffer.alloc(size - from)
43
+ const text = buf.subarray(0, readSync(fd, buf, 0, buf.length, from)).toString('utf8')
44
+ const lines = text.split('\n').filter((l) => l !== '')
45
+ return from > 0 ? lines.slice(1) : lines
46
+ } finally {
47
+ closeSync(fd)
48
+ }
49
+ } catch {
50
+ return []
51
+ }
52
+ }
53
+
54
+ /** the role's holder as its orchestrator, where no live terminal of the hub carries the role */
55
+ const heldOrch = (h: HolderView): NonNullable<OrchView['orch']> => ({ phase: h.busy ? 'working' : h.ear !== null ? 'listening' : 'idle', since: h.since, account: null, holder: { name: h.name, where: h.where }, window: null, pid: h.pid })
56
+
57
+ /** each repo given, as it stands at `now` */
58
+ export function orchestratorsNow(repos: readonly { name: string; path: string }[], src: NowSources, now = Date.now()): OrchView[] {
59
+ const starts = src.starts ?? readStarts()
60
+ const holders = src.holders?.() ?? []
61
+ const ws: OrchWindow[] | { failed: string } = src.host === null ? [] : src.host.windows()
62
+ return repos.map((r): OrchView => {
63
+ const watchers = src.watchers(r.path)
64
+ const holder = holders.find((h) => h.repo === r.name) ?? null
65
+ const hears = holder?.ear != null || watchers.some(bareWatch)
66
+ const held = holder === null ? null : heldOrch(holder)
67
+ const start = starts[r.name] ?? null
68
+ const base = { since: start?.at ?? null, account: start?.account ?? null }
69
+ if ('failed' in ws) return { repo: r.name, hears, orch: held ?? (start === null ? null : { phase: 'unknown', why: ws.failed, ...base, window: null, pid: null }) }
70
+ const w = src.host === null ? undefined : ws.find((x) => x.group === src.host!.group(r.name))
71
+ if (w === undefined) return { repo: r.name, hears, orch: held ?? (start === null ? null : { phase: 'ended', ...base, since: null, window: null, pid: null }) }
72
+ if (w.dead) return { repo: r.name, hears, orch: held ?? { phase: 'ended', ended: w.status, ...base, since: null, window: w.window, pid: null } }
73
+ const host = src.host!
74
+ const at = { window: w.window, pid: w.pid }
75
+ const dialog = dialogOf(host.capture(w.window), new Date(now))
76
+ const c = host.claudeIn(w.group, r.path, w.window)
77
+ const account = c?.account ?? base.account
78
+ if (dialog !== null) return { repo: r.name, hears, orch: { phase: 'stuck', stuck: { kind: dialog.kind, ...(dialog.until ? { until: dialog.until } : {}) }, ...base, account, ...at, pid: c?.pid ?? w.pid } }
79
+ if (c === null) return { repo: r.name, hears, orch: { phase: 'starting', ...base, ...at } }
80
+ const limit = c.transcript === null ? null : limitInTranscript((src.tail ?? tailLines)(c.transcript), now)
81
+ if (limit !== null) return { repo: r.name, hears, orch: { phase: 'stuck', stuck: { kind: limit.kind, ...(limit.until ? { until: limit.until } : {}) }, ...base, account, ...at, pid: c.pid } }
82
+ // it hears as the role's holder (its channel or its watch), or by a watch of every thread of its own
83
+ const own = watchers.find((x) => bareWatch(x) && x.by === c.session)
84
+ const listens = (holder?.ear != null && holder.session === c.session) || own !== undefined
85
+ const phase = c.busy ? 'working' : listens ? 'listening' : 'idle'
86
+ return { repo: r.name, hears, orch: { phase, ...base, ...(own ? { since: own.started } : {}), account, ...at, pid: c.pid } }
87
+ })
88
+ }
@@ -84,6 +84,9 @@ export async function pushPhone(root: string, repo: string, now = Date.now()): P
84
84
  if (plan.push.length === 0) return 0
85
85
  const scan = { advisorEmail: '', words: privateWords(houseRoot(root)) }
86
86
  const clean = (t: string): string => redact(t, scanText(t, scan))
87
+ // the push lands on a public server: a foreign repo's thread words never ride it, only that a thread waits (core/foreign.ts)
88
+ const { isForeign } = await import('../core/foreign.ts')
89
+ const words = isForeign(root) ? (): string => 'a thread waits on you' : (p: { title: string; line: string }): string => `${clean(p.title)}\n${clean(p.line)}`
87
90
  let sent = 0
88
91
  for (const p of plan.push) {
89
92
  // another hub of this Mac may run the same pass: the keys say who pushes
@@ -91,7 +94,7 @@ export async function pushPhone(root: string, repo: string, now = Date.now()): P
91
94
  last[`${repo}/${p.thread}`] = new Date(now).toISOString()
92
95
  const path = p.thread.startsWith('proposal:') || p.thread.startsWith('advice:') ? `/r/${encodeURIComponent(repo)}/` : `/r/${encodeURIComponent(repo)}/#page:review:${p.thread}`
93
96
  const url = await phoneUrl(path)
94
- if (await pushNow(`${repo}: ${clean(p.title)}\n${clean(p.line)}${url ? `\n${url}` : ''}`).catch(() => false)) sent++
97
+ if (await pushNow(`${repo}: ${words(p)}${url ? `\n${url}` : ''}`).catch(() => false)) sent++
95
98
  }
96
99
  writeLast(last, now)
97
100
  return sent
@@ -0,0 +1,38 @@
1
+ // the view file of places on disk (wiki tools/shipkit/sessions.md, Places and Placement): where it is, its read,
2
+ // and the placement pm reads from it. The readers of hearing are places.ts; the pure rules places-shape.ts.
3
+ // The one constraint a reader breaks first: pm imports this module, so it imports nothing of the stores or the
4
+ // review: a change there must never restart pm (tests/home-lib-watch.test.ts)
5
+ import { readFileSync, statSync } from 'node:fs'
6
+ import { join } from 'node:path'
7
+ import { placedElsewhere, type PlacedPlace, type PlacesView } from './places-shape.ts'
8
+ import { orchestratorsDir } from './started.ts'
9
+
10
+ export const placesFile = (): string => join(orchestratorsDir(), 'places.json')
11
+
12
+ /** the view the daemon wrote last, null when none reads */
13
+ export function readPlaces(file: string = placesFile()): PlacesView | null {
14
+ try {
15
+ const v = JSON.parse(readFileSync(file, 'utf8')) as PlacesView
16
+ return typeof v.at === 'number' && typeof v.you === 'string' && Array.isArray(v.rows) ? v : null
17
+ } catch {
18
+ return null
19
+ }
20
+ }
21
+
22
+ let seen: { file: string; stamp: string; v: PlacesView | null } | null = null
23
+
24
+ /** the places `repo` is placed on when this place is not one of them, null when it runs here (wiki
25
+ * tools/shipkit/sessions.md, Placement). What pm reads at its start and in each answer: the view as the last look
26
+ * that reached the hq wrote it, whatever its age, so an hq not reached keeps the last placement, never « everywhere ».
27
+ * Read again only when the file moved (a stat, a few µs) */
28
+ export function placedOn(repo: string, file: string = placesFile()): PlacedPlace[] | null {
29
+ let stamp = ''
30
+ try {
31
+ const st = statSync(file)
32
+ stamp = `${st.mtimeMs}:${st.size}`
33
+ } catch {
34
+ // no view yet: no placement read, every process starts as before placement
35
+ }
36
+ if (seen === null || seen.file !== file || seen.stamp !== stamp) seen = { file, stamp, v: stamp === '' ? null : readPlaces(file) }
37
+ return placedElsewhere(seen.v, repo)
38
+ }
@@ -0,0 +1,180 @@
1
+ // the daemon's look of places (wiki tools/shipkit/sessions.md, Places): this place's facts of each repo it holds,
2
+ // sent to the hq as the kind `presence` when they change, then every place's facts read back into the view file
3
+ // (places.ts). The pure rules are places-shape.ts.
4
+ // The one constraint a reader breaks first: the look runs in the daemon's process, beside the 3 s due of the job `hq
5
+ // threads` (home/daemon-jobs.ts), so it reads files and probes pids only, never walks, and gives up on the hq after 2 s
6
+ import { atomicWriteJson } from '../core/atomic-write.ts'
7
+ import type { HeldRepo } from '../hq/thread-sync.ts'
8
+ import type { ReadLink } from '../hq/hq-routes.ts'
9
+ import type { HqLink, Outbox } from '../hq/outbox.ts'
10
+ import type { Refused } from '../hq/hq-store.ts'
11
+ import type { HolderView } from './role-shape.ts'
12
+ import type { Watcher } from '../review/model.ts'
13
+ import { PRESENCE_RESEND_MS, type PlacesView, type PresenceFacts, type PresenceRow } from './places-shape.ts'
14
+ import { placesFile, readPlaces } from './places-file.ts'
15
+ import type { LiveSession } from './sessions-shape.ts'
16
+
17
+ /** the facts a place sends of a session: never its pid or its folder */
18
+ const sessionFacts = (s: LiveSession): LiveSession => ({ session: s.session, name: s.name, busy: s.busy, ear: s.ear })
19
+
20
+ /** this place's facts of one repo: its role holder (role.ts roleHolders, by the repo's folder name) and the live
21
+ * watches of its store; never a pid */
22
+ export function factsOf(repo: HeldRepo, holder: HolderView | null, watches: readonly Watcher[], sessions: readonly LiveSession[] = []): PresenceFacts {
23
+ return {
24
+ repo: repo.id,
25
+ holder: holder === null ? null : { session: holder.session, name: holder.name, where: holder.where, since: holder.since, ear: holder.ear, busy: holder.busy },
26
+ watches: watches.map((w) => ({ session: w.session, lane: w.lane, by: w.by ?? null, house: w.house === true, started: w.started })),
27
+ // the head line's chips on the other places: those that listen or work, at most what the hq takes
28
+ sessions: sessions.filter((s) => s.ear !== null || s.busy).slice(0, 64).map(sessionFacts),
29
+ }
30
+ }
31
+
32
+ /** what the look remembers of each repo it put in the outbox: its facts, and when; and whether rows of it wait there */
33
+ export interface Sent {
34
+ get(repo: string): { facts: string; at: number } | null
35
+ set(repo: string, v: { facts: string; at: number }): void
36
+ waits(): boolean
37
+ setWaits(v: boolean): void
38
+ }
39
+
40
+ /** one look: each repo whose facts changed (or were sent PRESENCE_RESEND_MS ago) goes to the hq through the outbox
41
+ * `presence`, where it replaces the row of that repo still waiting: the outbox is durable, so a row once in it counts
42
+ * as sent, and an hq that is down for hours finds one row a repo. Then every row of the repos this place holds is read
43
+ * back and written as the view, each under this place's name of its repo; that read is what tells the other places
44
+ * this one looks. The hq not reached: nothing is written, and the view goes stale by itself */
45
+ export async function presenceLook(o: { link: HqLink & ReadLink; outbox: () => Outbox | null; repos: readonly HeldRepo[]; facts: readonly PresenceFacts[]; sent: Sent; now: number; file?: string }): Promise<{ sent: number; rows: number } | Refused> {
46
+ const due = o.facts.filter((f) => {
47
+ const was = o.sent.get(f.repo)
48
+ return was === null || was.facts !== JSON.stringify(f) || o.now - was.at >= PRESENCE_RESEND_MS
49
+ })
50
+ // what waits goes first, from this look or an earlier one: the view is read only once the hq holds this place's
51
+ // facts. The outbox is opened only while something of it waits
52
+ if (due.length > 0 || o.sent.waits()) {
53
+ const box = o.outbox()
54
+ if (box === null) return { refused: "the daemon's own database does not open: no presence is sent" }
55
+ for (const f of due) {
56
+ box.dropWaiting('presence', 'repo', f.repo)
57
+ box.push('presence', f, o.now)
58
+ o.sent.set(f.repo, { facts: JSON.stringify(f), at: o.now })
59
+ }
60
+ o.sent.setWaits(true)
61
+ const { flush } = await import('../hq/outbox.ts')
62
+ const f = await flush(box, o.link, o.now)
63
+ if ('refused' in f) return f
64
+ o.sent.setWaits(box.waiting() > 0)
65
+ }
66
+ const names = new Map(o.repos.map((r) => [r.id, r.name]))
67
+ const rows: PlacesView['rows'] = []
68
+ let you: string | null = null
69
+ const leads: NonNullable<PlacesView['leads']> = {}
70
+ const placed: NonNullable<PlacesView['placed']> = {}
71
+ let saidPlaced = false
72
+ let after = ''
73
+ for (let i = 0; i < 10; i++) {
74
+ const page = await o.link.read('presence', after === '' ? {} : { after })
75
+ if ('refused' in page) return page
76
+ you ??= page.you ?? null
77
+ for (const [id, l] of Object.entries(page.leads ?? {})) {
78
+ const name = names.get(id)
79
+ if (name !== undefined) leads[name] = l
80
+ }
81
+ if (page.placed !== undefined) saidPlaced = true
82
+ for (const [id, p] of Object.entries(page.placed ?? {})) {
83
+ const name = names.get(id)
84
+ if (name !== undefined) placed[name] = p
85
+ }
86
+ for (const r of page.rows as PresenceRow[]) {
87
+ const name = names.get(r.facts.repo)
88
+ if (name !== undefined) rows.push({ ...r, name })
89
+ }
90
+ if (page.next === null) break
91
+ after = page.next
92
+ }
93
+ if (you === null) return { refused: 'the hq names no node for this daemon in its presence answer: update the hq' }
94
+ // an hq of before placement says none: the last placement this place read stays until an hq says one
95
+ const kept = saidPlaced ? placed : (readPlaces(o.file)?.placed ?? {})
96
+ atomicWriteJson(o.file ?? placesFile(), { at: o.now, you, rows, leads, placed: kept } satisfies PlacesView)
97
+ return { sent: due.length, rows: rows.length }
98
+ }
99
+
100
+ /** the facts of every repo the threads job last held, read now: `name` the repo's folder name, as the role is keyed */
101
+ export async function factsHere(repos: readonly HeldRepo[], now: number): Promise<PresenceFacts[]> {
102
+ const { roleHolders } = await import('./role.ts')
103
+ const { liveWatchers } = await import('../review/watchers.ts')
104
+ const { storeDir } = await import('../review/store.ts')
105
+ const { liveSessions } = await import('./sessions.ts')
106
+ const holders = roleHolders(now)
107
+ const sessions = liveSessions(repos)
108
+ return repos.map((r) => factsOf(r, holders.find((h) => h.repo === r.name) ?? null, liveWatchers(storeDir(r.path)), sessions.get(r.name) ?? []))
109
+ }
110
+
111
+ const SENT = 'hq-presence-sent:'
112
+ const WAITS = 'hq-presence-waits'
113
+ let looking = false
114
+
115
+ /** what a look ended on, said once a reason: a refusal is one WARN and the machine db row PLACES_REFUSED (places.ts
116
+ * placesRefusal, for `sk orchestrator`); the first look that works again says so once and clears it */
117
+ export async function sayLook(r: { sent: number; rows: number } | Refused, now: number, printErr: (l: string) => void, print: (l: string) => void): Promise<void> {
118
+ const { machineDelete, machineGet, machineSet } = await import('../core/machine-db.ts')
119
+ const { PLACES_REFUSED } = await import('./places.ts')
120
+ const was = machineGet<{ why: string; at: number }>(PLACES_REFUSED)
121
+ if (!('refused' in r)) {
122
+ if (was == null) return
123
+ machineDelete(PLACES_REFUSED)
124
+ return print(`ok: places: the look reaches the hq again (it did not since ${new Date(was.at).toISOString()}: ${was.why})`)
125
+ }
126
+ if (was?.why === r.refused) return
127
+ machineSet(PLACES_REFUSED, { why: r.refused, at: now })
128
+ printErr(`WARN places: ${r.refused}: the other places stop counting this one in 15 s, and this one hears with its own facts alone`)
129
+ }
130
+
131
+ /** the look in the daemon's process: one at a time (the next waits for this one, even past its give up), 2 s at most,
132
+ * never a throw; what it ended on is said (sayLook). The caller runs it only while the threads go to the hq
133
+ * (hq/switch.ts threadsOn) */
134
+ export async function presenceLookHere(now: number, printErr: (l: string) => void = (l) => console.error(l), print: (l: string) => void = (l) => console.log(l)): Promise<void> {
135
+ if (looking) return
136
+ looking = true
137
+ let started = false
138
+ const failed = (e: unknown): Refused => ({ refused: `the look failed: ${(e as Error)?.message ?? String(e)}` })
139
+ try {
140
+ const { machineGet, machineSet } = await import('../core/machine-db.ts')
141
+ const { HELD_REPOS } = await import('../hq/thread-sync.ts')
142
+ const { repoNameOf } = await import('../agent-time/registry.ts')
143
+ // each repo under the name every reader of this place gives it: its folder's (registry.ts repoNameOf)
144
+ const repos = (machineGet<HeldRepo[]>(HELD_REPOS) ?? []).map((r) => ({ ...r, name: repoNameOf(r.path) }))
145
+ const { myHq } = await import('../hq/hq-local.ts')
146
+ const link = myHq()
147
+ if ('refused' in link) return await sayLook(link, now, printErr, print)
148
+ const facts = await factsHere(repos, now)
149
+ const { openDaemonDb, Outbox } = await import('../hq/outbox.ts')
150
+ let db: ReturnType<typeof openDaemonDb> = null
151
+ const look = presenceLook({
152
+ link,
153
+ repos,
154
+ facts,
155
+ now,
156
+ outbox: () => ((db ??= openDaemonDb()) === null ? null : new Outbox(db, 'presence')),
157
+ sent: {
158
+ get: (r) => machineGet<{ facts: string; at: number }>(`${SENT}${r}`) ?? null,
159
+ set: (r, v) => machineSet(`${SENT}${r}`, v),
160
+ waits: () => machineGet<boolean>(WAITS) === true,
161
+ setWaits: (v) => machineSet(WAITS, v),
162
+ },
163
+ })
164
+ started = true
165
+ const settled = look
166
+ .catch(failed)
167
+ .then((r) => sayLook(r, now, printErr, print))
168
+ .catch(() => {})
169
+ .finally(() => {
170
+ ;(db as { close(): void } | null)?.close()
171
+ looking = false
172
+ })
173
+ let timer: ReturnType<typeof setTimeout> | undefined
174
+ await Promise.race([settled, new Promise((r) => (timer = setTimeout(r, 2000)))]).finally(() => clearTimeout(timer))
175
+ } catch (e) {
176
+ await sayLook(failed(e), now, printErr, print).catch(() => {})
177
+ } finally {
178
+ if (!started) looking = false
179
+ }
180
+ }
@@ -0,0 +1,151 @@
1
+ // the project's other places, as this place hears them (wiki tools/shipkit/sessions.md, Places): each place's
2
+ // daemon reads its own facts (its role holders, its live watches) and sends them to the hq as the kind `presence`; each
3
+ // daemon reads back the others' and keeps them in one view file. Pure and browser safe: places.ts is the disk side,
4
+ // hq/kinds/presence.ts the hq's.
5
+ // The one constraint a reader breaks first: a fact of another place counts only while the hq heard its node in the last
6
+ // PRESENCE_FRESH_MS, and only while this place's own view of the hq is that fresh: past it, every reader hears with this
7
+ // place's own facts alone, as before places
8
+ import type { LaneParty, Parties, SessionParty } from '../review/parties.ts'
9
+ import type { Watcher } from '../review/model.ts'
10
+ import type { LeadSeen } from './lead-shape.ts'
11
+ import type { LiveSession } from './sessions-shape.ts'
12
+
13
+ import { PRESENCE_FRESH_MS, PRESENCE_OLD_MS } from '../hq/kinds/presence-rule.ts'
14
+ // the times live with the lead rule, low enough for the hq that settles a lead to read them
15
+ export { PRESENCE_FRESH_MS, PRESENCE_OLD_MS, PRESENCE_RESEND_MS } from '../hq/kinds/presence-rule.ts'
16
+
17
+ /** what a place is: one node of the hq (a machine and its OS user, a VM, a container on `host`, the node of its machine) */
18
+ export type PlaceKind = 'machine' | 'vm' | 'container'
19
+ export interface Place {
20
+ node: string
21
+ /** its machine's name, as the hq holds it */
22
+ name: string
23
+ osUser: string
24
+ kind: PlaceKind
25
+ host: string | null
26
+ }
27
+
28
+ /** the facts one place's daemon read of one repo it holds: never a pid, a prompt or a transcript */
29
+ export interface PresenceFacts {
30
+ /** the repo's key (host and path of its remote) */
31
+ repo: string
32
+ /** the holder of the repo's role there, as role.ts roleHolders reads it; null while nobody holds it */
33
+ holder: { session: string; name: string; where: string; since: string; ear: 'watch' | 'channel' | null; busy: boolean } | null
34
+ /** the live watches of the repo's store there (review/watchers.ts liveWatchers) */
35
+ watches: { session: string | null; lane: string | null; by: string | null; house: boolean; started: string }[]
36
+ /** the live top level sessions of the repo there (sessions.ts), the head line's chips; absent from a place of
37
+ * before sessions */
38
+ sessions?: LiveSession[]
39
+ }
40
+
41
+ /** one row as the hq answers it: its node's place, its ages by the hq's clock, the hq machine's own rows marked */
42
+ export interface PresenceRow {
43
+ place: Place
44
+ /** ms since the node's last look (its last read of presence), and since the row landed, by the hq's clock */
45
+ age: number
46
+ old: number
47
+ /** when the hq first saw the holder's session hold the role (ms, the hq's clock), null with no holder: the claim
48
+ * the lead is read from, never the node's own `since` */
49
+ claimed: number | null
50
+ /** a node of the machine that carries the hq: it alone sends the push of a word nobody heard (unheard.ts) */
51
+ hq: boolean
52
+ facts: PresenceFacts
53
+ }
54
+
55
+ /** the view file: what the hq answered at `at` (this place's clock), each row under this place's name of its repo */
56
+ export interface PlacesView {
57
+ at: number
58
+ /** this place's own node */
59
+ you: string
60
+ rows: (PresenceRow & { name: string })[]
61
+ /** each repo's lead as the hq settled it (lead-shape.ts), under this place's name of the repo; absent from an hq
62
+ * of before the lead */
63
+ leads?: Record<string, LeadSeen>
64
+ /** where the owner placed each repo (wiki tools/shipkit/sessions.md, Placement), under this place's name of
65
+ * it; a repo absent runs on every place that has it. Absent from an hq of before placement. Read by pm at its
66
+ * next start whatever the view's age: the last placement the hq said holds while it is not reached */
67
+ placed?: Record<string, PlacedPlace[]>
68
+ }
69
+
70
+ /** a place a repo is placed on: its node and its machine's name (`<machine>/<os user>` on a machine of two nodes) */
71
+ export interface PlacedPlace {
72
+ node: string
73
+ name: string
74
+ }
75
+
76
+ /** the places `repo` (this place's name of it) is placed on when this place is not one of them; null when it runs
77
+ * here: no placement, or one that names this place. The view's age does not count (see PlacesView.placed) */
78
+ export function placedElsewhere(v: PlacesView | null, repo: string): PlacedPlace[] | null {
79
+ const p = v?.placed?.[repo]
80
+ if (v == null || p == null || p.length === 0 || p.some((x) => x.node === v.you)) return null
81
+ return p
82
+ }
83
+
84
+ /** the rows of other places that count now; null while the view is not fresh (the hq not reached): hear locally */
85
+ export function freshRows(v: PlacesView | null, now: number): PlacesView['rows'] | null {
86
+ if (v === null || !(now - v.at < PRESENCE_FRESH_MS) || now < v.at - PRESENCE_FRESH_MS) return null
87
+ const drift = Math.max(0, now - v.at)
88
+ return v.rows.filter((r) => r.place.node !== v.you && r.age + drift < PRESENCE_FRESH_MS && r.old + drift < PRESENCE_OLD_MS)
89
+ }
90
+
91
+ /** a place silent this long is no place of the project's now: it is not named */
92
+ export const SILENT_NAMED_MS = 24 * 3600_000
93
+
94
+ /** the places of a fresh view that stopped calling the hq, and since when (this place's clock): « <place> silent since
95
+ * 10:42 » */
96
+ export function silentPlaces(v: PlacesView | null, now: number): { place: Place; since: number }[] {
97
+ if (v === null || freshRows(v, now) === null) return []
98
+ const drift = Math.max(0, now - v.at)
99
+ const out = new Map<string, { place: Place; since: number }>()
100
+ for (const r of v.rows) if (r.place.node !== v.you && r.age + drift >= PRESENCE_FRESH_MS && r.age < SILENT_NAMED_MS) out.set(r.place.node, { place: r.place, since: v.at - r.age })
101
+ return [...out.values()]
102
+ }
103
+
104
+ /** a row's holder claim as the hq stamped it (ISO), null when it holds none */
105
+ export const claimOf = (r: Pick<PresenceRow, 'claimed'>): string | null => (r.claimed === null ? null : new Date(r.claimed).toISOString())
106
+
107
+ /** this place's own holders' claims as the hq stamped them, by session: what this place sorts its own orchestrator on,
108
+ * so every place sorts on the same times (role.ts hearingHolders) */
109
+ export function ownClaims(v: PlacesView | null): Map<string, string> {
110
+ const out = new Map<string, string>()
111
+ for (const r of v?.rows ?? []) {
112
+ const c = claimOf(r)
113
+ if (r.place.node === v?.you && r.facts.holder !== null && c !== null) out.set(r.facts.holder.session, c)
114
+ }
115
+ return out
116
+ }
117
+
118
+ /** the sessions and lanes the rows say live, each under its place: the holder that hears is its repo's orchestrator */
119
+ export function partiesOfRows(rows: readonly (PresenceRow & { name: string })[]): Parties {
120
+ const sessions = new Map<string, SessionParty>()
121
+ const lanes: LaneParty[] = []
122
+ for (const r of rows) {
123
+ const place = r.place.node
124
+ const h = r.facts.holder
125
+ if (h !== null && h.ear !== null) sessions.set(h.session, { id: h.session, repo: r.name, live: true, watch: true, orchestrator: 'own', since: claimOf(r) ?? h.since, place })
126
+ for (const w of r.facts.watches) {
127
+ const session = w.by ?? w.session
128
+ if (session === null) continue
129
+ if (w.lane !== null) {
130
+ if (!lanes.some((l) => l.name === w.lane && l.session === session)) lanes.push({ name: w.lane, session, live: true, watch: true })
131
+ if (!sessions.has(session)) sessions.set(session, { id: session, repo: r.name, live: true, watch: false, place })
132
+ } else if (sessions.get(session)?.orchestrator === undefined) sessions.set(session, { id: session, repo: r.name, live: true, watch: true, place })
133
+ }
134
+ }
135
+ return { sessions: [...sessions.values()], lanes }
136
+ }
137
+
138
+ /** what a fresh view says of each repo's lead, this place's node and each place's name, for parties.ts to name a lead
139
+ * and a place by; nothing while the view is not fresh: each place then leads by its own facts */
140
+ export function leadFacts(v: PlacesView | null, now: number): Pick<Parties, 'leads' | 'here' | 'placeNames'> {
141
+ if (v === null || freshRows(v, now) === null) return {}
142
+ const placeNames: Record<string, string> = {}
143
+ for (const r of v.rows) placeNames[r.place.node] = r.place.name
144
+ const leads: Record<string, string | null> = {}
145
+ for (const [repo, l] of Object.entries(v.leads ?? {})) leads[repo] = l.lead
146
+ return { leads, here: v.you, placeNames }
147
+ }
148
+
149
+ /** the live watches other places say run on `repo` (this place's name of it), as a watcher list reads them: no pid */
150
+ export const watchersOfRows = (rows: readonly (PresenceRow & { name: string })[], repo: string): Watcher[] =>
151
+ rows.flatMap((r) => (r.name !== repo ? [] : r.facts.watches.map((w): Watcher => ({ pid: 0, session: w.session, lane: w.lane, started: w.started, ...(w.by !== null ? { by: w.by } : {}), ...(w.house ? { house: true as const } : {}) }))))