rvlib-shipkit 2.26.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 (442) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +1 -1
  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 +6 -4
  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 +122 -21
  11. package/src/agent-time/report-cache.ts +57 -0
  12. package/src/agent-time/report.ts +314 -40
  13. package/src/agent-time/shape.ts +50 -3
  14. package/src/agent-time/store.ts +320 -99
  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/SK047-login-in-description.check.ts +36 -0
  34. package/src/checks/SK048-one-local-file.check.ts +36 -0
  35. package/src/cli/cmd_Asks.ts +71 -5
  36. package/src/cli/cmd_Backup.ts +2 -2
  37. package/src/cli/cmd_Capacity.ts +2 -2
  38. package/src/cli/cmd_CrossRepoActivity.ts +5 -4
  39. package/src/cli/cmd_Db.ts +253 -0
  40. package/src/cli/cmd_History.ts +212 -0
  41. package/src/cli/cmd_Home.ts +31 -3
  42. package/src/cli/cmd_Hq.ts +516 -0
  43. package/src/cli/cmd_Machines.ts +36 -0
  44. package/src/cli/cmd_Media.ts +38 -6
  45. package/src/cli/cmd_Reflect.ts +23 -2
  46. package/src/cli/cmd_Review.ts +548 -116
  47. package/src/cli/cmd_Secret.ts +62 -12
  48. package/src/cli/cmd_Social.ts +83 -1
  49. package/src/cli/cmd_Space.ts +324 -0
  50. package/src/cli/cmd_Time.ts +76 -5
  51. package/src/cli/cmd_Tmp.ts +28 -4
  52. package/src/cli/cmd_Trailer.ts +14 -10
  53. package/src/cli/cmd_Urls.ts +56 -0
  54. package/src/cli/cmd_Vault.ts +583 -0
  55. package/src/cli/family-help.ts +4 -2
  56. package/src/cli/family-pages.ts +1 -1
  57. package/src/cli/registry.ts +24 -3
  58. package/src/collections/actions.ts +63 -13
  59. package/src/collections/collection-types.ts +23 -1
  60. package/src/collections/providers.ts +117 -23
  61. package/src/collections/review.ts +4 -4
  62. package/src/contracts/contract-manifests.ts +6 -5
  63. package/src/contracts/contract-types.ts +6 -4
  64. package/src/contracts/contracts-engine.ts +11 -0
  65. package/src/contracts/manifests/chrome-web-store.contract.ts +31 -0
  66. package/src/core/budget.ts +12 -17
  67. package/src/core/capacity.ts +27 -18
  68. package/src/core/check-runner.ts +7 -4
  69. package/src/core/layout.ts +3 -0
  70. package/src/core/machine-busy.ts +127 -0
  71. package/src/core/machine-commit.ts +6 -1
  72. package/src/core/machine-db.ts +368 -20
  73. package/src/core/machine-layout.ts +137 -0
  74. package/src/core/machine-read.ts +81 -0
  75. package/src/core/migrate-layout.ts +1 -1
  76. package/src/core/one-way-in-policy.ts +64 -7
  77. package/src/core/polling-policy.ts +27 -0
  78. package/src/core/retention.ts +16 -2
  79. package/src/core/scope.ts +107 -14
  80. package/src/core/slots.ts +5 -4
  81. package/src/drill/clean.ts +25 -1
  82. package/src/drill/run.ts +1 -1
  83. package/src/drill/seal.ts +27 -4
  84. package/src/home/activity-shape.ts +2 -0
  85. package/src/home/activity.ts +66 -3
  86. package/src/home/app-sign.ts +15 -4
  87. package/src/home/daemon-jobs.ts +149 -7
  88. package/src/home/database-projects.ts +111 -0
  89. package/src/home/database-words.ts +203 -0
  90. package/src/home/databases.ts +460 -0
  91. package/src/home/global-units.ts +6 -0
  92. package/src/home/gui-app/ShipkitGui.swift +122 -1
  93. package/src/home/gui-app.ts +6 -3
  94. package/src/home/home-move.ts +514 -0
  95. package/src/home/home-paths.ts +12 -3
  96. package/src/home/home-routes.ts +68 -0
  97. package/src/home/inbox-shape.ts +24 -14
  98. package/src/home/machine-fold.ts +820 -0
  99. package/src/home/machine-host.ts +20 -5
  100. package/src/home/machine-repair.ts +503 -0
  101. package/src/home/machine-stores.ts +66 -15
  102. package/src/home/machine-temp.ts +547 -86
  103. package/src/home/resume.ts +79 -0
  104. package/src/home/run-daemon.ts +25 -4
  105. package/src/home/run-pm.ts +18 -5
  106. package/src/home/serve-daemon.ts +18 -3
  107. package/src/home/serve-web.ts +175 -7
  108. package/src/home/space-job.ts +115 -0
  109. package/src/home/space-page.ts +257 -0
  110. package/src/home/space-route.ts +167 -0
  111. package/src/home/space-words.ts +103 -0
  112. package/src/home/time-page-shape.ts +202 -0
  113. package/src/home/time-page.ts +64 -0
  114. package/src/home/vault-page.ts +482 -0
  115. package/src/home/vault-words.ts +132 -0
  116. package/src/hooks/leak-guard.ts +40 -13
  117. package/src/hooks/one-way-in-guard.ts +17 -4
  118. package/src/hq/cards.ts +581 -0
  119. package/src/hq/door-route.ts +43 -0
  120. package/src/hq/door.ts +163 -0
  121. package/src/hq/files-send.ts +348 -0
  122. package/src/hq/forgotten-log.ts +35 -0
  123. package/src/hq/history-check.ts +255 -0
  124. package/src/hq/history-place.ts +146 -0
  125. package/src/hq/history-send.ts +487 -0
  126. package/src/hq/hq-db.ts +99 -0
  127. package/src/hq/hq-local.ts +469 -0
  128. package/src/hq/hq-routes.ts +196 -0
  129. package/src/hq/hq-store.ts +599 -0
  130. package/src/hq/kinds/ask.ts +147 -0
  131. package/src/hq/kinds/card-gone.ts +83 -0
  132. package/src/hq/kinds/card-msg.ts +66 -0
  133. package/src/hq/kinds/card.ts +99 -0
  134. package/src/hq/kinds/index.ts +21 -0
  135. package/src/hq/kinds/kind.ts +126 -0
  136. package/src/hq/kinds/media.ts +125 -0
  137. package/src/hq/kinds/prompt.ts +219 -0
  138. package/src/hq/kinds/reflection.ts +128 -0
  139. package/src/hq/kinds/report.ts +55 -0
  140. package/src/hq/kinds/time-day.ts +236 -0
  141. package/src/hq/ledger.ts +473 -0
  142. package/src/hq/machine-key.ts +44 -0
  143. package/src/hq/machine-notes.ts +131 -0
  144. package/src/hq/outbox.ts +372 -0
  145. package/src/hq/replica.ts +168 -0
  146. package/src/hq/repo-id.ts +4 -0
  147. package/src/hq/report-facts.ts +117 -0
  148. package/src/hq/report.ts +274 -0
  149. package/src/hq/switch.ts +151 -0
  150. package/src/hq/vault-grant.ts +92 -0
  151. package/src/identities/identities.ts +15 -3
  152. package/src/identities/steps.ts +31 -0
  153. package/src/ledger/db.ts +73 -26
  154. package/src/ledger/gate-checks.ts +6 -2
  155. package/src/ledger/run-log.ts +11 -3
  156. package/src/ledger/store.ts +26 -4
  157. package/src/media-store/backup/daemon.ts +25 -17
  158. package/src/media-store/backup/kept.ts +241 -0
  159. package/src/media-store/backup/restore.ts +14 -4
  160. package/src/media-store/backup/run.ts +11 -11
  161. package/src/media-store/backup/secret.ts +6 -4
  162. package/src/media-store/backup/snapshot.ts +4 -2
  163. package/src/media-store/backup/sources.ts +67 -16
  164. package/src/media-store/copy/config.ts +77 -0
  165. package/src/media-store/copy/copy.ts +194 -0
  166. package/src/media-store/copy/lifecycle.ts +43 -0
  167. package/src/media-store/copy/night.ts +90 -0
  168. package/src/media-store/copy/proof.ts +151 -0
  169. package/src/media-store/copy/snapshot.ts +152 -0
  170. package/src/media-store/copy/store.ts +62 -0
  171. package/src/media-store/copy/stream.ts +176 -0
  172. package/src/media-store/daemon.ts +66 -16
  173. package/src/media-store/db.ts +22 -11
  174. package/src/media-store/forget.ts +23 -3
  175. package/src/media-store/hand.ts +4 -3
  176. package/src/media-store/hq-find.ts +75 -0
  177. package/src/media-store/hq-send.ts +277 -0
  178. package/src/media-store/kind.ts +2 -0
  179. package/src/media-store/purge.ts +18 -15
  180. package/src/media-store/put.ts +24 -8
  181. package/src/media-store/remote.ts +16 -7
  182. package/src/media-store/space-listing.ts +240 -0
  183. package/src/media-store/space.ts +40 -21
  184. package/src/media-store/sync.ts +5 -5
  185. package/src/media-store/tidy.ts +98 -0
  186. package/src/media-store/upload.ts +3 -3
  187. package/src/media-store/webp.ts +66 -0
  188. package/src/messages/model.ts +16 -7
  189. package/src/messages/routes.ts +14 -4
  190. package/src/messages/score.ts +2 -2
  191. package/src/messages/suggest.ts +96 -0
  192. package/src/pages/frame-client.ts +10 -0
  193. package/src/plan/planner.ts +28 -17
  194. package/src/recordings/media-kind.ts +1 -0
  195. package/src/recordings/model.ts +1 -1
  196. package/src/recordings/recorder-app/Capture.swift +9 -7
  197. package/src/reflect/hq-corpus.ts +56 -0
  198. package/src/reflect/prompt-corpus.ts +3 -1
  199. package/src/reflect/transcript.ts +129 -37
  200. package/src/release/machine-words.ts +67 -0
  201. package/src/release/public-clean.ts +8 -3
  202. package/src/releases/from-card.ts +1 -1
  203. package/src/releases/routes.ts +10 -5
  204. package/src/releases/store.ts +10 -1
  205. package/src/repo-config.ts +32 -2
  206. package/src/review/anim.ts +2 -2
  207. package/src/review/auto.ts +2 -2
  208. package/src/review/card-db.ts +244 -0
  209. package/src/review/card-rows.ts +266 -0
  210. package/src/review/cells.ts +76 -5
  211. package/src/review/draft-card.ts +41 -0
  212. package/src/review/draft-model.ts +78 -0
  213. package/src/review/format.ts +29 -10
  214. package/src/review/gone.ts +98 -0
  215. package/src/review/inbox-hook.ts +4 -4
  216. package/src/review/marks.ts +1 -1
  217. package/src/review/media-kind.ts +7 -5
  218. package/src/review/media-read.ts +9 -7
  219. package/src/review/media.ts +32 -5
  220. package/src/review/model.ts +202 -39
  221. package/src/review/move.ts +491 -0
  222. package/src/review/notes.ts +12 -20
  223. package/src/review/previews.ts +15 -19
  224. package/src/review/project.ts +1 -1
  225. package/src/review/rev.ts +8 -0
  226. package/src/review/role.ts +1 -1
  227. package/src/review/routes.ts +64 -13
  228. package/src/review/stage-card.ts +8 -4
  229. package/src/review/stage-routes.ts +1 -1
  230. package/src/review/store.ts +529 -83
  231. package/src/review/thread-fold.ts +51 -0
  232. package/src/review/threads.ts +147 -9
  233. package/src/review/trailer-auto-mock.ts +63 -0
  234. package/src/review/trailer-card.ts +4 -4
  235. package/src/review/trailer-desk.ts +41 -7
  236. package/src/review/trailer-media.ts +1 -0
  237. package/src/review/trailer-model.ts +8 -0
  238. package/src/review/trailer-notes.ts +1 -1
  239. package/src/review/trailer-routes.ts +9 -1
  240. package/src/review/unit.ts +6 -6
  241. package/src/review/watchers.ts +1 -1
  242. package/src/rules/untrack-generated.ts +92 -8
  243. package/src/secrets/held.ts +16 -0
  244. package/src/secrets/keychain.ts +113 -0
  245. package/src/secrets/list.ts +16 -6
  246. package/src/secrets/manager.ts +24 -10
  247. package/src/secrets/read.ts +257 -0
  248. package/src/secrets/who-reads.ts +49 -0
  249. package/src/serve/door-forward.ts +268 -0
  250. package/src/serve/door-names.ts +47 -0
  251. package/src/serve/embed.ts +1 -1
  252. package/src/serve/hub-app/activity-view.tsx +56 -32
  253. package/src/serve/hub-app/activity.css +7 -1
  254. package/src/serve/hub-app/asks-page.tsx +48 -0
  255. package/src/serve/hub-app/asks-st.ts +25 -0
  256. package/src/serve/hub-app/clock-svc.ts +1 -2
  257. package/src/serve/hub-app/col-card.tsx +64 -13
  258. package/src/serve/hub-app/col-list-page.tsx +122 -0
  259. package/src/serve/hub-app/col-list-st.ts +103 -0
  260. package/src/serve/hub-app/col-tables-view.tsx +10 -41
  261. package/src/serve/hub-app/col-tables.ts +76 -8
  262. package/src/serve/hub-app/cols-svc.ts +70 -16
  263. package/src/serve/hub-app/database-st.ts +260 -0
  264. package/src/serve/hub-app/database-view.tsx +289 -0
  265. package/src/serve/hub-app/database.css +32 -0
  266. package/src/serve/hub-app/entry-bar.css +14 -0
  267. package/src/serve/hub-app/entry-bar.tsx +33 -0
  268. package/src/serve/hub-app/entry-pick.ts +31 -0
  269. package/src/serve/hub-app/floating.tsx +1 -0
  270. package/src/serve/hub-app/hash-route.ts +11 -1
  271. package/src/serve/hub-app/header-bar.tsx +14 -18
  272. package/src/serve/hub-app/home-st.ts +89 -9
  273. package/src/serve/hub-app/home-strip.css +5 -19
  274. package/src/serve/hub-app/home-strip.tsx +58 -92
  275. package/src/serve/hub-app/home.html +7 -0
  276. package/src/serve/hub-app/hub-app.tsx +31 -142
  277. package/src/serve/hub-app/hub-types.ts +3 -1
  278. package/src/serve/hub-app/hub.css +109 -23
  279. package/src/serve/hub-app/icons.tsx +18 -1
  280. package/src/serve/hub-app/identities-st.ts +56 -6
  281. package/src/serve/hub-app/identities-view.tsx +100 -58
  282. package/src/serve/hub-app/identities.css +17 -15
  283. package/src/serve/hub-app/identity-address.ts +5 -0
  284. package/src/serve/hub-app/inbox-st.ts +41 -24
  285. package/src/serve/hub-app/inbox-view.tsx +37 -41
  286. package/src/serve/hub-app/inbox.css +2 -5
  287. package/src/serve/hub-app/index.html +7 -0
  288. package/src/serve/hub-app/kept-cols.tsx +7 -0
  289. package/src/serve/hub-app/keys.ts +28 -15
  290. package/src/serve/hub-app/later.tsx +26 -0
  291. package/src/serve/hub-app/list-filter.tsx +14 -0
  292. package/src/serve/hub-app/list-walk.ts +72 -3
  293. package/src/serve/hub-app/machines-st.ts +251 -0
  294. package/src/serve/hub-app/machines-view.tsx +224 -0
  295. package/src/serve/hub-app/machines.css +76 -0
  296. package/src/serve/hub-app/md-copy.tsx +79 -0
  297. package/src/serve/hub-app/media-view.tsx +2 -0
  298. package/src/serve/hub-app/messages/messages-page.tsx +79 -7
  299. package/src/serve/hub-app/messages/messages-st.ts +99 -3
  300. package/src/serve/hub-app/messages.css +14 -0
  301. package/src/serve/hub-app/page-keys.ts +175 -0
  302. package/src/serve/hub-app/pages-frames.tsx +11 -3
  303. package/src/serve/hub-app/palette-st.ts +58 -11
  304. package/src/serve/hub-app/palette-view.tsx +3 -1
  305. package/src/serve/hub-app/project-list.css +54 -8
  306. package/src/serve/hub-app/project-list.tsx +128 -59
  307. package/src/serve/hub-app/projects-svc.ts +78 -7
  308. package/src/serve/hub-app/reader-chips.tsx +13 -0
  309. package/src/serve/hub-app/readme-view.tsx +2 -3
  310. package/src/serve/hub-app/readme.css +27 -5
  311. package/src/serve/hub-app/reflections-page.tsx +42 -0
  312. package/src/serve/hub-app/reflections-st.ts +17 -0
  313. package/src/serve/hub-app/releases/releases-page.tsx +25 -2
  314. package/src/serve/hub-app/releases/releases-st.ts +1 -1
  315. package/src/serve/hub-app/repo-sections.ts +9 -5
  316. package/src/serve/hub-app/repo-st.ts +35 -8
  317. package/src/serve/hub-app/review/draft-card.tsx +163 -0
  318. package/src/serve/hub-app/review/kit.tsx +50 -7
  319. package/src/serve/hub-app/review/note-place.ts +1 -1
  320. package/src/serve/hub-app/review/review-board.tsx +2 -2
  321. package/src/serve/hub-app/review/review-cells.tsx +145 -65
  322. package/src/serve/hub-app/review/review-kit.ts +27 -1
  323. package/src/serve/hub-app/review/review-list.tsx +68 -30
  324. package/src/serve/hub-app/review/review-page.tsx +7 -8
  325. package/src/serve/hub-app/review/review-st.ts +111 -24
  326. package/src/serve/hub-app/review/review-thread.tsx +49 -19
  327. package/src/serve/hub-app/review/review-views.tsx +475 -144
  328. package/src/serve/hub-app/review/thread-control-st.ts +115 -0
  329. package/src/serve/hub-app/review/thread-control.tsx +74 -0
  330. package/src/serve/hub-app/review/thread-st.ts +73 -26
  331. package/src/serve/hub-app/review/trailer-card.tsx +1 -1
  332. package/src/serve/hub-app/review/trailer-page.tsx +37 -16
  333. package/src/serve/hub-app/review/trailer-st.ts +41 -7
  334. package/src/serve/hub-app/review.css +267 -61
  335. package/src/serve/hub-app/side-lists.ts +72 -0
  336. package/src/serve/hub-app/sidebar.tsx +6 -3
  337. package/src/serve/hub-app/site/site-part.tsx +2 -8
  338. package/src/serve/hub-app/site/site-st.ts +4 -4
  339. package/src/serve/hub-app/social/comms-page.tsx +20 -5
  340. package/src/serve/hub-app/social/kit.tsx +30 -4
  341. package/src/serve/hub-app/social/post-card.tsx +139 -49
  342. package/src/serve/hub-app/social/serial-writes.ts +13 -0
  343. package/src/serve/hub-app/social/social-model.ts +11 -0
  344. package/src/serve/hub-app/social/social-page.tsx +94 -35
  345. package/src/serve/hub-app/social/social-st.ts +120 -36
  346. package/src/serve/hub-app/social/stage-popup.tsx +1 -1
  347. package/src/serve/hub-app/social/stage-st.ts +1 -1
  348. package/src/serve/hub-app/social/step-layout.ts +1 -1
  349. package/src/serve/hub-app/social.css +3 -0
  350. package/src/serve/hub-app/space-st.ts +209 -0
  351. package/src/serve/hub-app/space-view.tsx +196 -0
  352. package/src/serve/hub-app/space.css +27 -0
  353. package/src/serve/hub-app/stores/stores-page.tsx +91 -23
  354. package/src/serve/hub-app/stores/stores-st.ts +44 -19
  355. package/src/serve/hub-app/stores.css +6 -1
  356. package/src/serve/hub-app/theme-st.ts +22 -9
  357. package/src/serve/hub-app/time-charts.tsx +291 -0
  358. package/src/serve/hub-app/time-pages.tsx +749 -0
  359. package/src/serve/hub-app/time-st.ts +162 -0
  360. package/src/serve/hub-app/time-view.tsx +76 -0
  361. package/src/serve/hub-app/time.css +138 -0
  362. package/src/serve/hub-app/tree-build.ts +52 -42
  363. package/src/serve/hub-app/tree-row.tsx +4 -4
  364. package/src/serve/hub-app/tree-svc.ts +18 -9
  365. package/src/serve/hub-app/urls-svc.ts +154 -0
  366. package/src/serve/hub-app/urls-view.tsx +117 -0
  367. package/src/serve/hub-app/urls.css +30 -0
  368. package/src/serve/hub-app/vault-st.ts +127 -0
  369. package/src/serve/hub-app/vault-view.tsx +154 -0
  370. package/src/serve/hub-app/vault.css +38 -0
  371. package/src/serve/hub-app/veille/veille-st.ts +12 -10
  372. package/src/serve/hub-app/waiting-svc.ts +29 -0
  373. package/src/serve/hub-app/wikis-view.tsx +2 -2
  374. package/src/serve/hub-runtime.ts +15 -2
  375. package/src/serve/project-gutter-route.ts +27 -14
  376. package/src/serve/project-gutter.ts +25 -12
  377. package/src/serve/same-origin.ts +10 -0
  378. package/src/serve/serve-hub.ts +13 -4
  379. package/src/shipkit-files.ts +16 -2
  380. package/src/shipkit.ts +1 -1
  381. package/src/shot/shooter.ts +616 -420
  382. package/src/shot/shot-ask.ts +246 -155
  383. package/src/site/desk.ts +2 -2
  384. package/src/smoke/run-smoke.ts +3 -2
  385. package/src/social/cover.ts +202 -0
  386. package/src/social/discord-layout.ts +37 -13
  387. package/src/social/drafts.ts +3 -0
  388. package/src/social/load.ts +23 -2
  389. package/src/social/media-kind.ts +2 -1
  390. package/src/social/publish/discord.ts +5 -2
  391. package/src/social/publish/secret.ts +2 -2
  392. package/src/social/release-stage.ts +28 -13
  393. package/src/social/routes.ts +26 -1
  394. package/src/social/stage.ts +1 -1
  395. package/src/social/stats.ts +12 -9
  396. package/src/social/strip.ts +4 -1
  397. package/src/social/thumbnail.ts +255 -0
  398. package/src/stores/collection.ts +15 -11
  399. package/src/stores/desk.ts +236 -42
  400. package/src/stores/model.ts +72 -6
  401. package/src/stores/routes.ts +37 -12
  402. package/src/stores/unit.ts +14 -8
  403. package/src/suite/judge-suites.ts +41 -11
  404. package/src/suite/select.ts +45 -3
  405. package/src/suite/suite-cli.ts +16 -10
  406. package/src/trailer/bed.ts +1 -1
  407. package/src/trailer/build.ts +134 -21
  408. package/src/trailer/ffmpeg.ts +7 -0
  409. package/src/trailer/fonts.ts +3 -2
  410. package/src/trailer/grammar.ts +201 -2
  411. package/src/trailer/graph.ts +42 -5
  412. package/src/trailer/look.ts +21 -0
  413. package/src/trailer/mock.ts +154 -0
  414. package/src/trailer/passage.ts +65 -26
  415. package/src/trailer/score/heard.ts +89 -0
  416. package/src/trailer/score/sound.ts +14 -8
  417. package/src/trailer/sound/run.ts +16 -6
  418. package/src/trailer/stitch.ts +26 -5
  419. package/src/trailer/titles.ts +82 -19
  420. package/src/trailer/versions.ts +1 -3
  421. package/src/trailer/vertical.ts +3 -1
  422. package/src/urls/frame.ts +195 -0
  423. package/src/urls/routes.ts +43 -0
  424. package/src/urls/rows.ts +171 -0
  425. package/src/urls/unit.ts +73 -0
  426. package/src/vault/house-keys.ts +42 -0
  427. package/src/vault/layout.ts +50 -0
  428. package/src/vault/policy.ts +165 -0
  429. package/src/vault/vault-audit.ts +276 -0
  430. package/src/vault/vault-client.ts +40 -0
  431. package/src/vault/vault-config.ts +159 -0
  432. package/src/vault/vault-destroy.ts +78 -0
  433. package/src/vault/vault-handover.ts +305 -0
  434. package/src/vault/vault-http.ts +352 -0
  435. package/src/vault/vault-import.ts +208 -0
  436. package/src/vault/vault-init.ts +328 -0
  437. package/src/vault/vault-minter.ts +271 -0
  438. package/src/vault/vault-restore.ts +333 -0
  439. package/src/vault/vault-serve.ts +342 -0
  440. package/src/vault/vault-snapshot.ts +281 -0
  441. package/src/veille/asks.ts +1 -1
  442. package/src/veille/desk.ts +2 -2
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## 2.27.0
2
+
3
+ - **The hq: one place for every machine.** Every daemon carries an hq and reports to it (`sk machines`); another machine joins with `sk hq`. Review cards, asks, reflections, prompts and agent time days travel through it, each behind its own switch. `sk hq replicate` and `sk hq drill` keep a second copy and prove it.
4
+ - **The vault.** OpenBao runs under pm, its seal key in the login keychain. On its machine every read of a secret comes from it and every write goes to it. A scope names a machine and a repo. `sk vault init`, `import`, `compare`, `snapshot`, `restore`, `narrow` and `destroy`. A sealed snapshot is proved by a restore before it leaves, sent to the Space, and removed after 30 days once a newer one passed its proof.
5
+ - **One machine database.** The media index, the agent time index and the daemon's file fold into one store (`sk db fold`, and back). A damaged table costs only itself (`sk db drop`, `sk db repair`, `sk db rebuild`). A store keeps a copy of itself before its schema changes.
6
+ - **The home.** Pages for the machines, the databases, the vault, the Space and agent time. The pages move into a folding rail, with no top bar. One keyboard pattern for every side list. Two new themes, dim and grey. `sk home move` puts the machine's state under `~/.shipkit`.
7
+ - **Review cards as rows** of the machine database, behind a switch: `sk review move`, `--back`, `--tidy`, and a watch that hears a verdict in 50 ms. A verdict opens the next waiting card. The lightbox fills the window at the size you set. A draft card pins a post draft.
8
+ - **Threads.** One thread per subject for its whole life, at its own address. `sk thread` asks a question with its answers as buttons, proposes a change the owner applies in one click, and links what it is about. A watch follows whoever holds the thread. The hub has a threads page, and every object carries a thread control.
9
+ - **`sk time` sees more, and counts truer.** Foreground and background apart, Bash by family, turns by model and context size, the refused calls with the turns they wasted, the time limits hit, the scripts behind a `<file>` shape, a report kept 5 minutes, and a `/time` page in the home. A line of several commands is its own row, `<first> (+ more)`, so a fast command before a slow one never looks slow.
10
+ - **ONE WAY IN lets `bun test <file or folder>` run.** Only a whole suite run is refused, and SK013 replaces the old `Bash(bun test*)` deny row with the bare `Bash(bun test)`. The Bash guard also refuses a wait loop on `pgrep -f <name>`: loops that wait on the same name match each other and never end. It names `kill -0 <pid>` instead.
11
+ - **Urls.** A repo lists every url it has, dev and prod, on its own page, its logins as copy chips. A `/` in a label makes folders. The overview lists the urls of every repo.
12
+ - **Trailers.** A cut opens on its start image and ends on its end image (`thumbnail`, and `endcard` on a landscape cut, both required). `sk trailer --mock` plays the whole cut before its shots exist. A corner `watermark`. The score warns where a phone hears it fall away.
13
+ - **Social and stores.** `sk social thumbnail` makes every video's thumbnail from the brand. The Chrome Web Store joins the desk. The owner suggests messages and phrasings from the hub.
14
+ - **Asks.** The owner can decline an ask (`sk asks decline`), and a declined ask stays closed. A login's row carries its account beside the password.
15
+ - **Lanes and the gate read the cores really in use**, not the load alone: `sk capacity`, the slow checks, the suite judge and the slot pool.
16
+ - **Temp folders.** Each house repo's `.shipkit/tmp` joins the machine's temp sweep. A dry sweep names every unit it would take.
17
+ - **The Space.** A copy to a second place by stream, each object with its content type. `sk space` and `sk space ls`.
18
+ - **Checks.** SK035 refuses a machine of the owner in what a unit publishes. SK047 warns on a password in a process description. SK028 takes a README alone, with no screenshot.
19
+ - **Faster.** A media sender's first run of 91,125 objects in 5 s. Keychain calls without a 250 ms spawn timeout. A verdict given on another machine reaches a watch in about 7 s, not 60.
20
+
1
21
  ## 2.26.0
2
22
 
3
23
  - **A slow hook is refused.** SK045 fails a repo whose hook on every tool call (`PreToolUse`, `PostToolUse`) takes over 150 ms on a no-op Bash call, and fails a hook on a save as soon as it is wired, unless `repo.config.ts` names it under `instantHooks` with the reason it is instant. SK046 warns on the runs the harness recorded. `sk time hooks` shows what each hook cost.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rvlib-shipkit",
3
- "version": "2.26.0",
3
+ "version": "2.27.0",
4
4
  "funding": "https://github.com/sponsors/rvion",
5
5
  "description": "All-in-one repo companion: ci gate (task DAG), auto-discovered health checks, release-contract fulfillness, asks queue, md-wiki tools, asset atelier, live tui",
6
6
  "license": "MIT",
@@ -0,0 +1,77 @@
1
+ // the diet of the agent time index: after DIET_KEEP_MS, a call keeps its command's text only when `sk time` shows it
2
+ // (it failed, was refused, ran DIET_SLOW_MS or more, has no end, or ran a script: a `<file>` shape), and every other
3
+ // text goes, its 53 bit sum kept so the blind retry test still compares. The one constraint a reader breaks first: a
4
+ // dropped text never comes back (Claude Code prunes the transcripts), so it runs only while the owner's switch
5
+ // `time-diet` is on, off by default, in steps that rewrite each range of rows so its pages go back to the disk
6
+ import type { Database } from 'bun:sqlite'
7
+ import { machineGet, machineSet } from '../core/machine-db.ts'
8
+ import { FILE_MARK } from './shape.ts'
9
+ import { cmdSum } from './timeline.ts'
10
+
11
+ export const TIME_DIET = 'time-diet'
12
+ /** the owner's word: on, the agent time job drops the texts; off, its default, nothing is dropped */
13
+ export const dietOn = (): boolean => machineGet<boolean>(TIME_DIET) === true
14
+ export const setDietOn = (on: boolean): boolean => machineSet(TIME_DIET, on)
15
+
16
+ /** a call this recent keeps its text, whatever it is */
17
+ export const DIET_KEEP_MS = 7 * 86_400_000
18
+ /** a call that ran this long keeps its text: the slowest calls `sk time` lists */
19
+ export const DIET_SLOW_MS = 10_000
20
+ /** rows a step rewrites: a few ms of the file's write lock */
21
+ const DIET_STEP = 500
22
+ /** the pause between two steps */
23
+ const DIET_PAUSE_MS = 10
24
+
25
+
26
+ /** the texts that stay, as a condition on a row of time_calls */
27
+ const KEEPS = `(outcome in ('exit', 'error', 'timeout', 'blocked', 'denied') or end is null or end - start >= ${DIET_SLOW_MS} or instr(shape, '${FILE_MARK}') > 0)`
28
+
29
+ export type Diet = { calls: number; bytes: number; heldMs: number }
30
+
31
+ /** the texts the diet drops, older than `now - DIET_KEEP_MS`: `dry` counts them and drops nothing. Each step deletes a
32
+ * range of rows and writes them back without their text under the same rowids, so the range takes fewer pages and
33
+ * the freed ones go to the free list (the file gives them back in steps: machine-db.ts vacuumSteps). A row older
34
+ * than the cut is never written by the indexer again (it only closes a call with no end, which keeps its text) */
35
+ export function dietCalls(db: Database, o: { now: number; dry?: boolean; step?: number; pauseMs?: number }): Diet {
36
+ const cut = o.now - DIET_KEEP_MS
37
+ const goes = `start < ? and cmd != '' and cmd_sum is null and not ${KEEPS}`
38
+ if (o.dry === true) {
39
+ const r = db.query(`select count(*) as n, coalesce(sum(length(cast(cmd as blob))), 0) as b from time_calls where ${goes}`).get(cut) as { n: number; b: number }
40
+ return { calls: r.n, bytes: r.b, heldMs: 0 }
41
+ }
42
+ const cols = (db.query("select name from pragma_table_info('time_calls')").all() as { name: string }[]).map((c) => c.name)
43
+ const keeps = (r: Record<string, unknown>): boolean => ['exit', 'error', 'timeout', 'blocked', 'denied'].includes(r.outcome as string) || r.end == null || (r.end as number) - (r.start as number) >= DIET_SLOW_MS || (r.shape as string).includes(FILE_MARK)
44
+ const drops = (r: Record<string, unknown>): boolean => (r.start as number) < cut && r.cmd !== '' && r.cmd_sum == null && !keeps(r)
45
+ const list = cols.map((c) => `"${c}"`).join(', ')
46
+ // a step is a range of DIET_STEP rows, kept ones too: a range of a fixed size holds the lock a fixed time, and a
47
+ // range rewritten whole takes the fewest pages
48
+ const first = db.query(`select min(rowid) as r from time_calls where ${goes}`)
49
+ const end = db.query('select rowid as r from time_calls where rowid >= ? order by rowid limit 1 offset ?')
50
+ const out: Diet = { calls: 0, bytes: 0, heldMs: 0 }
51
+ const step = o.step ?? DIET_STEP
52
+ for (let lo = (first.get(cut) as { r: number | null }).r; lo != null; ) {
53
+ const hi = (end.get(lo, step - 1) as { r: number } | null)?.r ?? Number.MAX_SAFE_INTEGER
54
+ const t = performance.now()
55
+ db.transaction(() => {
56
+ const rows = db.query(`select rowid as _r, ${list} from time_calls where rowid between ? and ?`).all(lo, hi) as Record<string, unknown>[]
57
+ db.query('delete from time_calls where rowid between ? and ?').run(lo, hi)
58
+ const put = db.query(`insert into time_calls (rowid, ${list}) values (${['?', ...cols.map(() => '?')].join(', ')})`)
59
+ for (const r of rows) {
60
+ if (drops(r)) {
61
+ out.bytes += Buffer.byteLength(r.cmd as string)
62
+ out.calls++
63
+ r.cmd_sum = cmdSum(r.cmd as string)
64
+ r.cmd = ''
65
+ }
66
+ put.run(r._r as never, ...cols.map((c) => r[c] as never))
67
+ }
68
+ }).immediate()
69
+ out.heldMs = Math.max(out.heldMs, Math.round(performance.now() - t))
70
+ // the log checkpointed here at each step: else another process's small write past the threshold pays it
71
+ db.query('pragma wal_checkpoint(passive)').all()
72
+ // a pause a step, so the machine's other writes and the log's checkpoint get the disk between two
73
+ Bun.sleepSync(o.pauseMs ?? DIET_PAUSE_MS)
74
+ lo = (db.query(`select min(rowid) as r from time_calls where rowid > ? and ${goes}`).get(hi, cut) as { r: number | null }).r
75
+ }
76
+ return out
77
+ }
@@ -0,0 +1,72 @@
1
+ // A Bash shape's FAMILY: the kind of work the command is (a read, an edit, a
2
+ // check, a wait). A few hundred shapes group into ten rows, so « Bash » is
3
+ // never one figure.
4
+ //
5
+ // The constraint a reader breaks first: the rules run in order and the first
6
+ // match wins, so `sed -i (edit)` is an edit before `sed` is a read, and
7
+ // `bun check` is a check before `bun` is a program.
8
+
9
+ import { kindOf } from './shape.ts'
10
+
11
+ export const FAMILIES = ['scripts', 'checks', 'reads', 'edits', 'git', 'shipkit', 'files', 'machine', 'waits', 'other'] as const
12
+ export type Family = (typeof FAMILIES)[number]
13
+
14
+ /** each family as a person names it, and what falls in it */
15
+ export const FAMILY_WORDS: Record<Family, { label: string; title: string }> = {
16
+ scripts: { label: 'scripts and programs', title: 'bun <file>, python3, bash <file>, a package script, ffmpeg' },
17
+ checks: { label: 'checks and tests', title: 'bun check, a test run, sk ci, a linter' },
18
+ reads: { label: 'reading and searching', title: 'grep, sed, cat, ls, head, tail, wc, find' },
19
+ edits: { label: 'editing through the shell', title: 'a python3 heredoc that writes a file, sed -i, perl -i, cat >' },
20
+ git: { label: 'git', title: 'git and gh' },
21
+ shipkit: { label: 'shipkit commands', title: 'sk, its checks left out (sk ci, sk check, sk status are checks)' },
22
+ files: { label: 'moving files', title: 'cp, mv, rm, mkdir, chmod, tar, rsync' },
23
+ machine: { label: 'the machine and the network', title: 'curl, ssh, lsof, pgrep, kill, du, df' },
24
+ waits: { label: 'waiting and polling', title: 'sleep, an until loop, a while loop' },
25
+ other: { label: 'other', title: 'a shell function, a loop whose command the shape does not name' },
26
+ }
27
+
28
+ const BG = ' (bg)'
29
+ /** a row of a background run: timed from its start to its end, never a wait inside the call */
30
+ export const isBgShape = (shape: string): boolean => shape.endsWith(BG)
31
+ export const bareShape = (shape: string): string => (isBgShape(shape) ? shape.slice(0, -BG.length) : shape)
32
+
33
+ const READS = new Set([
34
+ 'grep', 'rg', 'sed', 'awk', 'cat', 'head', 'tail', 'ls', 'wc', 'find', 'sort', 'uniq', 'cut', 'jq', 'diff', 'tree', 'stat', 'file', 'echo', 'printf',
35
+ 'pwd', 'which', 'test', 'less', 'xxd', 'nl', 'tr', 'basename', 'dirname', 'realpath', 'readlink', 'sqlite3', 'date', 'column', 'comm', 'md5', 'shasum', 'strings', 'type',
36
+ ])
37
+ const FILES = new Set(['cp', 'mv', 'rm', 'rmdir', 'mkdir', 'chmod', 'chown', 'touch', 'ln', 'tar', 'zip', 'unzip', 'gzip', 'gunzip', 'rsync', 'tee', 'trash'])
38
+ const MACHINE = new Set([
39
+ 'curl', 'wget', 'ssh', 'scp', 'lsof', 'pgrep', 'ps', 'kill', 'killall', 'pkill', 'du', 'df', 'top', 'uptime', 'open', 'osascript', 'launchctl', 'tmutil', 'nc', 'ping',
40
+ 'say', 'afplay', 'screencapture', 'brew', 'docker', 'sysctl', 'vm_stat', 'defaults', 'diskutil', 'mdfind', 'pmset', 'sw_vers', 'uname', 'whoami', 'hostname', 'tailscale', 'dig',
41
+ ])
42
+ const PROGRAMS = new Set([
43
+ 'bun', 'node', 'deno', 'python', 'python3', 'bash', 'sh', 'zsh', 'npx', 'bunx', 'pnpx', 'npm', 'pnpm', 'yarn', 'ffmpeg', 'ffprobe', 'magick', 'convert', 'sips',
44
+ 'make', 'cargo', 'go', 'ruby', 'perl', 'time', 'xargs', 'comfy-ts', 'chi', 'cflow', 'wrangler', 'swift', 'swiftc', 'xcodebuild', 'pip', 'pip3', 'uv',
45
+ ])
46
+ const CHECKERS = new Set(['tsc', 'vitest', 'jest', 'eslint', 'biome', 'oxlint', 'prettier', 'playwright'])
47
+ /** a package script that checks: `test:raw`, `box:check`, `prove:data` */
48
+ const CHECK_WORD = /(?:^|:)(?:test|tests|check|lint|typecheck|types|tsc|ci|prove|verify)(?::|$)/
49
+ const SCRIPT_FILE = /\.(?:sh|bash|zsh|ts|tsx|js|mjs|cjs|py|rb|pl)$/
50
+
51
+ /** the family of one Bash shape; a background row falls in the family of its command */
52
+ export function familyOf(shape: string): Family {
53
+ const s = kindOf(bareShape(shape))
54
+ if (/^\((?:until|while)\)/.test(s)) return 'waits'
55
+ // a loop, a subshell, a group or a substitution is the command it runs
56
+ const cmd = s.replace(/^(?:\((?:for|if|function)\)\s*|[A-Za-z_][A-Za-z0-9_]*=\$\(|\$?\(|\{ )+/, '')
57
+ const w = cmd.split(' ')
58
+ const head = w[0] ?? ''
59
+ if (head === 'sleep') return 'waits'
60
+ if (cmd.endsWith('(edit)') || cmd === 'cat > (write)') return 'edits'
61
+ if (head === 'git' || head === 'gh') return 'git'
62
+ const runner = head === 'bun' || head === 'npm' || head === 'pnpm' || head === 'yarn'
63
+ if (runner && CHECK_WORD.test(w[1] === 'run' ? (w[2] ?? '') : (w[1] ?? ''))) return 'checks'
64
+ if ((head === 'bunx' || head === 'npx' || head === 'pnpx') && CHECKERS.has(w[1] ?? '')) return 'checks'
65
+ if (CHECKERS.has(head)) return 'checks'
66
+ if (head === 'sk' || head === 'shipkit') return w[1] === 'ci' || w[1] === 'check' || w[1] === 'status' ? 'checks' : 'shipkit'
67
+ if (READS.has(head)) return 'reads'
68
+ if (FILES.has(head)) return 'files'
69
+ if (MACHINE.has(head)) return 'machine'
70
+ if (PROGRAMS.has(head) || SCRIPT_FILE.test(head) || head === '<file>') return 'scripts'
71
+ return 'other'
72
+ }
@@ -3,8 +3,9 @@
3
3
  // verdicts of SK045 (the gate) and SK046 (the recorded runs, a warning).
4
4
  // `sk time hooks` reads the same declarations.
5
5
  //
6
- // The constraint a reader breaks first: the harness records a hook's run only
7
- // when the hook printed something, so a silent hook has no record, and a hook
6
+ // The constraint a reader breaks first: the harness records the run of a hook
7
+ // on a tool call or a prompt only when the hook printed something, so a silent
8
+ // one has no record (the hooks of a turn's end are all recorded), and a hook
8
9
  // the probe may not run (one on a save may write) has no measure at all.
9
10
  import { createHash } from 'crypto'
10
11
  import { existsSync, readFileSync, realpathSync, statSync } from 'fs'
@@ -266,7 +267,8 @@ export const hookLabel = (h: DeclaredHook): string =>
266
267
  /** the key of repo.config.ts that declares a hook the gate cannot time */
267
268
  export const INSTANT_KEY = 'instantHooks'
268
269
 
269
- const NOT_RECORDED = 'the harness records a hook run only when the hook prints something'
270
+ /** why a hook has no timed run: every hook of a turn's end is recorded, the others only when they print */
271
+ const notRecorded = (event: string): string => (event === 'Stop' || event === 'SubagentStop' ? 'the harness records every hook of a turn end: none ran in the records read' : 'the harness records a hook run only when the hook prints something')
270
272
  const AS_A_CHECK = 'work over the tree runs as a check when the step is done: sk ci --only <check>'
271
273
 
272
274
  /** SK045's verdict on one per call hook, from what the gate itself can tell:
@@ -302,7 +304,7 @@ export function judgeRecords(h: DeclaredHook, recorded: number[], behind?: strin
302
304
  const rec = measureOf(recorded)
303
305
  const cadence = cadenceOf(h.event)
304
306
  const budget = cadence === 'call' ? CALL_BUDGET_MS : TURN_BUDGET_MS
305
- if (rec == null) return { level: 'ok', text: `${label}: no timed run recorded (${NOT_RECORDED})${behind == null ? '' : `; ${behind}`}` }
307
+ if (rec == null) return { level: 'ok', text: `${label}: no timed run recorded (${notRecorded(h.event)})${behind == null ? '' : `; ${behind}`}` }
306
308
  if (rec.runs >= MIN_RUNS && rec.p50 > budget)
307
309
  return {
308
310
  level: 'warn',
@@ -0,0 +1,44 @@
1
+ // The commands that reached the time limit of their call, summed for a
2
+ // reader: what became of them, by command (a `<file>` command by its scripts),
3
+ // and the newest. The page and the console read the same sums.
4
+ import type { TimeoutRow } from './report.ts'
5
+
6
+ export const TOP_LIMIT_SHAPES = 15
7
+ /** the scripts a `<file>` row opens on */
8
+ export const TOP_FILE_PARTS = 10
9
+ export const TOP_TIMEOUTS = 40
10
+
11
+ /** the commands that reached the time limit of their call, summed by shape */
12
+ /** `parts`: for a `<file>` shape, the scripts that reached the limit */
13
+ export type TimeoutShape = { shape: string; n: number; finished: number; lost: number; limitMs: number; typicalTotalMs: number | null; parts?: TimeoutShape[] }
14
+ export type Timeouts = { count: number; finished: number; failed: number; stopped: number; lost: number; limitMs: number; byShape: TimeoutShape[]; rows: TimeoutRow[] }
15
+
16
+ const median = (xs: number[]): number | null => (xs.length === 0 ? null : ([...xs].sort((a, b) => a - b)[Math.floor(xs.length / 2)] ?? null))
17
+
18
+ /** the commands that reached their call's time limit: the counts by what became of them, by shape, and the newest */
19
+ export function timeoutsOf(rows: readonly TimeoutRow[]): Timeouts {
20
+ const count = (after: TimeoutRow['after'], of: readonly TimeoutRow[] = rows): number => of.filter((t) => t.after === after).length
21
+ /** the rows summed under a name, the most hits first */
22
+ const cut = (of: readonly TimeoutRow[], key: (t: TimeoutRow) => string): TimeoutShape[] => {
23
+ const by = new Map<string, TimeoutRow[]>()
24
+ for (const t of of) by.set(key(t), [...(by.get(key(t)) ?? []), t])
25
+ return [...by.entries()]
26
+ .map(([shape, ts]) => ({ shape, n: ts.length, finished: count('ok', ts), lost: count('none', ts), limitMs: ts.reduce((n, t) => n + t.limitMs, 0), typicalTotalMs: median(ts.flatMap((t) => (t.totalMs == null ? [] : [t.totalMs]))) }))
27
+ .sort((a, b) => b.n - a.n || a.shape.localeCompare(b.shape))
28
+ }
29
+ return {
30
+ count: rows.length,
31
+ finished: count('ok'),
32
+ failed: count('failed'),
33
+ stopped: count('stopped'),
34
+ lost: count('none'),
35
+ limitMs: rows.reduce((n, t) => n + t.limitMs, 0),
36
+ byShape: cut(rows, (t) => t.shape)
37
+ .slice(0, TOP_LIMIT_SHAPES)
38
+ .map((s) => {
39
+ const scripts = rows.filter((t) => t.shape === s.shape && t.script != null)
40
+ return scripts.length === 0 ? s : { ...s, parts: cut(scripts, (t) => t.script ?? '').slice(0, TOP_FILE_PARTS) }
41
+ }),
42
+ rows: rows.slice(0, TOP_TIMEOUTS),
43
+ }
44
+ }
@@ -8,6 +8,7 @@
8
8
  // each time someone looks.
9
9
  import { closeSync, openSync, readFileSync, readSync, statSync } from 'fs'
10
10
  import type { TranscriptFile } from './store.ts'
11
+ import { HAND_BACK } from './timeline.ts'
11
12
 
12
13
  const HEAD_BYTES = 64 * 1024
13
14
  const TAIL_BYTES = 256 * 1024
@@ -54,9 +55,6 @@ export function callWords(p: Part): string {
54
55
  return `${p.name ?? 'tool'}${one === '' ? '' : `: ${one.length > 70 ? `${one.slice(0, 69)}…` : one}`}`
55
56
  }
56
57
 
57
- /** the call a sub-agent ends on: its report handed back to the session that started it */
58
- const HAND_BACK = 'SubagentHandback'
59
-
60
58
  /** what the last entries of a transcript say the agent does now. `lines` are its last lines, oldest first */
61
59
  export function stateOf(lines: readonly string[]): { state: LiveState; at: number } {
62
60
  // a result just came back, or a request is in flight: a model turn, unless the call before it was the hand back
@@ -1,24 +1,102 @@
1
- // What `sk time` prints comes from his sessions: commands and prompts can
2
- // carry a token or a private name. Every line passes through here first: the
3
- // leak guard's own keyword list (machine wide and the repo's), then the token
4
- // shapes no list has to name.
1
+ // What `sk time` prints comes from the owner's sessions, and a prompt that
2
+ // leaves the machine (hq/kinds/prompt.ts) is one of them: a command or a prompt
3
+ // can carry a token or a private name. Every line passes through here first:
4
+ // the house's key shapes, the name rules, then the leak guard's keyword list
5
+ // (machine wide and the repo's).
5
6
  import { existsSync, readFileSync } from 'fs'
6
7
  import { join } from 'path'
7
8
  import { KEYWORD_FILE } from '../core/layout.ts'
8
- import { type ParsedPatterns, globalKeywordFile, parsePatterns } from '../hooks/leak-guard.ts'
9
-
10
- /** token shapes masked whatever the lists say */
11
- const TOKEN_SHAPES: RegExp[] = [
12
- /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,
13
- /(?<![A-Za-z0-9_-])sk-[A-Za-z0-9_-]{20,}/g,
14
- /\bgh[pousr]_[A-Za-z0-9]{30,}/g,
15
- /\bxox[baprs]-[A-Za-z0-9-]{10,}/g,
16
- /\bAKIA[0-9A-Z]{16}\b/g,
17
- /\b(?:Bearer|token|Token)\s+[A-Za-z0-9._~+/=-]{16,}/g,
18
- /\b(?:api[_-]?key|secret|password|passwd|token)\s*[=:]\s*['"]?[^\s'"]{8,}/gi,
19
- /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g,
9
+ import { type ParsedPatterns, globalKeywordFile, parsePatterns, SECRET_ROWS } from '../hooks/leak-guard.ts'
10
+
11
+ // a name that says its value is a secret: an env line, an ini or yaml key, a JSON key, a header
12
+ const SECRET_NAME = String.raw`[A-Za-z0-9_.-]*?(?:token|secret|passw(?:or)?d|passphrase|mot[_-]?de[_-]?passe|pwd|auth[_-]?header|api[_-]?key|apikey|access[_-]?key|private[_-]?key|_key|key[_-]?id|credential|client[_-]key[_-]data)[A-Za-z0-9_.-]*`
13
+ // a value already masked is never masked again: a second pass (the hq after the machine) changes nothing
14
+ const FRESH = String.raw`(?!\*{3})`
15
+ const NAMED = String.raw`(?<![A-Za-z0-9_.-])(?<name>["']?${SECRET_NAME}["']?)[ \t]*`
16
+
17
+ /** the name rules: a value after a name, a flag or a scheme that says it is a secret. A rule with a group `k` keeps
18
+ * that part and masks the value after it; with a group `v`, a value that cannot be a secret (`spare`) stays */
19
+ const NAME_RULES: readonly RegExp[] = [
20
+ // a JSON key that names a secret, its string value, escapes included
21
+ new RegExp(String.raw`(?<k>"(?<name>${SECRET_NAME})"\s*:\s*")${FRESH}(?<v>[^"\\]+(?:\\.[^"\\]*)*)(?=")`, 'gi'),
22
+ // a name, `=` or `:`, a quoted value: up to its closing quote
23
+ new RegExp(String.raw`(?<k>${NAMED}[:=][ \t]*(?<q>["'\x60]))${FRESH}(?<v>[^"'\x60\n]+)(?=\k<q>)`, 'gi'),
24
+ // a name, `=` or `:`, a bare value, on the same line or alone on the next
25
+ new RegExp(String.raw`(?<k>${NAMED}(?:=[ \t]*(?:\r?\n[ \t]*)?|:[ \t]*))${FRESH}(?<v>[^\s'"\x60]+)`, 'gi'),
26
+ // a flag that names a secret, its value after a space
27
+ new RegExp(String.raw`(?<k>(?<![\w-])(?<name>--?(?:[a-z0-9-]*-)?(?:token|secret|password|passwd|api-?key|access-key))[ \t]+['"]?)${FRESH}(?<v>[^\s'"-][^\s'"]*)`, 'gi'),
28
+ // a one time code, a pin: 4 to 8 digits after its name
29
+ new RegExp(String.raw`(?<k>(?<![A-Za-z0-9_.-])["']?[A-Za-z0-9_.-]*?(?:pin|otp|code)["']?[ \t]*[:=][ \t]*["']?)${FRESH}\d{4,8}(?!\d)`, 'gi'),
30
+ // the password of a url, of any scheme: scheme://user:password@host
31
+ new RegExp(String.raw`(?<k>\b[a-z][a-z0-9+.-]*://[^\s:/@]*:)${FRESH}[^\s@/]+(?=@)`, 'gi'),
32
+ // a url's query that names a secret
33
+ new RegExp(String.raw`(?<k>[?&](?<name>access_token|refresh_token|id_token|token|key|api_key|apikey|secret|client_secret|sig|signature|password)=)${FRESH}(?<v>[^&\s#"']+)`, 'gi'),
34
+ // an authorization value with no scheme before it, a value with a digit or long, never a word of prose
35
+ new RegExp(String.raw`(?<k>\bauthorization["']?[ \t]*[:=][ \t]*["']?)${FRESH}(?!(?:bearer|basic|token|digest)\b)(?=[A-Za-z0-9._~+/=-]*\d|[A-Za-z0-9._~+/=]{20})[A-Za-z0-9._~+/=-]{16,}`, 'gi'),
36
+ // a cookie header: the value of each of its pairs up to the `;`
37
+ new RegExp(String.raw`(?<k>(?<![A-Za-z0-9_-])(?:set-)?cookie["']?[ \t]*:[ \t]*["']?[A-Za-z0-9_.-]+=)${FRESH}[^\s;"']{8,}`, 'gi'),
38
+ // the key of a dsn: 32 hex before the `@` of a url
39
+ new RegExp(String.raw`(?<k>\bhttps?://)${FRESH}[a-f0-9]{32}(?=(?::[a-f0-9]{32})?@)`, 'gi'),
40
+ new RegExp(String.raw`(?<k>\bauthorization["']?\s*[:=]\s*["']?basic\s+)${FRESH}[A-Za-z0-9+/]{6,}={0,2}`, 'gi'),
41
+ // a bearer token, a `token <value>`: a value with a digit, or long, never a word of prose
42
+ new RegExp(String.raw`(?<k>\bbearer\s+)${FRESH}(?=[A-Za-z0-9._~+/=-]*\d|[A-Za-z0-9._~+/=]{16})[A-Za-z0-9._~+/=-]{8,}`, 'gi'),
43
+ new RegExp(String.raw`(?<k>\btoken\s+)${FRESH}(?=[A-Za-z0-9._~+/=-]*\d|[A-Za-z0-9._~+/=]{20})[A-Za-z0-9._~+/=-]{16,}`, 'gi'),
44
+ // a password on a command line: mysql -pVALUE, sshpass -p VALUE, curl -u user:VALUE, redis-cli -a VALUE
45
+ new RegExp(String.raw`(?<k>\bmysql(?:dump|admin|sh)?\b[^\n|;&]*?\s-p['"]?)${FRESH}[^\s'"]+`, 'g'),
46
+ new RegExp(String.raw`(?<k>\bsshpass\b[^\n|;&]*?\s-p[ \t]*['"]?)${FRESH}[^\s'"]+`, 'g'),
47
+ new RegExp(String.raw`(?<k>\bcurl\b[^\n|;&]*?\s(?:-u|--user)[ \t]+['"]?[^\s:'"@]+:)${FRESH}[^\s'"]+`, 'g'),
48
+ new RegExp(String.raw`(?<k>\bredis-cli\b[^\n|;&]*?\s-a[ \t]+['"]?)${FRESH}[^\s'"]+`, 'g'),
20
49
  ]
21
50
 
51
+ // whole names of a secret's lookalikes, `_`, `-` and `.` left out: a count, a column, a public half, an id. Matched as
52
+ // the whole name, never a part (`api_tokens` is no `max_tokens`)
53
+ const NOT_SECRET_NAME = new Set(['maxtokens', 'maxoutputtokens', 'inputtokens', 'outputtokens', 'prompttokens', 'completiontokens', 'totaltokens', 'cachereadinputtokens', 'cachecreationinputtokens', 'primarykey', 'foreignkey', 'publickey', 'keyid', 'keyof', 'cachekey', 'sortkey', 'partitionkey'])
54
+ const SAYS_PASSWORD = /passw(?:or)?d|passphrase|passe|pwd|pin|code|otp|secret/i
55
+ // a placeholder: `<…>`, `${…}`, `$NAME`, `xxx…`, `YOUR_…`. `changeme` is no placeholder: it is a password
56
+ const PLACEHOLDER = /^(?:<[^<>]*>|\$\{[^}]*\}|\$[A-Z_][A-Z0-9_]*|x{3,}|X{3,}|YOUR_[A-Z0-9_]*|your[-_][a-z0-9_-]*)$/
57
+
58
+ /** a value that cannot be a secret, after a name that says one: an empty value, a literal, a placeholder, a number of 6
59
+ * digits or fewer after a name that says no password; after a whole name of a lookalike (`max_tokens`), a number or
60
+ * a value with no digit. Never a value for its shape alone: when in doubt, masked */
61
+ export function spare(name: string, value: string): boolean {
62
+ const v = value.replace(/[,;)\]}]+$/, '')
63
+ if (v === '' || /^(?:true|false|null|none|undefined)$/i.test(v) || PLACEHOLDER.test(value) || PLACEHOLDER.test(v)) return true
64
+ if (NOT_SECRET_NAME.has(name.toLowerCase().replace(/["'_.\s-]/g, ''))) return /^\d+$/.test(v) || (!/\d/.test(v) && v.length < 32)
65
+ return /^\d{1,6}$/.test(v) && !SAYS_PASSWORD.test(name)
66
+ }
67
+
68
+ // a private key's row names its first line: the mask takes the whole block
69
+ const KEY_BLOCK = /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g
70
+ // a jwt is masked here and not in the house's list: docs and tests carry sample tokens the commit gate must let by
71
+ // a stripe publishable key is masked here, not in the house's list: it is public by design, and web code commits it
72
+ const PK = /\bpk_(?:live|test)_[A-Za-z0-9]{16,}/g
73
+ const JWT = /\beyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g
74
+
75
+ /** every shape a mask takes out, in order: the key block, the house's key shapes (leak-guard.ts SECRET_ROWS, exact in
76
+ * case, as the commit gate and the backup read them), then the name rules */
77
+ export const SECRET_SHAPES: readonly RegExp[] = [KEY_BLOCK, JWT, PK, ...parsePatterns(SECRET_ROWS.join('\n')).regexes.map((r) => new RegExp(r.re.source, 'g')), ...NAME_RULES]
78
+
79
+ /** a shape's match becomes its kept part `k` and `***`; a value it spares stays whole */
80
+ const masked = (...args: unknown[]): string => {
81
+ const groups = args.at(-1)
82
+ const g = groups != null && typeof groups === 'object' ? (groups as { k?: string; name?: string; v?: string }) : {}
83
+ if (g.v != null && g.name != null && spare(g.name, g.v)) return String(args[0])
84
+ return `${g.k ?? ''}***`
85
+ }
86
+
87
+ /** every secret shape becomes `***`, and how many: what leaves the machine. Masking twice changes nothing */
88
+ export function maskSecrets(text: string): { text: string; masked: number } {
89
+ let n = 0
90
+ let out = text
91
+ for (const re of SECRET_SHAPES)
92
+ out = out.replace(re, (...args: unknown[]) => {
93
+ const m = masked(...args)
94
+ if (m !== args[0]) n++
95
+ return m
96
+ })
97
+ return { text: out, masked: n }
98
+ }
99
+
22
100
  const escapeRegex = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
23
101
 
24
102
  export type Masker = (text: string) => string
@@ -26,12 +104,12 @@ export type Masker = (text: string) => string
26
104
  /** a masker over parsed keyword rows plus the token shapes */
27
105
  export function makeMasker(p: ParsedPatterns): Masker {
28
106
  const res: RegExp[] = [
29
- ...TOKEN_SHAPES,
107
+ ...SECRET_SHAPES,
30
108
  ...p.substrings.map((s) => new RegExp(escapeRegex(s), 'gi')),
31
109
  ...p.words.map((w) => new RegExp(w.re.source, 'giu')),
32
110
  ...p.regexes.map((r) => new RegExp(r.re.source, 'gi')),
33
111
  ]
34
- return (text) => res.reduce((t, re) => t.replace(re, '***'), text)
112
+ return (text) => res.reduce((t, re) => t.replace(re, masked), text)
35
113
  }
36
114
 
37
115
  /** the masker this machine and repo call for: the global keyword list and
@@ -0,0 +1,45 @@
1
+ // A call refused before it ran: who refused it and why, read from the
2
+ // harness's own words in the call's result (`why` of a call).
3
+ //
4
+ // The constraint a reader breaks first: a refused call still cost the model
5
+ // turn that wrote it, and the next turn reads the refusal. So a refusal is
6
+ // counted with the model time of its turn, never as free.
7
+
8
+ export const REFUSERS = ['classifier', 'hook', 'rule', 'you', 'other'] as const
9
+ export type Refuser = (typeof REFUSERS)[number]
10
+
11
+ export const REFUSER_WORDS: Record<Refuser, { label: string; title: string }> = {
12
+ classifier: { label: 'the auto mode classifier', title: 'the classifier that checks a call in auto mode judged it unsafe' },
13
+ hook: { label: 'a hook', title: 'a PreToolUse hook of the repo or of the user refused the call' },
14
+ rule: { label: 'a permission rule', title: 'a deny rule, or a permission mode that asks nobody' },
15
+ you: { label: 'you said no', title: 'the call waited for your allow and you refused it' },
16
+ other: { label: 'not named', title: 'the result does not say what refused it' },
17
+ }
18
+
19
+ /** `name`: which hook, or which reason of the classifier; `reason`: the words given to the agent */
20
+ export type Refusal = { by: Refuser; name: string; reason: string }
21
+
22
+ const HOOK = /^PreToolUse:\w+ (?:hook error: )?\[(.*?)\]:? ?(.*)$/
23
+ const SCRIPT = /([\w.-]+)\.(?:ts|tsx|js|mjs|cjs|sh|py)\b/g
24
+ const CLASSIFIER_REASON = /Reason: (.*?)(?:\. If you have|\. IMPORTANT|$)/
25
+
26
+ /** a hook is named by its script, without its folder and its extension */
27
+ const hookName = (command: string): string => {
28
+ const scripts = [...command.matchAll(SCRIPT)].map((m) => m[1] ?? '')
29
+ return scripts[scripts.length - 1] ?? command.slice(0, 60)
30
+ }
31
+
32
+ export function refusalOf(outcome: string | null, why: string): Refusal {
33
+ if (outcome === 'denied') return { by: 'you', name: '', reason: why.replace(/^The user doesn't want to proceed with this tool use\. The tool use was rejected.*?(?:the user said:|$)/i, '').trim() }
34
+ if (/auto mode classifier/i.test(why)) {
35
+ const reason = (CLASSIFIER_REASON.exec(why)?.[1] ?? '').trim()
36
+ // `[Irreversible Local Destruction]` is the classifier's own name for the reason
37
+ const named = /^\[(.+?)\]/.exec(reason)?.[1]
38
+ return { by: 'classifier', name: named ?? (/gave no explanation/.test(reason) ? 'no reason given' : reason.slice(0, 80) || 'no reason given'), reason }
39
+ }
40
+ const hook = HOOK.exec(why)
41
+ if (hook != null) return { by: 'hook', name: hookName(hook[1] ?? ''), reason: (hook[2] ?? '').trim() }
42
+ if (/hook error/i.test(why)) return { by: 'hook', name: 'a hook that failed', reason: why }
43
+ if (/^Permission (?:to use|for this action)/.test(why)) return { by: 'rule', name: '', reason: why.length > 160 ? 'the permission settings deny this call' : why }
44
+ return { by: 'other', name: '', reason: why }
45
+ }