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,83 +1,33 @@
1
1
  // the shared-file gate: a commit must not take another writer's hunks. A pathspec commit takes the whole file, so a
2
2
  // file two agents wrote since its last commit holds the other one's unfinished work (preferences/how-we-commit).
3
- // The edit guard notes every Edit and Write of an agent, one line, keyed by session and subagent (Claude Code hands a
4
- // hook `agent_id` inside a lane); the gate reads those lines and refuses a staged file two writers or more touched since
5
- // its last commit. Writes that are no tool call (an `sk` repair, a script) are never noted, so they never block.
6
- // the one constraint a reader breaks first: the edit guard runs on EVERY edit, so noting stays one append, no git
7
- import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, rmSync } from 'fs'
3
+ // It reads the write log (write-log.ts): every Edit and Write of an agent, and every file a Bash call of an agent
4
+ // named and left changed (shell-writes.ts), keyed by session and subagent. It refuses a staged file two writers or
5
+ // more wrote since its last commit, and one whose writers do not include the committer: the agent whose Bash call runs
6
+ // the commit, which the guard held (shell-writes.ts `commitFolders`). A write no call names (an `sk` repair, a
7
+ // script's own output) is never noted.
8
+ // the one constraint a reader breaks first: an ordinary commit (each staged file noted by its committer alone) runs
9
+ // no git here, only a contested file asks its date and its blobs
10
+ import { readFileSync, realpathSync, statSync } from 'fs'
8
11
  import { homedir } from 'os'
9
12
  import { basename, dirname, join } from 'path'
13
+ import { sessionRecords } from '../agent-time/claude-sessions.ts'
10
14
  import { laneNameOf } from '../agent-time/lane-name.ts'
11
15
  import { gitBin } from '../core/git-bin.ts'
12
16
  import { EDIT_MATCHER, hasEditGuard } from './edit-guard.ts'
17
+ import { heldNow, markJudged, type Committing } from './shell-writes.ts'
13
18
  import type { Staged } from './staged.ts'
19
+ import { readWrites, seenOf, writerKey, type Write, type Writer } from './write-log.ts'
14
20
 
15
21
  /** the joint commit two lanes agreed on: the other writers, by the names the refusal prints */
16
22
  export const COMMIT_WITH = 'SHIPKIT_COMMIT_WITH'
17
23
 
18
- const DAY_MS = 86_400_000
19
- /** a lane holding hunks longer than this is no longer seen */
20
- const READ_DAYS = 3
21
- const KEEP_DAYS = 7
22
-
23
- export const writesDir = (): string => process.env['SHIPKIT_WRITES_DIR'] ?? join(homedir(), '.shipkit', 'writes')
24
-
25
- /** one noted write: when, the file, the session, its lane (absent on a main thread), the session's transcript */
26
- export type Write = { t: number; f: string; s: string; a?: string; tp?: string }
27
-
28
- type HookIn = { session_id?: unknown; agent_id?: unknown; transcript_path?: unknown }
29
-
30
24
  function repoHasEditGuard(root: string): boolean {
31
25
  try { return hasEditGuard(JSON.parse(readFileSync(join(root, '.claude', 'settings.json'), 'utf8')) as Parameters<typeof hasEditGuard>[0]) } catch { return false }
32
26
  }
33
27
 
34
- /** the session of the made up hook input `sk` probes a hook's cost with (agent-time/hooks.ts): its edit is no write */
35
- export const HOOK_PROBE_SESSION = 'shipkit-hook-probe'
36
-
37
- /** the write an edit is about to make, or null when nothing names its writer */
38
- export function writeOf(ev: HookIn, file: string, now = Date.now()): Write | null {
39
- if (typeof ev.session_id !== 'string' || ev.session_id === '' || ev.session_id === HOOK_PROBE_SESSION || file === '') return null
40
- const w: Write = { t: now, f: file, s: ev.session_id }
41
- if (typeof ev.agent_id === 'string' && ev.agent_id !== '') w.a = ev.agent_id
42
- if (typeof ev.transcript_path === 'string' && ev.transcript_path !== '') w.tp = ev.transcript_path
43
- return w
44
- }
45
-
46
- const bucket = (t: number): string => join(writesDir(), `${Math.floor(t / DAY_MS)}.jsonl`)
47
-
48
- /** one append, never a failure of the edit it notes */
49
- export function noteWrite(w: Write): void {
50
- try {
51
- const file = bucket(w.t)
52
- if (!existsSync(dirname(file))) mkdirSync(dirname(file), { recursive: true })
53
- appendFileSync(file, `${JSON.stringify(w)}\n`)
54
- } catch { /* a write the gate never sees only loosens it */ }
55
- }
56
-
57
- /** the writes of the last READ_DAYS days; the days past KEEP_DAYS go */
58
- export function readWrites(now = Date.now()): Write[] {
59
- const today = Math.floor(now / DAY_MS)
60
- const out: Write[] = []
61
- let names: string[] = []
62
- try { names = readdirSync(writesDir()) } catch { return out }
63
- for (const n of names) {
64
- const day = Number(/^(\d+)\.jsonl$/.exec(n)?.[1] ?? NaN)
65
- if (!Number.isFinite(day)) continue
66
- if (day < today - KEEP_DAYS) { try { rmSync(join(writesDir(), n)) } catch { /* the next commit retries */ } continue }
67
- if (day < today - READ_DAYS + 1) continue
68
- for (const line of readFileSync(join(writesDir(), n), 'utf8').split('\n')) {
69
- if (line === '') continue
70
- try { out.push(JSON.parse(line) as Write) } catch { /* a torn line is one write lost */ }
71
- }
72
- }
73
- return out
74
- }
75
-
76
- export const writerKey = (w: Write): string => (w.a == null ? w.s : `${w.s}/${w.a}`)
77
-
78
28
  /** a writer's name: its lane's name from the description its session gave it, else a short id. A lane's description
79
29
  * sits beside the session's transcript, `<session>/subagents/agent-<id>.meta.json` */
80
- export function writerName(w: Write): string {
30
+ export function writerName(w: Writer): string {
81
31
  if (w.a == null) return `session-${w.s.slice(0, 8)}`
82
32
  try {
83
33
  const meta = JSON.parse(readFileSync(join(w.tp?.replace(/\.jsonl$/, '') ?? '', 'subagents', `agent-${w.a}.meta.json`), 'utf8')) as { description?: string }
@@ -87,6 +37,41 @@ export function writerName(w: Write): string {
87
37
  return `agent-${w.a.slice(0, 8)}`
88
38
  }
89
39
 
40
+ const pidLives = (pid: number): boolean => {
41
+ try {
42
+ process.kill(pid, 0)
43
+ return true
44
+ } catch (e) { return (e as NodeJS.ErrnoException).code === 'EPERM' }
45
+ }
46
+
47
+ /** what Claude Code's own record of its processes says of a writer (`<config>/sessions/<pid>.json`, the config folder
48
+ * the writer's transcript sits in):
49
+ * - `gone`: the Claude Code process that ran it ended. No live process runs its session, or one does and the lane
50
+ * wrote nothing (no line of its transcript, no note) since that process began, so it ran in an earlier process of
51
+ * a session started again;
52
+ * - `live`: a live process runs its session, and the lane wrote since it began. Never from how long a lane has been
53
+ * silent: a lane inside a five minute test is live;
54
+ * - `unknown`: the config folder holds no record at all, so nothing says live or gone, and nothing is guessed.
55
+ * `heard`: when the writer was last heard, the newest of its transcript's last line and its notes; 0 when neither */
56
+ export type WriterState = { state: 'live' | 'gone' | 'unknown'; heard: number }
57
+ export function writerState(w: Writer, lastNote = 0): WriterState {
58
+ const config = w.tp != null ? dirname(dirname(dirname(w.tp))) : (process.env['CLAUDE_CONFIG_DIR'] ?? join(homedir(), '.claude'))
59
+ const transcript = w.tp == null ? null : w.a == null ? w.tp : join(w.tp.replace(/\.jsonl$/, ''), 'subagents', `agent-${w.a}.jsonl`)
60
+ let heard = lastNote
61
+ try { if (transcript != null) heard = Math.max(heard, statSync(transcript).mtimeMs) } catch { /* no transcript: its notes date it */ }
62
+ const records = sessionRecords(config)
63
+ if (records.length === 0) return { state: 'unknown', heard }
64
+ const live = records.filter((r) => r.sessionId === w.s && pidLives(r.pid))
65
+ if (live.length === 0) return { state: 'gone', heard }
66
+ if (w.a == null) return { state: 'live', heard }
67
+ const began = Math.max(...live.map((r) => r.startedAt))
68
+ return { state: began > 0 && heard > 0 && heard < began ? 'gone' : 'live', heard }
69
+ }
70
+
71
+ const two = (n: number): string => String(n).padStart(2, '0')
72
+ /** a moment as a refusal prints it, in the machine's own time: `11-24 22:41` */
73
+ export const heardAt = (ms: number): string => { const d = new Date(ms); return `${two(d.getMonth() + 1)}-${two(d.getDate())} ${two(d.getHours())}:${two(d.getMinutes())}` }
74
+
90
75
  /** a path with its folder resolved (`/tmp` → `/private/tmp`), one realpath a folder; a folder gone keeps the path */
91
76
  function realPaths(): (p: string) => string {
92
77
  const dirs = new Map<string, string>()
@@ -101,23 +86,94 @@ function realPaths(): (p: string) => string {
101
86
  }
102
87
  }
103
88
 
104
- /** a staged file and every writer of it since its last commit, by name */
89
+ /** a staged file and every writer of it since its last commit, by name; a writer that is gone says so after its name,
90
+ * with when it was last heard, `L236 (gone, last heard 11-24 22:41, agent a1b2c3d4)`, so two agents under one lane
91
+ * name read as two */
105
92
  export type SharedFile = { path: string; writers: string[] }
106
93
  export type SharedOutcome =
107
94
  | { status: 'skipped'; reason: string }
108
95
  | { status: 'clean'; joint: SharedFile[] }
109
96
  | { status: 'shared'; files: SharedFile[] }
110
97
 
111
- /** the decision. `lastCommitMs` is asked only for a file two writers touched, so an ordinary commit runs no git */
112
98
  const OUTSIDE: SharedOutcome = { status: 'skipped', reason: 'a commit from outside Claude Code' }
113
99
  /** a commit from the owner's terminal is never judged: only an agent's shell carries CLAUDECODE */
114
100
  const fromAgent = (env: Record<string, string | undefined>): boolean => env['CLAUDECODE'] === '1'
115
101
 
116
- /** a staged file two writers or more touched in the window, with its writes */
102
+ /** a staged file the gate must look at, with its writes: two writers or more noted it, or none of those that did may
103
+ * be the committer */
117
104
  type Contested = { path: string; ws: Write[] }
118
105
 
119
- function contested(root: string, staged: Staged, writes: readonly Write[]): Contested[] {
120
- const real = realPaths()
106
+ /** the files of one commit whose single noted writers are asked of git, the newest note first: one process each */
107
+ const MAX_FOREIGN = 16
108
+
109
+ /** may this writer be the one that commits */
110
+ type MayCommit = (w: Write) => boolean
111
+
112
+ /** the newest lanes of a session the log is asked a name of: a lane that commits wrote lately */
113
+ const MAX_NAMED = 48
114
+
115
+ /** who commits: who may be the committer, the name a refusal prints, and the held calls it was read from */
116
+ type Committer = { may: MayCommit; label: string; calls: Committing[] }
117
+
118
+ /** who commits, or null when nothing says. Two sources, in this order:
119
+ * 1. the held calls of the commit's session that may commit in this checkout (shell-writes.ts `commitFolders`): the
120
+ * guard saw the agent of the Bash call that runs `git commit`, which the commit's own environment does not carry.
121
+ * The calls no commit was judged from yet are asked first, so the last commit of a lane that ended does not speak
122
+ * for the next lane's. One agent among them is the committer. Several (two lanes commit at once): the one whose
123
+ * command names the most staged files, else the one `SK_AGENT` names, else any of them may be it.
124
+ * 2. no such call (a script that commits, a guard that did not run): the commit's environment. `CLAUDE_CODE_SESSION_ID`
125
+ * is the session of the shell that runs the commit, and the lane is the name it exported (`SK_AGENT`, what
126
+ * `writerName` gives), taken only when the log knows a lane of that session by it. With a session alone, any writer
127
+ * of that session may be the committer: its main thread and its lanes look the same from here */
128
+ function committerOf(env: Record<string, string | undefined>, commits: readonly Committing[], top: string, stagedFiles: ReadonlySet<string>, real: (p: string) => string, everyNote: () => readonly Write[], nameOf: (w: Writer) => string): Committer | null {
129
+ const session = env['CLAUDE_CODE_SESSION_ID'] || null
130
+ const lane = env['SK_AGENT'] || null
131
+ const here = session == null ? [] : commits.filter((c) => c.s === session && c.k.includes(top))
132
+ for (const pool of [here.filter((c) => !c.used), here.filter((c) => c.used)]) {
133
+ const agents = new Map<string, Committing[]>()
134
+ for (const c of pool) agents.set(writerKey(c), [...(agents.get(writerKey(c)) ?? []), c])
135
+ if (agents.size === 0) continue
136
+ // the name is read only where a refusal prints it
137
+ const exact = (key: string): Committer => ({ may: (w) => writerKey(w) === key, get label() { return nameOf(agents.get(key)![0]!) }, calls: agents.get(key)! })
138
+ let tied = [...agents.keys()]
139
+ if (tied.length === 1) return exact(tied[0]!)
140
+ const score = new Map(tied.map((key) => [key, new Set(agents.get(key)!.flatMap((c) => c.files.map(real)).filter((f) => stagedFiles.has(f))).size]))
141
+ const best = Math.max(...score.values())
142
+ if (best > 0) tied = tied.filter((key) => score.get(key) === best)
143
+ if (tied.length === 1) return exact(tied[0]!)
144
+ const named = lane == null ? [] : tied.filter((key) => nameOf(agents.get(key)![0]!) === lane)
145
+ if (named.length === 1) return exact(named[0]!)
146
+ return { may: (w) => tied.includes(writerKey(w)), label: tied.map((key) => nameOf(agents.get(key)![0]!)).join(' or '), calls: [] }
147
+ }
148
+ if (session == null && lane == null) return null
149
+ const inSession: MayCommit = (w) => session == null || w.s === session
150
+ let known: boolean | null = null
151
+ /** does the log know a lane of the session by the exported name: its newest lanes are asked, each one's name once */
152
+ const laneKnown = (): boolean => {
153
+ const asked = new Set<string>()
154
+ const notes = everyNote()
155
+ for (let i = notes.length - 1; i >= 0 && asked.size < MAX_NAMED; i--) {
156
+ const w = notes[i]!
157
+ if (w.a == null || !inSession(w) || asked.has(writerKey(w))) continue
158
+ asked.add(writerKey(w))
159
+ if (nameOf(w) === lane) return true
160
+ }
161
+ return false
162
+ }
163
+ return {
164
+ label: lane ?? `session-${session!.slice(0, 8)}`,
165
+ calls: [],
166
+ may: (w) => {
167
+ if (!inSession(w)) return false
168
+ if (lane == null || (w.a != null && nameOf(w) === lane)) return true
169
+ // the log is read for the name only here, where the writer asked about is not that lane
170
+ known ??= laneKnown()
171
+ return !known
172
+ },
173
+ }
174
+ }
175
+
176
+ function contested(top: string, staged: Staged, writes: readonly Write[], may: MayCommit | null, real: (p: string) => string): Contested[] {
121
177
  const byFile = new Map<string, Write[]>()
122
178
  for (const w of writes) {
123
179
  const f = real(w.f)
@@ -125,35 +181,133 @@ function contested(root: string, staged: Staged, writes: readonly Write[]): Cont
125
181
  if (ws == null) byFile.set(f, [w])
126
182
  else ws.push(w)
127
183
  }
128
- const top = real(root)
129
184
  const out: Contested[] = []
185
+ const foreign: Contested[] = []
130
186
  for (const e of staged.entries) {
131
187
  const ws = byFile.get(real(join(top, e.path))) ?? []
132
188
  if (new Set(ws.map(writerKey)).size >= 2) out.push({ path: e.path, ws })
189
+ else if (may != null && ws.length > 0 && !may(ws[0]!)) foreign.push({ path: e.path, ws })
133
190
  }
134
- return out
191
+ const newest = (c: Contested): number => Math.max(...c.ws.map((w) => w.e ?? w.t))
192
+ return [...out, ...foreign.sort((x, y) => newest(y) - newest(x)).slice(0, MAX_FOREIGN)]
193
+ }
194
+
195
+ /** an edit lands this soon after its note, which the guard takes before the edit runs */
196
+ const EDIT_LANDS_MS = 5_000
197
+ const isShell = (w: Write): boolean => w.e != null
198
+
199
+ /** one write of each writer of a file since its last commit, from its notes. An edit is a write of its agent. A Bash
200
+ * call only NAMED the file, between `t` and `e`, so the mtimes decide: each mtime a note saw (the file's own before a
201
+ * call, `b`, and after a Bash call, `m`) is one write, and the Bash calls whose time holds it are asked:
202
+ * - every call SHAPED to write the file made it (`w`): two that overlap are two writers, whichever began last;
203
+ * - a call that only names the file made it when nothing else explains it: no shaped call, and no edit, which writes
204
+ * once and so explains the first mtime a note saw after it. Several such calls all count: either may have written.
205
+ * So an agent that read the file while another's edit or shaped call wrote it is no writer, and a write a later one
206
+ * covered still counts: the later call saw its mtime.
207
+ * `head`: the file's blob in HEAD. The last note that saw the file hold that content (`h`) moves the start past the
208
+ * last commit: the diff against HEAD was empty then, so each of its hunks was written after that note, and a writer
209
+ * whose hunk left before it (a word added and taken back, a merge that left the file as HEAD holds it) is none */
210
+ export function writersSince(ws: readonly Write[], since: number, head: string | null = null): Write[] {
211
+ const by = new Map<string, Write>()
212
+ const add = (w: Write): void => { if (!by.has(writerKey(w))) by.set(writerKey(w), w) }
213
+ /** when the file was last seen as HEAD holds it, and its mtime then */
214
+ let asHead: { at: number; mtime: number } | null = null
215
+ if (head != null) for (const w of ws) {
216
+ if (w.h == null || !head.startsWith(w.h)) continue
217
+ const at = isShell(w) ? w.e! : w.t
218
+ if (at >= since && (asHead == null || at > asHead.at)) asHead = { at, mtime: (isShell(w) ? w.m : w.b) ?? 0 }
219
+ }
220
+ // git dates a commit to the second: a write inside that second, an edit or through the shell, is taken as
221
+ // committed, unless a note saw the file as HEAD holds it in that second or later. A file HEAD never held has none
222
+ const after = since > 0 ? since + 1000 : 0
223
+ const held = asHead
224
+ // an edit noted an instant before that note, with the file still older than it, had not landed yet
225
+ const editCounts = (w: Write): boolean => (held == null ? w.t >= after : w.t >= held.at || (w.t > held.mtime && held.at - w.t <= EDIT_LANDS_MS))
226
+ const mtimeCounts = (v: number): boolean => (held == null ? v >= after : v > held.mtime)
227
+ for (const w of ws) if (!isShell(w) && editCounts(w)) add(w)
228
+ const seen = new Set<number>()
229
+ for (const w of ws) for (const v of [w.b, w.m]) if (v != null && mtimeCounts(v)) seen.add(v)
230
+ const mtimes = [...seen].sort((x, y) => x - y)
231
+ const edited = new Set<number>()
232
+ for (const w of ws) {
233
+ if (isShell(w)) continue
234
+ const first = mtimes.find((v) => v >= w.t && v <= w.t + EDIT_LANDS_MS)
235
+ if (first != null) edited.add(first)
236
+ }
237
+ for (const v of mtimes) {
238
+ const calls = ws.filter((w) => isShell(w) && w.t <= v && v <= w.e!)
239
+ const shaped = calls.filter((w) => w.w === 1)
240
+ if (shaped.length > 0) shaped.forEach(add)
241
+ else if (!edited.has(v)) calls.forEach(add)
242
+ }
243
+ // a file a Bash call removed has no mtime to date its write
244
+ for (const w of ws) if (isShell(w) && w.m === 0 && w.b !== 0 && (held == null ? w.e! >= after : w.e! > held.at)) add(w)
245
+ return [...by.values()].sort((x, y) => x.t - y.t)
135
246
  }
136
247
 
137
- function judge(files: readonly Contested[], lastCommitMs: (path: string) => number, env: Record<string, string | undefined>): SharedOutcome {
248
+ /** what says whether a writer is live or gone: the writer, and its newest note of the file */
249
+ type StateOf = (w: Write, lastNote: number) => WriterState
250
+ const LIVE: WriterState = { state: 'live', heard: 0 }
251
+
252
+ /** each writer's name, read once */
253
+ function names(): (w: Writer) => string {
254
+ const known = new Map<string, string>()
255
+ return (w) => {
256
+ const k = writerKey(w)
257
+ let n = known.get(k)
258
+ if (n == null) known.set(k, (n = writerName(w)))
259
+ return n
260
+ }
261
+ }
262
+
263
+ function judge(files: readonly Contested[], lastCommitMs: (path: string) => number, headBlob: (path: string) => string | null, env: Record<string, string | undefined>, stateOf: StateOf, nameOf: (w: Writer) => string, committer: Committer | null): SharedOutcome {
138
264
  const named = new Set((env[COMMIT_WITH] ?? '').split(/[\s,]+/).filter(Boolean))
139
265
  const shared: SharedFile[] = []
140
266
  const joint: SharedFile[] = []
141
267
  for (const { path, ws } of files) {
142
- const since = lastCommitMs(path)
143
- const keys = new Set(ws.filter((w) => w.t >= since).map(writerKey))
144
- if (keys.size < 2) continue
145
- // one name per writer, never deduped: two lanes under one name are still two writers
146
- const writers = [...keys].map((k) => writerName(ws.find((w) => writerKey(w) === k)!))
268
+ const wrote = writersSince(ws, lastCommitMs(path), headBlob(path))
269
+ if (wrote.length === 0) continue
270
+ const lastNote = (w: Write): number => Math.max(...ws.filter((x) => writerKey(x) === writerKey(w)).map((x) => x.e ?? x.t))
271
+ // one name per writer, never deduped: two lanes under one name are still two writers.
272
+ // a gone writer needs the word like a live one: the mark only says who is left to ask, and since when
273
+ const writers = wrote.map((w) => {
274
+ const { state, heard } = stateOf(w, lastNote(w))
275
+ if (state !== 'gone') return nameOf(w)
276
+ return `${nameOf(w)} (${['gone', ...(heard > 0 ? [`last heard ${heardAt(heard)}`] : []), ...(w.a == null ? [] : [`agent ${w.a.slice(0, 8)}`])].join(', ')})`
277
+ })
278
+ const unnamed = wrote.filter((w) => !named.has(nameOf(w)))
279
+ // the committer wrote none of it: the file is its writers' to commit, so each one is named, a gone one too:
280
+ // its unfinished work goes to another lane on the orchestrator's word, never in silence
281
+ if (committer != null && !wrote.some(committer.may)) {
282
+ writers[writers.length - 1] += ` (the committer ${committer.label} wrote none of it)`
283
+ if (unnamed.length === 0) joint.push({ path, writers })
284
+ else shared.push({ path, writers })
285
+ continue
286
+ }
287
+ if (wrote.length < 2) continue
147
288
  // the committer is one of the writers and needs no name: every other one does
148
- if (writers.filter((n) => !named.has(n)).length <= 1) joint.push({ path, writers })
289
+ if (unnamed.length <= 1) joint.push({ path, writers })
149
290
  else shared.push({ path, writers })
150
291
  }
151
292
  return shared.length > 0 ? { status: 'shared', files: shared } : { status: 'clean', joint }
152
293
  }
153
294
 
154
- /** the decision. `lastCommitMs` is asked only for a file two writers touched, so an ordinary commit runs no git */
155
- export function sharedVerdict(root: string, staged: Staged, writes: readonly Write[], lastCommitMs: (path: string) => number, env: Record<string, string | undefined> = process.env): SharedOutcome {
156
- return fromAgent(env) ? judge(contested(root, staged, writes), lastCommitMs, env) : OUTSIDE
295
+ /** a folder's real path; the path itself where it cannot be resolved */
296
+ const realFolder = (dir: string): string => { try { return realpathSync(dir) } catch { return dir } }
297
+ const stagedSet = (top: string, staged: Staged, real: (p: string) => string): Set<string> => new Set(staged.entries.map((e) => real(join(top, e.path))))
298
+
299
+ /** the decision. `lastCommitMs` and `headBlob` are asked only for a file two writers noted, or none of whose noted
300
+ * writers may be the committer, so an ordinary commit runs no git. `headBlob`: the file's blob in HEAD, or null when a note of the working file says nothing of what this
301
+ * commit takes (`blobsOf`). `stateOf`: what says a writer is live or gone, live by default (the gate gives
302
+ * `writerState`).
303
+ * `commits`: the held calls that may commit (`heldNow`), none by default */
304
+ export function sharedVerdict(root: string, staged: Staged, writes: readonly Write[], lastCommitMs: (path: string) => number, env: Record<string, string | undefined> = process.env, headBlob: (path: string) => string | null = () => null, stateOf: StateOf = () => LIVE, commits: readonly Committing[] = []): SharedOutcome {
305
+ if (!fromAgent(env)) return OUTSIDE
306
+ const nameOf = names()
307
+ const real = realPaths()
308
+ const top = realFolder(root)
309
+ const committer = committerOf(env, commits, top, stagedSet(top, staged, real), real, () => writes, nameOf)
310
+ return judge(contested(top, staged, writes, committer?.may ?? null, real), lastCommitMs, headBlob, env, stateOf, nameOf, committer)
157
311
  }
158
312
 
159
313
  /** when the file was last committed, ms; 0 for a file HEAD never held */
@@ -163,12 +317,48 @@ async function lastCommitMs(root: string, path: string): Promise<number> {
163
317
  return (await p.exited) === 0 && Number.isFinite(s) ? s * 1000 : 0
164
318
  }
165
319
 
166
- /** the gate: each contested file's last commit asked of git at once, one process each */
320
+ /** one line of `git diff-index --cached --raw -z`: `:<mode> <mode> <blob in HEAD> <blob staged> <status>`, then the path */
321
+ const RAW = /^:\d+ \d+ ([0-9a-f]+) ([0-9a-f]+) \w/
322
+
323
+ /** each path's blob in HEAD, for the paths whose staged blob is the working file's content: one git process. The notes
324
+ * saw the WORKING file, and a commit takes the STAGED content. Where the two are one (a pathspec commit, a `git add`
325
+ * just before), the working file went from HEAD's content to what is committed, so a note that saw HEAD's content
326
+ * dates every hunk. Where they differ (a file staged earlier, then written again), no note says so: no blob */
327
+ async function blobsOf(root: string, paths: readonly string[]): Promise<Map<string, string>> {
328
+ const out = new Map<string, string>()
329
+ if (paths.length === 0) return out
330
+ const p = Bun.spawn([gitBin(), 'diff-index', '--cached', '--raw', '-z', 'HEAD', '--', ...paths], { cwd: root, env: process.env, stdout: 'pipe', stderr: 'ignore' })
331
+ const fields = (await new Response(p.stdout).text()).split('\0')
332
+ if ((await p.exited) !== 0) return out
333
+ for (let i = 0; i + 1 < fields.length; i += 2) {
334
+ const m = RAW.exec(fields[i]!)
335
+ const path = fields[i + 1]!
336
+ if (m == null || /^0+$/.test(m[1]!)) continue
337
+ const h = seenOf(join(root, path)).h
338
+ if (h != null && m[2]!.startsWith(h)) out.set(path, m[1]!)
339
+ }
340
+ return out
341
+ }
342
+
343
+ /** the gate: each contested file's last commit asked of git at once, one process each, and their blobs in one more.
344
+ * It parses the notes of the files this commit stages and no other; the whole log is read only where a lane's
345
+ * exported name must be looked up (`committerOf`, its second source) */
167
346
  export async function runSharedFile(root: string, staged: Staged): Promise<SharedOutcome> {
168
347
  if (!fromAgent(process.env)) return OUTSIDE
169
348
  // a pass that inspected nothing must not print ok
170
349
  if (!repoHasEditGuard(root)) return { status: 'skipped', reason: `no edit hook (${EDIT_MATCHER}) in .claude/settings.json, so no edit is noted: sk ci installs it (SK013), never in a repo whose root publishes to npm` }
171
- const files = contested(root, staged, readWrites())
172
- const last = new Map(await Promise.all(files.map(async (f) => [f.path, await lastCommitMs(root, f.path)] as const)))
173
- return judge(files, (p) => last.get(p) ?? 0, process.env)
350
+ const now = Date.now()
351
+ const held = heldNow(now)
352
+ const writes = [...readWrites(now, new Set(staged.entries.map((e) => basename(e.path)))), ...held.writes]
353
+ let every: Write[] | null = null
354
+ const everyNote = (): Write[] => (every ??= [...readWrites(now), ...held.writes])
355
+ const nameOf = names()
356
+ const real = realPaths()
357
+ const top = realFolder(root)
358
+ const committer = committerOf(process.env, held.commits, top, stagedSet(top, staged, real), real, everyNote, nameOf)
359
+ for (const call of committer?.calls ?? []) markJudged(call)
360
+ const files = contested(top, staged, writes, committer?.may ?? null, real)
361
+ const [dates, blobs] = await Promise.all([Promise.all(files.map(async (f) => [f.path, await lastCommitMs(root, f.path)] as const)), blobsOf(root, files.map((f) => f.path))])
362
+ const last = new Map(dates)
363
+ return judge(files, (p) => last.get(p) ?? 0, (p) => blobs.get(p) ?? null, process.env, writerState, nameOf, committer)
174
364
  }