rvlib-shipkit 2.25.0 → 2.27.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 (456) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/package.json +2 -2
  3. package/src/agent-time/diet.ts +77 -0
  4. package/src/agent-time/family.ts +72 -0
  5. package/src/agent-time/hooks.ts +331 -0
  6. package/src/agent-time/limits.ts +44 -0
  7. package/src/agent-time/live.ts +1 -3
  8. package/src/agent-time/mask.ts +96 -18
  9. package/src/agent-time/refused.ts +45 -0
  10. package/src/agent-time/render.ts +130 -17
  11. package/src/agent-time/report-cache.ts +57 -0
  12. package/src/agent-time/report.ts +349 -23
  13. package/src/agent-time/shape.ts +50 -3
  14. package/src/agent-time/store.ts +370 -95
  15. package/src/agent-time/timeline.ts +140 -21
  16. package/src/agent-time/turns.ts +18 -8
  17. package/src/annex/offload.ts +17 -6
  18. package/src/annex/tidy.ts +70 -10
  19. package/src/asks/ask-after.ts +40 -0
  20. package/src/asks/asks-queue.ts +205 -47
  21. package/src/assets/kit-config.ts +7 -3
  22. package/src/assets/kits/identity-kit.ts +289 -10
  23. package/src/check.ts +3 -1
  24. package/src/checks/SK004-gitignore-policy.check.ts +12 -5
  25. package/src/checks/SK013-one-way-in-policy.check.ts +8 -3
  26. package/src/checks/SK026-asks-autoclose.check.ts +5 -5
  27. package/src/checks/SK028-readme.check.ts +7 -66
  28. package/src/checks/SK030-cache-audit.check.ts +6 -1
  29. package/src/checks/SK031-trace-audit.check.ts +2 -0
  30. package/src/checks/SK033-global-contribution.check.ts +3 -1
  31. package/src/checks/SK035-public-clean.check.ts +2 -2
  32. package/src/checks/SK043-scratch-on-the-mac.check.ts +59 -4
  33. package/src/checks/SK045-slow-hooks.check.ts +47 -0
  34. package/src/checks/SK046-hook-records.check.ts +76 -0
  35. package/src/checks/SK047-login-in-description.check.ts +36 -0
  36. package/src/checks/SK048-one-local-file.check.ts +36 -0
  37. package/src/cli/cmd_Asks.ts +71 -5
  38. package/src/cli/cmd_Backup.ts +5 -3
  39. package/src/cli/cmd_Capacity.ts +2 -2
  40. package/src/cli/cmd_CrossRepoActivity.ts +5 -4
  41. package/src/cli/cmd_Db.ts +253 -0
  42. package/src/cli/cmd_History.ts +212 -0
  43. package/src/cli/cmd_Home.ts +31 -3
  44. package/src/cli/cmd_Hq.ts +516 -0
  45. package/src/cli/cmd_Machines.ts +36 -0
  46. package/src/cli/cmd_Media.ts +38 -6
  47. package/src/cli/cmd_Mv.ts +1 -1
  48. package/src/cli/cmd_Reflect.ts +23 -2
  49. package/src/cli/cmd_Releases.ts +30 -0
  50. package/src/cli/cmd_Review.ts +569 -118
  51. package/src/cli/cmd_Secret.ts +62 -12
  52. package/src/cli/cmd_Social.ts +83 -1
  53. package/src/cli/cmd_Space.ts +324 -0
  54. package/src/cli/cmd_Time.ts +82 -5
  55. package/src/cli/cmd_Tmp.ts +28 -4
  56. package/src/cli/cmd_Trailer.ts +14 -10
  57. package/src/cli/cmd_Urls.ts +56 -0
  58. package/src/cli/cmd_Vault.ts +583 -0
  59. package/src/cli/family-help.ts +4 -2
  60. package/src/cli/family-pages.ts +1 -1
  61. package/src/cli/registry.ts +26 -4
  62. package/src/collections/actions.ts +63 -13
  63. package/src/collections/collection-types.ts +23 -1
  64. package/src/collections/providers.ts +117 -23
  65. package/src/collections/review.ts +4 -4
  66. package/src/commands/runner.ts +5 -1
  67. package/src/contracts/contract-manifests.ts +6 -5
  68. package/src/contracts/contract-types.ts +6 -4
  69. package/src/contracts/contracts-engine.ts +11 -0
  70. package/src/contracts/manifests/chrome-web-store.contract.ts +31 -0
  71. package/src/core/budget.ts +12 -17
  72. package/src/core/capacity.ts +27 -18
  73. package/src/core/check-runner.ts +7 -4
  74. package/src/core/history-files.ts +9 -5
  75. package/src/core/layout.ts +3 -0
  76. package/src/core/machine-busy.ts +127 -0
  77. package/src/core/machine-commit.ts +6 -1
  78. package/src/core/machine-db.ts +368 -20
  79. package/src/core/machine-layout.ts +137 -0
  80. package/src/core/machine-read.ts +81 -0
  81. package/src/core/migrate-layout.ts +1 -1
  82. package/src/core/one-way-in-policy.ts +64 -7
  83. package/src/core/polling-policy.ts +27 -0
  84. package/src/core/retention.ts +16 -2
  85. package/src/core/scope.ts +107 -14
  86. package/src/core/signal-name.ts +6 -0
  87. package/src/core/slots.ts +5 -4
  88. package/src/core/trace-audit.ts +6 -1
  89. package/src/core/transient.ts +6 -0
  90. package/src/drill/clean.ts +25 -1
  91. package/src/drill/run.ts +2 -2
  92. package/src/drill/seal.ts +27 -4
  93. package/src/home/activity-shape.ts +2 -0
  94. package/src/home/activity.ts +66 -3
  95. package/src/home/app-sign.ts +15 -4
  96. package/src/home/daemon-jobs.ts +149 -7
  97. package/src/home/database-projects.ts +111 -0
  98. package/src/home/database-words.ts +203 -0
  99. package/src/home/databases.ts +460 -0
  100. package/src/home/global-units.ts +6 -0
  101. package/src/home/gui-app/ShipkitGui.swift +122 -1
  102. package/src/home/gui-app.ts +6 -3
  103. package/src/home/home-move.ts +514 -0
  104. package/src/home/home-paths.ts +12 -3
  105. package/src/home/home-routes.ts +68 -0
  106. package/src/home/inbox-shape.ts +24 -14
  107. package/src/home/machine-fold.ts +820 -0
  108. package/src/home/machine-host.ts +20 -5
  109. package/src/home/machine-repair.ts +503 -0
  110. package/src/home/machine-stores.ts +66 -15
  111. package/src/home/machine-temp.ts +547 -86
  112. package/src/home/resume.ts +79 -0
  113. package/src/home/run-daemon.ts +25 -4
  114. package/src/home/run-pm.ts +18 -5
  115. package/src/home/serve-daemon.ts +18 -3
  116. package/src/home/serve-web.ts +175 -7
  117. package/src/home/space-job.ts +115 -0
  118. package/src/home/space-page.ts +257 -0
  119. package/src/home/space-route.ts +167 -0
  120. package/src/home/space-words.ts +103 -0
  121. package/src/home/time-page-shape.ts +202 -0
  122. package/src/home/time-page.ts +64 -0
  123. package/src/home/vault-page.ts +482 -0
  124. package/src/home/vault-words.ts +132 -0
  125. package/src/hooks/leak-guard.ts +40 -13
  126. package/src/hooks/one-way-in-guard.ts +17 -4
  127. package/src/hq/cards.ts +581 -0
  128. package/src/hq/door-route.ts +43 -0
  129. package/src/hq/door.ts +163 -0
  130. package/src/hq/files-send.ts +348 -0
  131. package/src/hq/forgotten-log.ts +35 -0
  132. package/src/hq/history-check.ts +255 -0
  133. package/src/hq/history-place.ts +146 -0
  134. package/src/hq/history-send.ts +487 -0
  135. package/src/hq/hq-db.ts +99 -0
  136. package/src/hq/hq-local.ts +469 -0
  137. package/src/hq/hq-routes.ts +196 -0
  138. package/src/hq/hq-store.ts +599 -0
  139. package/src/hq/kinds/ask.ts +147 -0
  140. package/src/hq/kinds/card-gone.ts +83 -0
  141. package/src/hq/kinds/card-msg.ts +66 -0
  142. package/src/hq/kinds/card.ts +99 -0
  143. package/src/hq/kinds/index.ts +21 -0
  144. package/src/hq/kinds/kind.ts +126 -0
  145. package/src/hq/kinds/media.ts +125 -0
  146. package/src/hq/kinds/prompt.ts +219 -0
  147. package/src/hq/kinds/reflection.ts +128 -0
  148. package/src/hq/kinds/report.ts +55 -0
  149. package/src/hq/kinds/time-day.ts +236 -0
  150. package/src/hq/ledger.ts +473 -0
  151. package/src/hq/machine-key.ts +44 -0
  152. package/src/hq/machine-notes.ts +131 -0
  153. package/src/hq/outbox.ts +372 -0
  154. package/src/hq/replica.ts +168 -0
  155. package/src/hq/repo-id.ts +4 -0
  156. package/src/hq/report-facts.ts +117 -0
  157. package/src/hq/report.ts +274 -0
  158. package/src/hq/switch.ts +151 -0
  159. package/src/hq/vault-grant.ts +92 -0
  160. package/src/identities/identities.ts +15 -3
  161. package/src/identities/steps.ts +31 -0
  162. package/src/ledger/db.ts +73 -26
  163. package/src/ledger/gate-checks.ts +29 -4
  164. package/src/ledger/git-key.ts +3 -3
  165. package/src/ledger/git-scan.ts +49 -7
  166. package/src/ledger/run-log.ts +11 -3
  167. package/src/ledger/store.ts +26 -4
  168. package/src/media-store/backup/daemon.ts +36 -17
  169. package/src/media-store/backup/kept.ts +241 -0
  170. package/src/media-store/backup/restore.ts +14 -4
  171. package/src/media-store/backup/run.ts +11 -11
  172. package/src/media-store/backup/secret.ts +6 -4
  173. package/src/media-store/backup/snapshot.ts +4 -2
  174. package/src/media-store/backup/sources.ts +68 -20
  175. package/src/media-store/copy/config.ts +77 -0
  176. package/src/media-store/copy/copy.ts +194 -0
  177. package/src/media-store/copy/lifecycle.ts +43 -0
  178. package/src/media-store/copy/night.ts +90 -0
  179. package/src/media-store/copy/proof.ts +151 -0
  180. package/src/media-store/copy/snapshot.ts +152 -0
  181. package/src/media-store/copy/store.ts +62 -0
  182. package/src/media-store/copy/stream.ts +176 -0
  183. package/src/media-store/daemon.ts +66 -16
  184. package/src/media-store/db.ts +22 -11
  185. package/src/media-store/forget.ts +23 -3
  186. package/src/media-store/hand.ts +4 -3
  187. package/src/media-store/hq-find.ts +75 -0
  188. package/src/media-store/hq-send.ts +277 -0
  189. package/src/media-store/kind.ts +2 -0
  190. package/src/media-store/purge.ts +18 -15
  191. package/src/media-store/put.ts +24 -8
  192. package/src/media-store/remote.ts +16 -7
  193. package/src/media-store/space-listing.ts +240 -0
  194. package/src/media-store/space.ts +40 -21
  195. package/src/media-store/sync.ts +5 -5
  196. package/src/media-store/tidy.ts +98 -0
  197. package/src/media-store/upload.ts +3 -3
  198. package/src/media-store/webp.ts +66 -0
  199. package/src/messages/model.ts +16 -7
  200. package/src/messages/routes.ts +14 -4
  201. package/src/messages/score.ts +2 -2
  202. package/src/messages/suggest.ts +96 -0
  203. package/src/pages/frame-client.ts +10 -0
  204. package/src/plan/planner.ts +28 -17
  205. package/src/recordings/media-kind.ts +1 -0
  206. package/src/recordings/model.ts +1 -1
  207. package/src/recordings/recorder-app/Capture.swift +9 -7
  208. package/src/reflect/hq-corpus.ts +56 -0
  209. package/src/reflect/prompt-corpus.ts +3 -1
  210. package/src/reflect/transcript.ts +146 -36
  211. package/src/release/machine-words.ts +67 -0
  212. package/src/release/public-clean.ts +8 -3
  213. package/src/releases/from-card.ts +1 -1
  214. package/src/releases/model.ts +18 -0
  215. package/src/releases/routes.ts +10 -5
  216. package/src/releases/store.ts +23 -2
  217. package/src/repo-config.ts +42 -2
  218. package/src/review/anim.ts +2 -2
  219. package/src/review/auto.ts +2 -2
  220. package/src/review/card-db.ts +244 -0
  221. package/src/review/card-rows.ts +266 -0
  222. package/src/review/cells.ts +76 -5
  223. package/src/review/draft-card.ts +41 -0
  224. package/src/review/draft-model.ts +78 -0
  225. package/src/review/format.ts +29 -10
  226. package/src/review/gone.ts +98 -0
  227. package/src/review/inbox-hook.ts +35 -0
  228. package/src/review/marks.ts +1 -1
  229. package/src/review/media-kind.ts +7 -5
  230. package/src/review/media-read.ts +9 -7
  231. package/src/review/media.ts +32 -5
  232. package/src/review/model.ts +214 -45
  233. package/src/review/move.ts +491 -0
  234. package/src/review/notes.ts +12 -20
  235. package/src/review/previews.ts +15 -19
  236. package/src/review/project.ts +1 -1
  237. package/src/review/rev.ts +8 -0
  238. package/src/review/role.ts +1 -1
  239. package/src/review/routes.ts +64 -13
  240. package/src/review/stage-card.ts +8 -4
  241. package/src/review/stage-routes.ts +1 -1
  242. package/src/review/store.ts +529 -83
  243. package/src/review/thread-fold.ts +51 -0
  244. package/src/review/threads.ts +147 -9
  245. package/src/review/trailer-auto-mock.ts +63 -0
  246. package/src/review/trailer-card.ts +4 -4
  247. package/src/review/trailer-desk.ts +41 -7
  248. package/src/review/trailer-media.ts +1 -0
  249. package/src/review/trailer-model.ts +8 -0
  250. package/src/review/trailer-notes.ts +1 -1
  251. package/src/review/trailer-routes.ts +9 -1
  252. package/src/review/unit.ts +6 -6
  253. package/src/review/watchers.ts +1 -1
  254. package/src/rules/untrack-generated.ts +92 -8
  255. package/src/secrets/held.ts +16 -0
  256. package/src/secrets/keychain.ts +113 -0
  257. package/src/secrets/list.ts +16 -6
  258. package/src/secrets/manager.ts +24 -10
  259. package/src/secrets/read.ts +257 -0
  260. package/src/secrets/who-reads.ts +49 -0
  261. package/src/serve/door-forward.ts +268 -0
  262. package/src/serve/door-names.ts +47 -0
  263. package/src/serve/embed.ts +1 -1
  264. package/src/serve/hub-app/activity-view.tsx +56 -32
  265. package/src/serve/hub-app/activity.css +7 -1
  266. package/src/serve/hub-app/asks-page.tsx +48 -0
  267. package/src/serve/hub-app/asks-st.ts +25 -0
  268. package/src/serve/hub-app/clock-svc.ts +1 -2
  269. package/src/serve/hub-app/col-card.tsx +64 -13
  270. package/src/serve/hub-app/col-list-page.tsx +122 -0
  271. package/src/serve/hub-app/col-list-st.ts +103 -0
  272. package/src/serve/hub-app/col-tables-view.tsx +10 -41
  273. package/src/serve/hub-app/col-tables.ts +76 -8
  274. package/src/serve/hub-app/cols-svc.ts +70 -16
  275. package/src/serve/hub-app/database-st.ts +260 -0
  276. package/src/serve/hub-app/database-view.tsx +289 -0
  277. package/src/serve/hub-app/database.css +32 -0
  278. package/src/serve/hub-app/entry-bar.css +14 -0
  279. package/src/serve/hub-app/entry-bar.tsx +33 -0
  280. package/src/serve/hub-app/entry-pick.ts +31 -0
  281. package/src/serve/hub-app/floating.tsx +1 -0
  282. package/src/serve/hub-app/hash-route.ts +11 -1
  283. package/src/serve/hub-app/header-bar.tsx +14 -18
  284. package/src/serve/hub-app/home-st.ts +89 -9
  285. package/src/serve/hub-app/home-strip.css +5 -19
  286. package/src/serve/hub-app/home-strip.tsx +58 -92
  287. package/src/serve/hub-app/home.html +7 -0
  288. package/src/serve/hub-app/hub-app.tsx +31 -142
  289. package/src/serve/hub-app/hub-types.ts +3 -1
  290. package/src/serve/hub-app/hub.css +109 -23
  291. package/src/serve/hub-app/icons.tsx +18 -1
  292. package/src/serve/hub-app/identities-st.ts +56 -6
  293. package/src/serve/hub-app/identities-view.tsx +100 -58
  294. package/src/serve/hub-app/identities.css +17 -15
  295. package/src/serve/hub-app/identity-address.ts +5 -0
  296. package/src/serve/hub-app/inbox-st.ts +41 -24
  297. package/src/serve/hub-app/inbox-view.tsx +37 -41
  298. package/src/serve/hub-app/inbox.css +2 -5
  299. package/src/serve/hub-app/index.html +7 -0
  300. package/src/serve/hub-app/kept-cols.tsx +7 -0
  301. package/src/serve/hub-app/keys.ts +28 -15
  302. package/src/serve/hub-app/later.tsx +26 -0
  303. package/src/serve/hub-app/list-filter.tsx +14 -0
  304. package/src/serve/hub-app/list-walk.ts +72 -3
  305. package/src/serve/hub-app/machines-st.ts +251 -0
  306. package/src/serve/hub-app/machines-view.tsx +224 -0
  307. package/src/serve/hub-app/machines.css +76 -0
  308. package/src/serve/hub-app/md-copy.tsx +79 -0
  309. package/src/serve/hub-app/media-view.tsx +2 -0
  310. package/src/serve/hub-app/messages/messages-page.tsx +79 -7
  311. package/src/serve/hub-app/messages/messages-st.ts +99 -3
  312. package/src/serve/hub-app/messages.css +14 -0
  313. package/src/serve/hub-app/page-keys.ts +175 -0
  314. package/src/serve/hub-app/pages-frames.tsx +11 -3
  315. package/src/serve/hub-app/palette-st.ts +58 -11
  316. package/src/serve/hub-app/palette-view.tsx +3 -1
  317. package/src/serve/hub-app/project-list.css +54 -8
  318. package/src/serve/hub-app/project-list.tsx +128 -59
  319. package/src/serve/hub-app/projects-svc.ts +78 -7
  320. package/src/serve/hub-app/reader-chips.tsx +13 -0
  321. package/src/serve/hub-app/readme-view.tsx +2 -3
  322. package/src/serve/hub-app/readme.css +27 -5
  323. package/src/serve/hub-app/reflections-page.tsx +42 -0
  324. package/src/serve/hub-app/reflections-st.ts +17 -0
  325. package/src/serve/hub-app/releases/releases-page.tsx +25 -2
  326. package/src/serve/hub-app/releases/releases-st.ts +1 -1
  327. package/src/serve/hub-app/repo-sections.ts +9 -5
  328. package/src/serve/hub-app/repo-st.ts +35 -8
  329. package/src/serve/hub-app/review/draft-card.tsx +163 -0
  330. package/src/serve/hub-app/review/kit.tsx +50 -7
  331. package/src/serve/hub-app/review/note-place.ts +1 -1
  332. package/src/serve/hub-app/review/review-board.tsx +2 -2
  333. package/src/serve/hub-app/review/review-cells.tsx +145 -65
  334. package/src/serve/hub-app/review/review-kit.ts +27 -1
  335. package/src/serve/hub-app/review/review-list.tsx +68 -30
  336. package/src/serve/hub-app/review/review-page.tsx +7 -8
  337. package/src/serve/hub-app/review/review-st.ts +111 -24
  338. package/src/serve/hub-app/review/review-thread.tsx +49 -19
  339. package/src/serve/hub-app/review/review-views.tsx +475 -144
  340. package/src/serve/hub-app/review/thread-control-st.ts +115 -0
  341. package/src/serve/hub-app/review/thread-control.tsx +74 -0
  342. package/src/serve/hub-app/review/thread-st.ts +73 -26
  343. package/src/serve/hub-app/review/trailer-card.tsx +1 -1
  344. package/src/serve/hub-app/review/trailer-page.tsx +37 -16
  345. package/src/serve/hub-app/review/trailer-st.ts +41 -7
  346. package/src/serve/hub-app/review.css +267 -61
  347. package/src/serve/hub-app/side-lists.ts +72 -0
  348. package/src/serve/hub-app/sidebar.tsx +6 -3
  349. package/src/serve/hub-app/site/site-part.tsx +2 -8
  350. package/src/serve/hub-app/site/site-st.ts +4 -4
  351. package/src/serve/hub-app/social/comms-page.tsx +20 -5
  352. package/src/serve/hub-app/social/kit.tsx +30 -4
  353. package/src/serve/hub-app/social/post-card.tsx +139 -49
  354. package/src/serve/hub-app/social/serial-writes.ts +13 -0
  355. package/src/serve/hub-app/social/social-model.ts +11 -0
  356. package/src/serve/hub-app/social/social-page.tsx +94 -35
  357. package/src/serve/hub-app/social/social-st.ts +120 -36
  358. package/src/serve/hub-app/social/stage-popup.tsx +1 -1
  359. package/src/serve/hub-app/social/stage-st.ts +1 -1
  360. package/src/serve/hub-app/social/step-layout.ts +1 -1
  361. package/src/serve/hub-app/social.css +3 -0
  362. package/src/serve/hub-app/space-st.ts +209 -0
  363. package/src/serve/hub-app/space-view.tsx +196 -0
  364. package/src/serve/hub-app/space.css +27 -0
  365. package/src/serve/hub-app/stores/stores-page.tsx +91 -23
  366. package/src/serve/hub-app/stores/stores-st.ts +44 -19
  367. package/src/serve/hub-app/stores.css +6 -1
  368. package/src/serve/hub-app/theme-st.ts +22 -9
  369. package/src/serve/hub-app/time-charts.tsx +291 -0
  370. package/src/serve/hub-app/time-pages.tsx +749 -0
  371. package/src/serve/hub-app/time-st.ts +162 -0
  372. package/src/serve/hub-app/time-view.tsx +76 -0
  373. package/src/serve/hub-app/time.css +138 -0
  374. package/src/serve/hub-app/tree-build.ts +52 -42
  375. package/src/serve/hub-app/tree-row.tsx +4 -4
  376. package/src/serve/hub-app/tree-svc.ts +18 -9
  377. package/src/serve/hub-app/urls-svc.ts +154 -0
  378. package/src/serve/hub-app/urls-view.tsx +117 -0
  379. package/src/serve/hub-app/urls.css +30 -0
  380. package/src/serve/hub-app/vault-st.ts +127 -0
  381. package/src/serve/hub-app/vault-view.tsx +154 -0
  382. package/src/serve/hub-app/vault.css +38 -0
  383. package/src/serve/hub-app/veille/veille-st.ts +12 -10
  384. package/src/serve/hub-app/waiting-svc.ts +29 -0
  385. package/src/serve/hub-app/wikis-view.tsx +2 -2
  386. package/src/serve/hub-runtime.ts +15 -2
  387. package/src/serve/project-gutter-route.ts +27 -14
  388. package/src/serve/project-gutter.ts +25 -12
  389. package/src/serve/same-origin.ts +10 -0
  390. package/src/serve/serve-hub.ts +13 -4
  391. package/src/shipkit-files.ts +16 -2
  392. package/src/shipkit.ts +1 -1
  393. package/src/shot/shooter.ts +616 -420
  394. package/src/shot/shot-ask.ts +246 -155
  395. package/src/site/desk.ts +2 -2
  396. package/src/smoke/run-smoke.ts +3 -2
  397. package/src/social/cover.ts +202 -0
  398. package/src/social/discord-layout.ts +37 -13
  399. package/src/social/drafts.ts +3 -0
  400. package/src/social/load.ts +23 -2
  401. package/src/social/media-kind.ts +2 -1
  402. package/src/social/publish/discord.ts +5 -2
  403. package/src/social/publish/secret.ts +2 -2
  404. package/src/social/release-stage.ts +28 -13
  405. package/src/social/routes.ts +26 -1
  406. package/src/social/stage.ts +1 -1
  407. package/src/social/stats.ts +12 -9
  408. package/src/social/strip.ts +4 -1
  409. package/src/social/thumbnail.ts +255 -0
  410. package/src/stores/collection.ts +15 -11
  411. package/src/stores/desk.ts +236 -42
  412. package/src/stores/model.ts +72 -6
  413. package/src/stores/routes.ts +37 -12
  414. package/src/stores/unit.ts +14 -8
  415. package/src/suite/judge-suites.ts +113 -16
  416. package/src/suite/select.ts +45 -3
  417. package/src/suite/suite-cli.ts +81 -34
  418. package/src/trailer/bed.ts +1 -1
  419. package/src/trailer/build.ts +134 -21
  420. package/src/trailer/ffmpeg.ts +7 -0
  421. package/src/trailer/fonts.ts +3 -2
  422. package/src/trailer/grammar.ts +201 -2
  423. package/src/trailer/graph.ts +42 -5
  424. package/src/trailer/look.ts +21 -0
  425. package/src/trailer/mock.ts +154 -0
  426. package/src/trailer/passage.ts +65 -26
  427. package/src/trailer/score/heard.ts +89 -0
  428. package/src/trailer/score/sound.ts +14 -8
  429. package/src/trailer/sound/run.ts +16 -6
  430. package/src/trailer/stitch.ts +26 -5
  431. package/src/trailer/titles.ts +82 -19
  432. package/src/trailer/versions.ts +1 -3
  433. package/src/trailer/vertical.ts +3 -1
  434. package/src/urls/frame.ts +195 -0
  435. package/src/urls/routes.ts +43 -0
  436. package/src/urls/rows.ts +171 -0
  437. package/src/urls/unit.ts +73 -0
  438. package/src/vault/house-keys.ts +42 -0
  439. package/src/vault/layout.ts +50 -0
  440. package/src/vault/policy.ts +165 -0
  441. package/src/vault/vault-audit.ts +276 -0
  442. package/src/vault/vault-client.ts +40 -0
  443. package/src/vault/vault-config.ts +159 -0
  444. package/src/vault/vault-destroy.ts +78 -0
  445. package/src/vault/vault-handover.ts +305 -0
  446. package/src/vault/vault-http.ts +352 -0
  447. package/src/vault/vault-import.ts +208 -0
  448. package/src/vault/vault-init.ts +328 -0
  449. package/src/vault/vault-minter.ts +271 -0
  450. package/src/vault/vault-restore.ts +333 -0
  451. package/src/vault/vault-serve.ts +342 -0
  452. package/src/vault/vault-snapshot.ts +281 -0
  453. package/src/veille/asks.ts +1 -1
  454. package/src/veille/desk.ts +2 -2
  455. package/src/wiki/run-wiki.ts +2 -1
  456. package/src/wiki/scan-md.ts +42 -2
@@ -7,11 +7,15 @@
7
7
  // use id, or every imported session counts twice.
8
8
  import { type PromptEntry, dedupePrompts } from '../reflect/prompt-corpus.ts'
9
9
  import type { Outcome } from '../reflect/transcript.ts'
10
+ import { familyOf } from './family.ts'
11
+ import { FILE_MARK, kindOf, scriptOf } from './shape.ts'
12
+ import { type Refuser, refusalOf } from './refused.ts'
10
13
  import type { Masker } from './mask.ts'
11
14
  import { type Signal, signalsOf } from './signals.ts'
12
- import type { FileRow, Loaded } from './store.ts'
15
+ import type { FileRow, HookRun, Loaded } from './store.ts'
16
+ import { cadenceOf, matcherMatches } from './hooks.ts'
13
17
  import { type ReadCost, type TurnStats, addTurns, emptyTurns, turnsOf } from './turns.ts'
14
- import { type Breakdown, type Call, type Mark, type Stream, FAILED, IDLE_MS, addBreakdown, callMs, type Closed, closeCalls, emptyBreakdown, quantileSorted, ranBefore, retries, runMs, wallBreakdown } from './timeline.ts'
18
+ import { type Breakdown, type Call, type Mark, type Stream, FAILED, IDLE_MS, addBreakdown, callMs, type Closed, closeCalls, emptyBreakdown, quantileSorted, lanesAtWork, ranBefore, retries, runMs, wallBreakdown } from './timeline.ts'
15
19
 
16
20
  /** `ms`, the quantiles and `failedMs` are run time (timeline.ts runMs): a
17
21
  * background run's from its start to its notification. `noEnd`: background
@@ -27,7 +31,7 @@ export type SlowCall = { ms: number; shape: string; cmd: string; at: number; acc
27
31
  export type Complaint = { at: number; session: string; account: string; text: string; signals: { signal: Signal; rule: string }[]; ran: { shape: string; cmd: string; ms: number; open: boolean }[] }
28
32
 
29
33
  /** one session or one sub-agent run, by its turns */
30
- export type TurnRow = { session: string; agent: string; account: string; start: number; work: number; wall: number; turns: TurnStats }
34
+ export type TurnRow = { session: string; agent: string; account: string; repo: string; start: number; work: number; wall: number; turns: TurnStats }
31
35
 
32
36
  /** turn count: the main sessions and the sub-agents apart, the runs with the
33
37
  * most wall, and the read shapes by the model time of the turns that issued them */
@@ -38,8 +42,148 @@ export type TurnReport = {
38
42
  reads: ReadCost[]
39
43
  }
40
44
 
45
+ /** a command that reached the time limit of its call: the harness moved it to the background. `limitMs`: how
46
+ * long it ran before that; `after`: what became of it (`none` while no end is recorded); `totalMs`: start to end */
47
+ export type TimeoutRow = { at: number; repo: string; session: string; agent: boolean; shape: string; /** the script a `<file>` shape ran, null for any other shape */ script: string | null; cmd: string; limitMs: number; after: 'ok' | 'failed' | 'stopped' | 'none'; totalMs: number | null }
48
+
49
+ /** the sub-agent runs of one repo: how many, and the wall they spent working or stopped on their own work */
50
+ export type LaneRepo = { repo: string; runs: number; work: number }
51
+
52
+ /** the foreground calls of commands that do next to nothing (INSTANT): their typical time is the floor of every Bash
53
+ * call, the permission check, the hooks on the call and the shell's start included */
54
+ export type Overhead = { calls: number; p50: number; p95: number; byRepo: ShapeRow[]; byPerm: ShapeRow[]; byDay: ShapeRow[] }
55
+
56
+ /** shapes whose own work is a few milliseconds, so the typical call is overhead */
57
+ const INSTANT = new Set(['echo', 'pwd', 'true', 'printf', 'date', 'which', 'cd', ':', 'test', 'ls', 'cat', 'wc', 'head', 'tail', 'basename', 'dirname', 'git rev-parse'])
58
+ export const TOP_SCRIPTS = 10
59
+
60
+ /** the turns of one model that wrote a call. `ctx` '' is every size, else one size of context (CTX_SIZES).
61
+ * `ms` the model time of those turns, `p50` and `p95` of one turn; `ctxP50` and `outP50` the typical
62
+ * tokens a turn read and wrote */
63
+ export type TurnCut = { model: string; ctx: string; turns: number; calls: number; ms: number; p50: number; p95: number; ctxP50: number; outP50: number }
64
+
65
+ /** the sizes of context a turn is filed under, by the tokens it read */
66
+ export const CTX_SIZES: readonly { label: string; under: number }[] = [
67
+ { label: 'under 50k', under: 50_000 },
68
+ { label: '50k to 100k', under: 100_000 },
69
+ { label: '100k to 200k', under: 200_000 },
70
+ { label: '200k to 400k', under: 400_000 },
71
+ { label: '400k and more', under: Infinity },
72
+ ]
73
+ const ctxSize = (tokens: number): string => (tokens <= 0 ? 'not recorded' : (CTX_SIZES.find((x) => tokens < x.under)?.label ?? 'not recorded'))
74
+ /** `claude-opus-4-5-20251101` reads as `opus-4-5` */
75
+ const modelName = (id: string): string => (id === '' ? 'not recorded' : id.replace(/^claude-/, '').replace(/-\d{8}$/, ''))
76
+
77
+ type Turn = { model: string; ctx: number; out: number; ms: number; calls: number }
78
+
79
+ /** the turns cut by model, each model then by its sizes of context; the most model time first */
80
+ export function turnCuts(turns: readonly Turn[]): TurnCut[] {
81
+ const by = new Map<string, Turn[]>()
82
+ for (const t of turns) for (const key of [`${modelName(t.model)}\u0000`, `${modelName(t.model)}\u0000${ctxSize(t.ctx)}`]) pushTo(by, key, t)
83
+ const cut = (key: string, ts: Turn[]): TurnCut => {
84
+ const [model = '', ctx = ''] = key.split('\u0000')
85
+ const sorted = (f: (t: Turn) => number): number[] => ts.map(f).sort((a, b) => a - b)
86
+ const ms = sorted((t) => t.ms)
87
+ const known = (xs: number[]): number[] => xs.filter((x) => x > 0)
88
+ return { model, ctx, turns: ts.length, calls: ts.reduce((a, t) => a + t.calls, 0), ms: ms.reduce((a, b) => a + b, 0), p50: quantileSorted(ms, 0.5), p95: quantileSorted(ms, 0.95), ctxP50: quantileSorted(known(sorted((t) => t.ctx)), 0.5), outP50: quantileSorted(known(sorted((t) => t.out)), 0.5) }
89
+ }
90
+ const all = [...by].map(([k, ts]) => cut(k, ts))
91
+ const order = CTX_SIZES.map((x) => x.label)
92
+ return all
93
+ .filter((c) => c.ctx === '')
94
+ .sort((a, b) => b.ms - a.ms)
95
+ .flatMap((m) => [m, ...all.filter((c) => c.model === m.model && c.ctx !== '').sort((a, b) => order.indexOf(a.ctx) - order.indexOf(b.ctx))])
96
+ }
97
+
98
+ /** a call refused before it ran. `ms`: the model time of the turn that wrote it, spent for nothing */
99
+ export type RefusedRow = { at: number; repo: string; session: string; agent: boolean; tool: string; shape: string; script: string | null; cmd: string; by: Refuser; name: string; reason: string; ms: number }
100
+ /** refusals summed under one name: how many, and the model time of the turns that wrote them */
101
+ export type RefusedCut = { name: string; by?: Refuser; n: number; ms: number; parts?: RefusedCut[] }
102
+ /** every call refused before it ran: by who refused, by reason (a hook by its script, the classifier by its
103
+ * reason), by command, and the newest ones */
104
+ export type Refused = { count: number; ms: number; by: RefusedCut[]; reasons: RefusedCut[]; shapes: RefusedCut[]; rows: RefusedRow[] }
105
+ export const TOP_REFUSED = 300
106
+
107
+ /** the kind of a reason: its first clause, a path and a quoted command as a mark, so the same refusal of
108
+ * two files is one kind */
109
+ export const reasonKind = (reason: string): string => {
110
+ const [head = '', next = ''] = reason.replace(/`[^`]*`/g, '<command>').replace(/[^\s:;,]*\/[^\s:;,]*/g, '<path>').split(': ')
111
+ return (head.length >= 20 || next === '' ? head : `${head}: ${next}`).replace(/[;,.]+$/, '').slice(0, 90)
112
+ }
113
+
114
+ /** rows summed under a key, the most refusals first */
115
+ function refusedCuts(rows: readonly RefusedRow[], key: (r: RefusedRow) => string, by?: (r: RefusedRow) => Refuser): RefusedCut[] {
116
+ const m = new Map<string, RefusedCut>()
117
+ for (const r of rows) {
118
+ const k = key(r)
119
+ const c = m.get(k) ?? { name: k, ...(by == null ? {} : { by: by(r) }), n: 0, ms: 0 }
120
+ c.n++
121
+ c.ms += r.ms
122
+ m.set(k, c)
123
+ }
124
+ return [...m.values()].sort((a, b) => b.n - a.n || b.ms - a.ms)
125
+ }
126
+
127
+ export function refusedOf(rows: RefusedRow[]): Refused {
128
+ const newest = [...rows].sort((a, b) => b.at - a.at)
129
+ return {
130
+ count: rows.length,
131
+ ms: rows.reduce((a, r) => a + r.ms, 0),
132
+ by: refusedCuts(rows, (r) => r.by, (r) => r.by),
133
+ reasons: refusedCuts(rows, (r) => `${r.by}\u0000${r.name}`, (r) => r.by).map((c) => {
134
+ const name = c.name.slice(c.name.indexOf('\u0000') + 1)
135
+ // a hook opens on what it said: its refusals by the kind of reason, the paths and commands left out
136
+ const said = c.by !== 'hook' ? [] : refusedCuts(rows.filter((r) => r.by === c.by && r.name === name && r.reason !== ''), (r) => reasonKind(r.reason)).slice(0, TOP_SCRIPTS)
137
+ return { ...c, name, ...(said.length > 1 || (said.length === 1 && said[0]?.name !== name) ? { parts: said } : {}) }
138
+ }),
139
+ shapes: refusedCuts(rows, (r) => r.shape).map((c) => {
140
+ const scripts = rows.filter((r) => r.shape === c.name && r.script != null)
141
+ return scripts.length === 0 ? c : { ...c, parts: refusedCuts(scripts, (r) => r.script ?? '').slice(0, TOP_SCRIPTS) }
142
+ }),
143
+ rows: newest.slice(0, TOP_REFUSED),
144
+ }
145
+ }
146
+
41
147
  export type SessionRow = { session: string; account: string; repo: string; start: number; wall: Breakdown; calls: number; subagents: number; first: string }
42
148
 
149
+ /** one local day: the wall of the main sessions and of the sub-agent runs
150
+ * inside it, the calls started in it, the sub-agent runs started in it */
151
+ export type DayRow = { at: number; day: string; main: Breakdown; sub: Breakdown; calls: number; runs: number }
152
+
153
+ /** past a day with a 25 hour clock change in it, short of two days */
154
+ const DAY_AND_A_BIT = 26 * 3_600_000
155
+
156
+ const startOfDay = (at: number): number => {
157
+ const d = new Date(at)
158
+ d.setHours(0, 0, 0, 0)
159
+ return d.getTime()
160
+ }
161
+
162
+ function dayRow(days: Map<number, DayRow>, at: number): DayRow {
163
+ let row = days.get(at)
164
+ if (row == null) {
165
+ const d = new Date(at)
166
+ row = { at, day: `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`, main: emptyBreakdown(), sub: emptyBreakdown(), calls: 0, runs: 0 }
167
+ days.set(at, row)
168
+ }
169
+ return row
170
+ }
171
+
172
+ /** from the first to the last thing a stream recorded, null for an empty one */
173
+ function spanOf(g: { stream: Stream; closed: Closed[] }): { start: number; end: number } | null {
174
+ let start = Infinity
175
+ let end = -Infinity
176
+ for (const m of g.stream.marks) {
177
+ if (m.at < start) start = m.at
178
+ if (m.at > end) end = m.at
179
+ }
180
+ for (const c of g.closed) {
181
+ if (c.start < start) start = c.start
182
+ if (c.stop > end) end = c.stop
183
+ }
184
+ return start === Infinity ? null : { start, end }
185
+ }
186
+
43
187
  export type TimeReport = {
44
188
  repos: string[]
45
189
  from: number | null
@@ -54,29 +198,115 @@ export type TimeReport = {
54
198
  callCount: number
55
199
  callMs: number
56
200
  shapes: ShapeRow[]
201
+ /** by tool; a tool's background runs are a row apart (`Bash (bg)`), their time being start to end */
57
202
  tools: ShapeRow[]
203
+ /** the Bash calls by family (family.ts), the background runs apart (`reads (bg)`) */
204
+ families: ShapeRow[]
205
+ /** the sub-agent runs by repo, the most work first */
206
+ lanesByRepo: LaneRepo[]
207
+ /** what a `<file>` shape ran: by the shape's key, its scripts with the most time */
208
+ scripts: Record<string, ShapeRow[]>
209
+ /** what a Bash call costs before its command does anything */
210
+ overhead: Overhead
211
+ /** the calls refused before they ran: by the classifier, a hook, a permission rule, or him */
212
+ refused: Refused
213
+ /** the model's turns that wrote a call, by model and by the size of the context the turn read */
214
+ models: { main: TurnCut[]; sub: TurnCut[] }
58
215
  slowest: SlowCall[]
59
216
  feedback: { prompts: number; queued: number; counts: Record<Signal, number>; rules: Record<string, number>; hits: Complaint[] }
60
217
  sessionRows: SessionRow[]
61
218
  turns: TurnReport
62
219
  /** the measured waste, biggest first: each with the number behind it */
63
220
  insights: Insight[]
221
+ hooks: HookRow[]
222
+ /** the wall of each local day of the window, oldest first */
223
+ days: DayRow[]
224
+ /** every command that reached its call's time limit, newest first */
225
+ timeouts: TimeoutRow[]
226
+ }
227
+
228
+ /** one hook command on one event, from the runs the harness timed (only the
229
+ * runs that printed). `repos`: where it was recorded. `calls`: the tool
230
+ * calls it applies to in each of those repos, between its first and its last
231
+ * recorded run there, by its declared matcher, else by the tools it was
232
+ * recorded on, each over its own span (`byMatcher` false); `waited`: the mean
233
+ * of its timed runs times those calls; both null on a turn event */
234
+ export type HookRow = { event: string; command: string; repos: string[]; tools: string[]; runs: number; mean: number; p50: number; p90: number; max: number; total: number; errors: number; first: number; calls: number | null; waited: number | null; byMatcher: boolean; placed: boolean }
235
+
236
+ /** some harness versions name a hook by its place in the settings (`command
237
+ * hook 2`), never its command: the place shifts as entries are added or
238
+ * differ per account, so those runs cannot be tied to a command, and the
239
+ * same place is another hook in each repo: one row per repo */
240
+ export const PLACED = /^command hook(?: \d+)?$/
241
+
242
+ /** key of a declared hook's matcher, by its event and command */
243
+ export const hookMatcherKey = (event: string, command: string): string => `${event}\u0000${command}`
244
+
245
+ export function hookRowsOf(runs: HookRun[], calls: { project: string; tool: string; start: number; end: number | null }[], matchers: Map<string, string>, mask: Masker, repoOf: (project: string) => string): HookRow[] {
246
+ const by = new Map<string, HookRun[]>()
247
+ for (const r of runs) pushTo(by, PLACED.test(r.command) ? `${hookMatcherKey(r.event, r.command)}\u0000${repoOf(r.project)}` : hookMatcherKey(r.event, r.command), r)
248
+ const callsOf = new Map<string, typeof calls>()
249
+ for (const c of calls) pushTo(callsOf, repoOf(c.project), c)
250
+ return [...by.values()].map((rs): HookRow => {
251
+ const first = rs[0] as HookRun
252
+ const ms = rs.map((r) => r.ms).sort((a, b) => a - b)
253
+ const tools = [...new Set(rs.map((r) => r.tool).filter((t) => t !== ''))].sort()
254
+ const matcher = matchers.get(hookMatcherKey(first.event, first.command)) ?? null
255
+ // a hook runs only where its settings wire it: each repo it was recorded in, between its first and last run
256
+ // there. With no declared matcher, each tool it was recorded on has its own span and its own mean: a place
257
+ // can name a save hook one day and a Bash guard the next
258
+ const spans = new Map<string, { repo: string; tool: string | null; start: number; last: number; ms: number; runs: number }>()
259
+ for (const r of rs) {
260
+ const repo = repoOf(r.project)
261
+ const key = matcher != null ? repo : `${repo}\u0000${r.tool}`
262
+ const s = spans.get(key)
263
+ if (s == null) spans.set(key, { repo, tool: matcher != null ? null : r.tool, start: r.at, last: r.at, ms: r.ms, runs: 1 })
264
+ else [s.start, s.last, s.ms, s.runs] = [Math.min(s.start, r.at), Math.max(s.last, r.at), s.ms + r.ms, s.runs + 1]
265
+ }
266
+ let n = 0
267
+ let waited = 0
268
+ for (const s of spans.values()) {
269
+ let here = 0
270
+ for (const c of callsOf.get(s.repo) ?? []) if ((c.end ?? c.start) >= s.start && c.start <= s.last && (s.tool == null ? matcherMatches(matcher ?? '', c.tool) : c.tool === s.tool)) here++
271
+ n += here
272
+ waited += here * (s.ms / s.runs)
273
+ }
274
+ const total = ms.reduce((a, b) => a + b, 0)
275
+ const call = cadenceOf(first.event) === 'call'
276
+ return { event: first.event, command: mask(first.command), repos: [...new Set([...spans.values()].map((s) => s.repo))].sort(), tools, runs: ms.length, mean: total / ms.length, p50: quantileSorted(ms, 0.5), p90: quantileSorted(ms, 0.9), max: ms[ms.length - 1] ?? 0, total, errors: rs.filter((r) => r.error).length, first: Math.min(...rs.map((r) => r.at)), calls: call ? n : null, waited: call ? waited : null, byMatcher: matcher != null, placed: PLACED.test(first.command) }
277
+ }).sort((a, b) => hookCost(b) - hookCost(a))
278
+ }
279
+
280
+ /** an estimate of what a hook cost: the mean of its timed runs times the
281
+ * calls it applies to (`waited`). It errs high where the hook returns early
282
+ * on calls that left no record (a silent run is never timed), low where it
283
+ * is slow and silent; never less than what was recorded */
284
+ export const hookCost = (h: HookRow): number => Math.max(h.total, h.waited ?? 0)
285
+
286
+ /** hook time is material past a minute recorded or five estimated */
287
+ export function hookInsight(rows: HookRow[]): Insight | null {
288
+ const top = rows[0]
289
+ if (top == null) return null
290
+ const est = top.waited ?? 0
291
+ if (top.total < 60_000 && est < 300_000) return null
292
+ const on = top.calls == null ? '' : `; it applies to ${top.calls.toLocaleString('en-US')} calls of ${top.repos.join(', ')}${top.byMatcher ? '' : ' (by the tools it was recorded on)'}, ~${fmt(est)} at the mean of its timed runs (an estimate: high where it returns early without a record)`
293
+ return { id: 'hooks', ms: Math.max(top.total, est), estimate: est > top.total, text: `the hook ${top.command.slice(0, 60)} on ${top.event}: ${top.runs.toLocaleString('en-US')} timed runs recorded, median ${fmt(top.p50)}, ${fmt(top.total)} in all${on} (sk time hooks)` }
64
294
  }
65
295
 
66
- export type Insight = { id: 'classifier' | 'bash-edits' | 'polling' | 'failed' | 'approval' | 'background'; ms: number; estimate: boolean; text: string }
296
+ export type Insight = { id: 'classifier' | 'bash-edits' | 'polling' | 'failed' | 'approval' | 'background' | 'hooks'; ms: number; estimate: boolean; text: string }
67
297
 
68
298
  /** commands that cost nothing to run: their time is the harness around them */
69
299
  const CHEAP = new Set(['grep', 'sed', 'cat', 'ls', 'head', 'tail', 'wc', 'git status', 'echo', 'pwd', 'rg'])
70
300
 
71
- const isEdit = (shape: string): boolean => shape.endsWith('(edit)') || shape === 'cat > (write)'
72
- const isPolling = (shape: string): boolean => shape.startsWith('(until)') || shape.startsWith('(while)') || shape === 'sleep'
301
+ const isEdit = (shape: string): boolean => shape.endsWith('(edit)') || shape.endsWith('cat > (write)')
302
+ const isPolling = (shape: string): boolean => shape.startsWith('(until)') || shape.startsWith('(while)') || kindOf(shape) === 'sleep'
73
303
 
74
304
  const fmt = (ms: number): string => (ms < 1000 ? `${(ms / 1000).toFixed(1)}s` : ms < 60_000 ? `${Math.round(ms / 1000)}s` : ms < 3_600_000 ? `${Math.round(ms / 60_000)}m` : `${(ms / 3_600_000).toFixed(1)}h`)
75
305
 
76
306
  const p50Of = (xs: number[]): number => quantileSorted(xs.sort((a, b) => a - b), 0.5)
77
307
 
78
308
  /** the waste the rows add up to, each a cause with its number */
79
- export function insightsOf(calls: Closed[], wall: Breakdown, shapes: ShapeRow[]): Insight[] {
309
+ export function insightsOf(calls: Closed[], shapes: ShapeRow[]): Insight[] {
80
310
  const out: Insight[] = []
81
311
  const bash = calls.filter((c) => c.tool === 'Bash')
82
312
  const cheap = bash.filter((c) => CHEAP.has(c.shape))
@@ -105,16 +335,21 @@ export function insightsOf(calls: Closed[], wall: Breakdown, shapes: ShapeRow[])
105
335
  const top = shapes.filter((s) => isPolling(s.shape) && !s.shape.endsWith(' (bg)')).slice(0, 3).map((s) => `${s.shape} ${fmt(s.ms)}`).join(', ')
106
336
  out.push({ id: 'polling', ms: polls.map(callMs).reduce((a, b) => a + b, 0), estimate: false, text: `${polls.length.toLocaleString('en-US')} polling waits (until and while loops, sleep), ${inBg} of them in the background, started there or moved there at the Bash timeout: ${top}` })
107
337
  }
108
- const failed = bash.filter((c) => c.outcome != null && FAILED.has(c.outcome))
338
+ // a failed wait is a foreground call: a background run that ends with an error, or that someone stops, held no agent
339
+ const failedAll = bash.filter((c) => c.outcome != null && FAILED.has(c.outcome))
340
+ const failed = failedAll.filter((c) => !c.bg)
109
341
  if (failed.length > 0) {
110
- const rerun = shapes.reduce((a, s) => a + s.retried, 0)
111
- const blind = shapes.reduce((a, s) => a + s.blind, 0)
112
- out.push({ id: 'failed', ms: failed.map((c) => runMs(c) ?? callMs(c)).reduce((a, b) => a + b, 0), estimate: false, text: `${failed.length.toLocaleString('en-US')} failed Bash runs (non zero exit, error, timeout), ${rerun} run again, ${blind} of them unchanged` })
342
+ const fg = shapes.filter((s) => !s.shape.endsWith(' (bg)'))
343
+ const rerun = fg.reduce((a, s) => a + s.retried, 0)
344
+ const blind = fg.reduce((a, s) => a + s.blind, 0)
345
+ const beside = failedAll.length - failed.length
346
+ out.push({ id: 'failed', ms: failed.map(callMs).reduce((a, b) => a + b, 0), estimate: false, text: `${failed.length.toLocaleString('en-US')} failed foreground Bash calls (non zero exit, error, timeout), ${rerun} run again, ${blind} of them unchanged${beside > 0 ? `; ${beside.toLocaleString('en-US')} background runs ended with an error or were stopped, a wait for no agent` : ''}` })
113
347
  }
114
- if (wall.approval > 0) {
115
- const n = calls.filter((c) => c.approval).length
348
+ // every call that waited for an allow, in a main session or in a lane; the time is the call's, its own run included
349
+ const allowed = calls.filter((c) => c.approval)
350
+ if (allowed.length > 0) {
116
351
  const top = [...shapes].filter((s) => s.approvals > 0).sort((a, b) => b.approvalMs - a.approvalMs).slice(0, 3).map((s) => `${s.shape} ${fmt(s.approvalMs)}`).join(', ')
117
- out.push({ id: 'approval', ms: wall.approval, estimate: false, text: `waiting for you to allow ${n} call${n === 1 ? '' : 's'}: ${top}` })
352
+ out.push({ id: 'approval', ms: allowed.map(callMs).reduce((a, b) => a + b, 0), estimate: false, text: `waiting for you to allow ${allowed.length} call${allowed.length === 1 ? '' : 's'}, in the main sessions and in the lanes${top === '' ? '' : `: ${top}`}` })
118
353
  }
119
354
  const bgRuns = bash.filter((c) => c.bg)
120
355
  if (bgRuns.length > 0) {
@@ -199,7 +434,7 @@ function rowsBy(calls: { c: Closed; key: string }[], retriesByKey: Map<string, {
199
434
  row.failed++
200
435
  row.failedMs += d
201
436
  }
202
- if (c.outcome === 'timeout') row.timeouts++
437
+ if (c.limited) row.timeouts++
203
438
  if (c.outcome === 'blocked' || c.outcome === 'denied') row.blocked++
204
439
  }
205
440
  const sorted = timed.sort((a, b) => a - b)
@@ -208,13 +443,14 @@ function rowsBy(calls: { c: Closed; key: string }[], retriesByKey: Map<string, {
208
443
  }).sort((a, b) => b.ms - a.ms || b.calls - a.calls)
209
444
  }
210
445
 
211
- export function buildReport(loaded: Loaded, q: { repos: string[]; from: number | null; to: number; repoOf: (project: string) => string }, mask: Masker): TimeReport {
446
+ export function buildReport(loaded: Loaded, q: { repos: string[]; from: number | null; to: number; repoOf: (project: string) => string; hookMatchers?: Map<string, string> }, mask: Masker): TimeReport {
212
447
  const from = q.from ?? -Infinity
213
448
  const groups = mergeStreams(loaded)
214
449
  const accounts = new Set<string>()
215
450
  const wall = emptyBreakdown()
216
451
  let subagentWork = 0
217
- const all: { c: Closed; g: Group }[] = []
452
+ /** `tm`: the model time of the turn that wrote the call, its share of it */
453
+ const all: { c: Closed; g: Group; tm: number }[] = []
218
454
  const retryShape = new Map<string, { retried: number; blind: number }>()
219
455
  const sessionRows: SessionRow[] = []
220
456
  const subsBySession = new Map<string, number>()
@@ -228,20 +464,32 @@ export function buildReport(loaded: Loaded, q: { repos: string[]; from: number |
228
464
  const runCalls: number[] = []
229
465
  const turnRows: TurnRow[] = []
230
466
  const readCosts = new Map<string, ReadCost>()
467
+ const days = new Map<number, DayRow>()
468
+ const laneRepos = new Map<string, LaneRepo>()
469
+ const mainTurnList: Turn[] = []
470
+ const subTurnList: Turn[] = []
231
471
 
472
+ // when each session's lanes were at work: a wait of a main session is on background work only while one was
473
+ const laneWork = lanesAtWork(groups, q.to)
232
474
  for (const g of groups) {
475
+ const lanes = g.agent === '' ? (laneWork.get(g.session) ?? []) : undefined
233
476
  for (const f of g.files) accounts.add(f.account)
234
477
  const turnModel = new Float64Array(g.closed.length)
235
- const b = wallBreakdown(g.stream, from, q.to, IDLE_MS, g.closed, turnModel)
478
+ const b = wallBreakdown(g.stream, from, q.to, IDLE_MS, g.closed, turnModel, lanes)
236
479
  const t = turnsOf(g.closed, b.model, turnModel, readCosts)
237
480
  const work = running(b)
238
- if (t.calls > 0) turnRows.push({ session: g.session, agent: g.agent, account: g.files[0]?.account ?? '', start: g.closed[0]?.start ?? 0, work: b.model + b.tools + b.approval, wall: work, turns: t })
481
+ const repo = q.repoOf(g.files[0]?.project ?? '')
482
+ if (t.calls > 0) turnRows.push({ session: g.session, agent: g.agent, account: g.files[0]?.account ?? '', repo, start: g.closed[0]?.start ?? 0, work: b.model + b.tools + b.approval, wall: work, turns: t })
239
483
  if (g.agent === '') addTurns(mainTurns, t)
240
484
  else {
241
485
  addTurns(subTurns, t)
242
486
  addBreakdown(subWork, b)
243
487
  runWalls.push(work)
244
488
  runCalls.push(t.calls)
489
+ const lr = laneRepos.get(repo) ?? { repo, runs: 0, work: 0 }
490
+ lr.runs++
491
+ lr.work += work
492
+ laneRepos.set(repo, lr)
245
493
  }
246
494
  if (g.agent === '') {
247
495
  addBreakdown(wall, b)
@@ -249,7 +497,7 @@ export function buildReport(loaded: Loaded, q: { repos: string[]; from: number |
249
497
  sessionRows.push({
250
498
  session: g.session,
251
499
  account: g.files[0]?.account ?? '',
252
- repo: q.repoOf(g.files[0]?.project ?? ''),
500
+ repo,
253
501
  start: [...g.stream.marks.map((m) => m.at), ...g.stream.calls.map((c) => c.start)].reduce((a, b) => (b < a ? b : a), Infinity),
254
502
  wall: b,
255
503
  calls: g.stream.calls.length,
@@ -257,7 +505,29 @@ export function buildReport(loaded: Loaded, q: { repos: string[]; from: number |
257
505
  first: firstPrompt == null ? '' : mask(firstPrompt.text.replace(/\s+/g, ' ').slice(0, 70)),
258
506
  })
259
507
  } else subagentWork += work
260
- for (const c of g.closed) all.push({ c, g })
508
+ g.closed.forEach((c, i) => all.push({ c, g, tm: turnModel[i] ?? 0 }))
509
+ // one turn per model message: its calls share the message, its model time is the sum of their shares
510
+ const turnOf = new Map<string, Turn>()
511
+ g.closed.forEach((c, i) => {
512
+ const key = c.msg == null || c.msg === '' ? c.id : c.msg
513
+ const t = turnOf.get(key) ?? { model: c.model, ctx: c.ctx, out: c.out, ms: 0, calls: 0 }
514
+ t.ms += turnModel[i] ?? 0
515
+ t.calls++
516
+ turnOf.set(key, t)
517
+ })
518
+ for (const t of turnOf.values()) (g.agent === '' ? mainTurnList : subTurnList).push(t)
519
+ // the same wall cut again day by day, so a session that runs for days gives each day its own share
520
+ const span = spanOf(g)
521
+ if (span != null) {
522
+ const end = Math.min(span.end, q.to)
523
+ for (let d = startOfDay(Math.max(span.start, from)); d <= end; d = startOfDay(d + DAY_AND_A_BIT)) {
524
+ const next = startOfDay(d + DAY_AND_A_BIT)
525
+ const row = dayRow(days, d)
526
+ addBreakdown(g.agent === '' ? row.main : row.sub, wallBreakdown(g.stream, Math.max(d, from), Math.min(next, q.to), IDLE_MS, g.closed, undefined, lanes, q.to))
527
+ for (const c of g.closed) if (c.start >= d && c.start < next && c.start >= from) row.calls++
528
+ if (g.agent !== '' && span.start >= d && span.start < next) row.runs++
529
+ }
530
+ }
261
531
  for (const r of retries(g.closed)) {
262
532
  const x = retryShape.get(shapeKey(r.failed)) ?? { retried: 0, blind: 0 }
263
533
  x.retried++
@@ -270,7 +540,31 @@ export function buildReport(loaded: Loaded, q: { repos: string[]; from: number |
270
540
  const shapes = rowsBy(all.filter(({ c }) => c.tool !== 'Agent' && c.tool !== 'Task').map(({ c }) => ({ c, key: shapeKey(c) })), retryShape)
271
541
  // the Bash shapes first: they are the commands; other tools stay in the table
272
542
  shapes.sort((a, b) => b.ms - a.ms)
273
- const tools = rowsBy(all.map(({ c }) => ({ c, key: c.tool })), new Map())
543
+ const tools = rowsBy(all.map(({ c }) => ({ c, key: shapeKey({ shape: c.tool, bg: c.bg }) })), new Map())
544
+ /** the script a `<file>` call ran, masked; null for any other shape */
545
+ const nameOf = (c: Closed): string | null => (c.tool === 'Bash' && c.shape.includes(FILE_MARK) ? mask(scriptOf(c.shape, c.cmd) ?? '(not named)') : null)
546
+ const scriptCalls = new Map<string, { c: Closed; key: string }[]>()
547
+ for (const { c } of bash) if (c.shape.includes(FILE_MARK)) pushTo(scriptCalls, shapeKey(c), { c, key: nameOf(c) ?? '(not named)' })
548
+ const scripts = Object.fromEntries([...scriptCalls].map(([k, cs]) => {
549
+ const rows = rowsBy(cs, new Map())
550
+ const rest = rows.slice(TOP_SCRIPTS)
551
+ // the scripts past the ten largest are one row: its calls and its time, no figure per call
552
+ const others: ShapeRow[] = rest.length === 0 ? [] : [{ ...(rest[0] as ShapeRow), shape: `${rest.length.toLocaleString('en-US')} other scripts`, calls: rest.reduce((a, r) => a + r.calls, 0), ms: rest.reduce((a, r) => a + r.ms, 0), failed: rest.reduce((a, r) => a + r.failed, 0), failedMs: rest.reduce((a, r) => a + r.failedMs, 0), blocked: 0, timeouts: 0, noEnd: 0, p50: 0, p95: 0, max: 0 }]
553
+ return [k, [...rows.slice(0, TOP_SCRIPTS), ...others]]
554
+ }))
555
+ // a call that waited for his allow is a wait on him, never the floor of a call
556
+ const instant = bash.filter(({ c }) => !c.bg && !c.open && !c.approval && c.perm !== 'user' && INSTANT.has(c.shape))
557
+ const instantMs = instant.map(({ c }) => callMs(c)).sort((a, b) => a - b)
558
+ const dayOf = (at: number): string => { const d = new Date(at); return `${d.getFullYear()}-${`${d.getMonth() + 1}`.padStart(2, '0')}-${`${d.getDate()}`.padStart(2, '0')}` }
559
+ const overhead: Overhead = {
560
+ calls: instant.length,
561
+ p50: quantileSorted(instantMs, 0.5),
562
+ p95: quantileSorted(instantMs, 0.95),
563
+ byRepo: rowsBy(instant.map(({ c, g }) => ({ c, key: q.repoOf(g.files[0]?.project ?? '') })), new Map()).sort((a, b) => b.calls - a.calls),
564
+ byPerm: rowsBy(instant.map(({ c }) => ({ c, key: c.perm === '' ? 'not recorded' : c.perm })), new Map()).sort((a, b) => b.calls - a.calls),
565
+ byDay: rowsBy(instant.map(({ c }) => ({ c, key: dayOf(c.start) })), new Map()).sort((a, b) => a.shape.localeCompare(b.shape)),
566
+ }
567
+ const families = rowsBy(bash.map(({ c }) => ({ c, key: shapeKey({ shape: familyOf(c.shape), bg: c.bg }) })), new Map())
274
568
  const slowest: SlowCall[] = topBy(bash, 40, ({ c }) => runMs(c) ?? callMs(c))
275
569
  .map(({ c, g }) => ({ ms: runMs(c) ?? callMs(c), shape: shapeKey(c), cmd: mask(c.cmd.replace(/\s+/g, ' ').slice(0, 120)), at: c.start, account: g.files[0]?.account ?? '', session: g.session, agent: g.agent !== '', outcome: c.outcome, open: c.open }))
276
570
 
@@ -319,6 +613,8 @@ export function buildReport(loaded: Loaded, q: { repos: string[]; from: number |
319
613
  const queued = kept.filter((p) => p.origin === 'queued').length
320
614
 
321
615
  const mains = groups.filter((g) => g.agent === '')
616
+ const hooks = hookRowsOf(loaded.hooks, all.map(({ c, g }) => ({ project: g.files[0]?.project ?? '', tool: c.tool, start: c.start, end: c.end })), q.hookMatchers ?? new Map(), mask, q.repoOf)
617
+ const hookLine = hookInsight(hooks)
322
618
  return {
323
619
  repos: q.repos,
324
620
  from: q.from,
@@ -333,6 +629,19 @@ export function buildReport(loaded: Loaded, q: { repos: string[]; from: number |
333
629
  callMs: all.reduce((a, { c }) => a + callMs(c), 0),
334
630
  shapes,
335
631
  tools,
632
+ families,
633
+ lanesByRepo: [...laneRepos.values()].sort((a, b) => b.work - a.work),
634
+ scripts,
635
+ overhead,
636
+ models: { main: turnCuts(mainTurnList), sub: turnCuts(subTurnList) },
637
+ refused: refusedOf(
638
+ all
639
+ .filter(({ c }) => c.outcome === 'blocked' || c.outcome === 'denied')
640
+ .map(({ c, g, tm }) => {
641
+ const why = refusalOf(c.outcome, c.why ?? '')
642
+ return { at: c.start, repo: q.repoOf(g.files[0]?.project ?? ''), session: g.session, agent: g.agent !== '', tool: c.tool, shape: c.shape, script: nameOf(c), cmd: mask(c.cmd.replace(/\s+/g, ' ').slice(0, 240)), by: why.by, name: mask(/^command hook/.test(why.name) ? `${why.name}, ${q.repoOf(g.files[0]?.project ?? '')}` : why.name), reason: mask(why.reason.slice(0, 300)), ms: tm }
643
+ }),
644
+ ),
336
645
  slowest,
337
646
  feedback: { prompts, queued, counts, rules, hits },
338
647
  sessionRows: sessionRows.sort((a, b) => total(b.wall, false) - total(a.wall, false)),
@@ -342,7 +651,24 @@ export function buildReport(loaded: Loaded, q: { repos: string[]; from: number |
342
651
  rows: topBy(turnRows, 200, (r) => r.work),
343
652
  reads: [...readCosts.values()].sort((a, b) => b.model - a.model),
344
653
  },
345
- insights: insightsOf(all.map(({ c }) => c), wall, shapes),
654
+ insights: [...insightsOf(all.map(({ c }) => c), shapes), ...(hookLine == null ? [] : [hookLine])].sort((a, b) => b.ms - a.ms),
655
+ hooks,
656
+ days: [...days.values()].sort((x, y) => x.at - y.at),
657
+ timeouts: all
658
+ .filter(({ c }) => c.limited)
659
+ .sort((x, y) => y.c.start - x.c.start)
660
+ .map(({ c, g }) => ({
661
+ at: c.start,
662
+ repo: q.repoOf(g.files[0]?.project ?? ''),
663
+ session: g.session,
664
+ agent: g.agent !== '',
665
+ shape: c.shape,
666
+ script: nameOf(c),
667
+ cmd: mask(c.cmd.replace(/\s+/g, ' ').slice(0, 240)),
668
+ limitMs: Math.max(0, (c.end ?? c.start) - c.start),
669
+ after: c.bgEnd == null ? 'none' : c.outcome == null || c.outcome === 'ok' ? 'ok' : c.outcome === 'interrupted' ? 'stopped' : 'failed',
670
+ totalMs: c.bgEnd == null ? null : Math.max(0, c.bgEnd - c.start),
671
+ })),
346
672
  }
347
673
  }
348
674
 
@@ -8,7 +8,7 @@
8
8
  // check is slow.
9
9
 
10
10
  /** bumped with any rule below: the index shapes every stored call again */
11
- export const SHAPE_VERSION = 4
11
+ export const SHAPE_VERSION = 6
12
12
 
13
13
  /** programs whose first word is never a subcommand */
14
14
  const NO_SUBCOMMAND = new Set([
@@ -138,13 +138,31 @@ const isLight = (w: string[]): boolean => LIGHT.has(w[0] as string) && (w[0] !==
138
138
  const PY_EDIT = /\bpython3?\s+-\s*<</
139
139
  const PY_WRITES = /open\([^)]*,\s*['"][wa]|\.write(?:_text)?\(/
140
140
 
141
+ /** inline code that writes a file: an edit through Bash too */
142
+ const JS_WRITES = /Bun\.write\(|writeFileSync\(|writeFile\(|appendFileSync\(/
143
+
141
144
  /** the shape of one Bash command line */
142
145
  export function commandShape(command: string): string {
143
146
  const stmts = statements(command.trim()).map(wordsOf).filter((w) => w.length > 0)
144
147
  if (stmts.length === 0) return '(empty)'
145
148
  const shape = pick(stmts) ?? (base(stmts[0]?.[0] ?? '') || '(empty)')
146
- if (shape.startsWith('python') && !shape.includes(' ') && PY_EDIT.test(command) && PY_WRITES.test(command)) return `${shape} (edit)`
147
- return shape
149
+ let out = shape
150
+ if (shape.startsWith('python') && !shape.includes(' ') && PY_EDIT.test(command) && PY_WRITES.test(command)) out = `${shape} (edit)`
151
+ else if (shape.endsWith(' -e') && JS_WRITES.test(command)) out = `${shape} (edit)`
152
+ // before the kind suffix, so `sed -i (+ more) (edit)` still ends in (edit)
153
+ return !shape.startsWith('(') && stmts.filter(isHeavy).length > 1 ? out.replace(/( \((?:edit|write)\))?$/, `${MORE}$1`) : out
154
+ }
155
+
156
+ /** a line that runs more than one real statement: its time is all of them, never its first command's alone, so
157
+ * `bun check; bun run remote …` never counts as a slow `bun check` */
158
+ export const MORE = ' (+ more)'
159
+
160
+ /** the shape with the line marker dropped: what kind of command it is, for a family or an insight */
161
+ export const kindOf = (shape: string): string => shape.replace(MORE, '')
162
+
163
+ const isHeavy = (w: string[]): boolean => {
164
+ const head = w[0] as string
165
+ return !SETUP.has(head) && !['do', 'done', 'then', 'fi', 'else'].includes(head) && !isLight(w)
148
166
  }
149
167
 
150
168
  /** the statement the time belongs to, shaped: loops by what they run */
@@ -206,6 +224,8 @@ function shapeOfWords(input: string[]): string {
206
224
  rest = rest.slice(pkg + 1)
207
225
  }
208
226
  }
227
+ // inline code is no file: `bun -e "…"` is its own shape, whatever the code holds
228
+ if ((program === 'bun' || program === 'node' || program === 'deno') && (rest[0] === '-e' || rest[0] === '--eval' || rest[0] === '-p' || rest[0] === '--print')) return `${program} -e`
209
229
  if (program.startsWith('python')) {
210
230
  if (rest[0] === '-c' || rest[0] === '-m') return `${program} ${rest[0]}${rest[0] === '-m' && rest[1] != null ? ` ${rest[1]}` : ''}`
211
231
  return rest.some((w) => isPathLike(w)) ? `${program} <file>` : program
@@ -269,3 +289,30 @@ export function toolShape(name: string, detail: string): string {
269
289
  if (name === 'Skill' && detail !== '') return `Skill ${detail}`
270
290
  return name
271
291
  }
292
+
293
+ /** a shape that stands for many scripts: `bun <file>`, `(for) bash <file>` */
294
+ export const FILE_MARK = '<file>'
295
+
296
+ /** the file a `<file>` shape ran, so the shape opens on its scripts: the first path the shape's
297
+ * program is given in the command. A session's scratch folder and the temp roots are one name
298
+ * each (their paths change per session), the home folder is `~` */
299
+ export function scriptOf(shape: string, command: string): string | null {
300
+ const at = shape.indexOf(FILE_MARK)
301
+ if (at <= 0) return null
302
+ const program = shape.slice(0, at).trim().split(/[\s(]+/).pop() ?? ''
303
+ if (!/^[\w.-]+$/.test(program)) return null
304
+ const text = stripHeredocs(command)
305
+ const re = new RegExp(`(?:^|[\\s;&|(/])${program.replace(/[.]/g, '\\.')}\\s+((?:-{1,2}[\\w-]+(?:=\\S+)?\\s+)*)(?:"([^"]+)"|'([^']+)'|([^\\s;&|<>)]+))`, 'g')
306
+ for (const m of text.matchAll(re)) {
307
+ const file = m[2] ?? m[3] ?? m[4] ?? ''
308
+ if (isPathLike(file) && !/\s/.test(file) && file.length <= 160) return placeOf(file)
309
+ }
310
+ return null
311
+ }
312
+
313
+ const placeOf = (file: string): string =>
314
+ file
315
+ .replace(/^(?:\/private)?\/tmp\/claude-\d+\/[^/]+\/[^/]+\/scratchpad\//, '<scratchpad>/')
316
+ .replace(/^(?:\/private)?\/var\/folders\/[^/]+\/[^/]+\/T\//, '<tmp>/')
317
+ .replace(/^(?:\/private)?\/tmp\//, '<tmp>/')
318
+ .replace(/^\/Users\/[^/]+\//, '~/')