rvlib-shipkit 2.12.0 → 2.14.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 (378) hide show
  1. package/CHANGELOG.md +75 -21
  2. package/README.md +1 -1
  3. package/package.json +4 -2
  4. package/src/agent-time/store.ts +2 -2
  5. package/src/assets/run-assets.ts +2 -2
  6. package/src/assets/server/studio-server.ts +27 -23
  7. package/src/check.ts +4 -4
  8. package/src/checks/SK001-package-json-shape.check.ts +8 -4
  9. package/src/checks/SK002-contracts-fulfillness.check.ts +2 -2
  10. package/src/checks/SK003-claude-md-shape.check.ts +20 -13
  11. package/src/checks/SK004-gitignore-policy.check.ts +45 -6
  12. package/src/checks/SK005-rvlib-versions.check.ts +2 -2
  13. package/src/checks/SK006-npm-publish-safety.check.ts +3 -3
  14. package/src/checks/SK007-github-visibility.check.ts +2 -2
  15. package/src/checks/SK008-reviewer-agent.check.ts +3 -3
  16. package/src/checks/SK010-undeclared-unit.check.ts +2 -2
  17. package/src/checks/SK011-sibling-unit-ranges.check.ts +2 -2
  18. package/src/checks/SK012-config-barrel-import.check.ts +2 -2
  19. package/src/checks/SK013-one-way-in-policy.check.ts +2 -2
  20. package/src/checks/SK015-nested-repo.check.ts +3 -3
  21. package/src/checks/SK016-legacy-check-shapes.check.ts +2 -2
  22. package/src/checks/SK017-vscode-hub-task.check.ts +2 -2
  23. package/src/checks/SK018-test-files-run.check.ts +2 -2
  24. package/src/checks/SK019-tests-run-in-units.check.ts +2 -2
  25. package/src/checks/SK020-self-spawning-check.check.ts +2 -2
  26. package/src/checks/SK022-machine-runs-the-pin.check.ts +2 -2
  27. package/src/checks/SK024-identity-colors.check.ts +1 -1
  28. package/src/checks/SK025-release-drift.check.ts +2 -2
  29. package/src/checks/SK026-asks-autoclose.check.ts +2 -2
  30. package/src/checks/SK027-agent-wiki-links.check.ts +8 -2
  31. package/src/checks/SK028-readme.check.ts +2 -2
  32. package/src/checks/SK029-explicit-check-files.check.ts +3 -3
  33. package/src/checks/SK030-cache-audit.check.ts +7 -5
  34. package/src/checks/SK031-trace-audit.check.ts +7 -7
  35. package/src/checks/SK032-ignored-inputs.check.ts +3 -3
  36. package/src/checks/SK033-global-contribution.check.ts +11 -4
  37. package/src/checks/SK034-commit-gates-armed.check.ts +2 -2
  38. package/src/checks/SK035-public-clean.check.ts +46 -0
  39. package/src/checks/SK036-draft-media-size.check.ts +28 -0
  40. package/src/checks/SK037-keyword-additions.check.ts +43 -0
  41. package/src/cli/cmd_Backup.ts +152 -0
  42. package/src/cli/cmd_Ci.ts +8 -11
  43. package/src/cli/cmd_Commands.ts +4 -4
  44. package/src/cli/cmd_ConfigKeys.ts +2 -2
  45. package/src/cli/cmd_Drill.ts +145 -0
  46. package/src/cli/cmd_Home.ts +50 -3
  47. package/src/cli/cmd_Init.ts +1 -1
  48. package/src/cli/cmd_Media.ts +10 -8
  49. package/src/cli/cmd_Mv.ts +14 -7
  50. package/src/cli/cmd_Review.ts +6 -4
  51. package/src/cli/cmd_Shot.ts +5 -2
  52. package/src/cli/cmd_Smoke.ts +5 -2
  53. package/src/cli/cmd_Social.ts +226 -0
  54. package/src/cli/cmd_Sound.ts +1 -1
  55. package/src/cli/cmd_Start.ts +1 -1
  56. package/src/cli/cmd_Time.ts +1 -1
  57. package/src/cli/cmd_TraceAudit.ts +6 -6
  58. package/src/cli/cmd_Trailer.ts +7 -4
  59. package/src/cli/cmd_Veille.ts +173 -0
  60. package/src/cli/cmd_When.ts +2 -2
  61. package/src/cli/family-pages.ts +19 -16
  62. package/src/cli/registry.ts +13 -2
  63. package/src/cli.ts +5 -2
  64. package/src/collections/actions.ts +1 -49
  65. package/src/collections/checks.ts +2 -1
  66. package/src/collections/collection-types.ts +12 -3
  67. package/src/collections/providers.ts +4 -4
  68. package/src/collections/review.ts +3 -2
  69. package/src/collections/tests.ts +19 -8
  70. package/src/comfy/comfy-panel.ts +2 -2
  71. package/src/contracts/apply-contracts.ts +1 -3
  72. package/src/contracts/contract-manifests.ts +2 -3
  73. package/src/contracts/contract-types.ts +0 -1
  74. package/src/contracts/contracts-engine.ts +0 -3
  75. package/src/contracts/manifests/discord.contract.ts +1 -1
  76. package/src/contracts/manifests/identity.contract.ts +1 -1
  77. package/src/contracts/manifests/itch.contract.ts +1 -1
  78. package/src/contracts/manifests/steam.contract.ts +1 -1
  79. package/src/core/agent-dir-at.ts +12 -0
  80. package/src/core/agent-dir.ts +16 -0
  81. package/src/core/app-icon.ts +9 -3
  82. package/src/core/budget.ts +1 -1
  83. package/src/core/bun-builtins.ts +2 -2
  84. package/src/core/canonical-scripts.ts +2 -2
  85. package/src/core/discover-checks.ts +38 -6
  86. package/src/core/fix-scope.ts +4 -2
  87. package/src/core/floor-resolve.ts +68 -48
  88. package/src/core/floor.ts +9 -0
  89. package/src/core/git-root.ts +24 -0
  90. package/src/core/global-contribution.ts +4 -1
  91. package/src/core/ignored-block.ts +1 -1
  92. package/src/core/ignored-inputs.ts +3 -2
  93. package/src/core/last-good.ts +3 -1
  94. package/src/core/layout.ts +8 -0
  95. package/src/core/log-stamp.ts +36 -0
  96. package/src/core/loop-watch.ts +93 -0
  97. package/src/core/machine-link.ts +134 -0
  98. package/src/core/memory-watch.ts +41 -0
  99. package/src/core/motherhome.ts +2 -2
  100. package/src/core/one-way-in-policy.ts +34 -26
  101. package/src/core/run-ci.ts +9 -11
  102. package/src/core/run-fixers.ts +9 -9
  103. package/src/core/runs-matrix.ts +1 -1
  104. package/src/core/slots.ts +30 -0
  105. package/src/core/trace-audit.ts +50 -9
  106. package/src/core/tree-rev.ts +60 -0
  107. package/src/core/unit-files.ts +42 -0
  108. package/src/drill/render.ts +140 -0
  109. package/src/drill/run.ts +269 -0
  110. package/src/fleet/scan-fleet.ts +6 -5
  111. package/src/home/daemon-jobs.ts +201 -0
  112. package/src/home/global-context.ts +44 -8
  113. package/src/home/gui-app/ShipkitGui.swift +91 -2
  114. package/src/home/home-routes.ts +22 -15
  115. package/src/home/hubs.ts +10 -3
  116. package/src/home/inbox-shape.ts +54 -5
  117. package/src/home/inbox.ts +17 -2
  118. package/src/home/lib-watch.ts +10 -3
  119. package/src/home/machine-stores.ts +15 -29
  120. package/src/home/pm-config.ts +4 -1
  121. package/src/home/pm-inputs.ts +2 -0
  122. package/src/home/resources.ts +7 -2
  123. package/src/home/run-daemon.ts +15 -18
  124. package/src/home/run-pm.ts +3 -1
  125. package/src/home/serve-daemon.ts +4 -3
  126. package/src/home/serve-web.ts +104 -1
  127. package/src/hooks/commit-message.ts +29 -20
  128. package/src/hooks/hook-gates.ts +1 -1
  129. package/src/hooks/leak-guard.ts +69 -9
  130. package/src/hooks/run-hooks.ts +18 -22
  131. package/src/identities/identities.ts +334 -0
  132. package/src/identities/machine-route.ts +126 -0
  133. package/src/identities/machine.ts +62 -0
  134. package/src/init-repo.ts +3 -3
  135. package/src/ledger/check-stats.ts +10 -9
  136. package/src/ledger/gate-checks.ts +32 -1
  137. package/src/ledger/record-kept.ts +112 -0
  138. package/src/ledger/repo-view.ts +10 -0
  139. package/src/ledger/run-log.ts +17 -12
  140. package/src/ledger/run-timeline.ts +8 -4
  141. package/src/ledger/store.ts +7 -0
  142. package/src/ledger/suite-log.ts +17 -13
  143. package/src/media-kinds.ts +3 -2
  144. package/src/media-store/backup/daemon.ts +73 -0
  145. package/src/media-store/backup/keys.ts +25 -0
  146. package/src/media-store/backup/manifest.ts +193 -0
  147. package/src/media-store/backup/restore.ts +192 -0
  148. package/src/media-store/backup/run.ts +278 -0
  149. package/src/media-store/backup/secret.ts +86 -0
  150. package/src/media-store/backup/snapshot.ts +64 -0
  151. package/src/media-store/backup/sources.ts +199 -0
  152. package/src/media-store/content.ts +1 -1
  153. package/src/media-store/daemon.ts +56 -70
  154. package/src/media-store/db.ts +1 -1
  155. package/src/media-store/fact.ts +1 -1
  156. package/src/media-store/hand.ts +1 -1
  157. package/src/media-store/kind.ts +1 -1
  158. package/src/media-store/purge.ts +1 -1
  159. package/src/media-store/put.ts +5 -3
  160. package/src/media-store/remote.ts +1 -1
  161. package/src/media-store/space.ts +24 -5
  162. package/src/mv/mv-md.ts +63 -22
  163. package/src/pages/forward.ts +35 -0
  164. package/src/pages/frame-client.ts +118 -0
  165. package/src/pages/routes.ts +29 -0
  166. package/src/pages/unit.ts +92 -0
  167. package/src/plan/planner.ts +12 -0
  168. package/src/plan/repo-source.ts +19 -5
  169. package/src/reflect/transcript.ts +35 -10
  170. package/src/release/public-clean.ts +319 -0
  171. package/src/release/published-here.ts +22 -0
  172. package/src/release/run-bump.ts +3 -2
  173. package/src/release/run-release.ts +7 -4
  174. package/src/repo-config.ts +71 -13
  175. package/src/review/anim.ts +1 -1
  176. package/src/review/auto.ts +1 -1
  177. package/src/review/cells.ts +15 -1
  178. package/src/review/format.ts +2 -2
  179. package/src/review/http.ts +16 -2
  180. package/src/review/marks.ts +1 -1
  181. package/src/review/media-kind.ts +1 -1
  182. package/src/review/media-read.ts +1 -1
  183. package/src/review/model.ts +27 -6
  184. package/src/review/notes.ts +125 -0
  185. package/src/review/previews.ts +1 -1
  186. package/src/review/project.ts +7 -39
  187. package/src/review/role.ts +1 -1
  188. package/src/review/routes.ts +18 -14
  189. package/src/review/store.ts +42 -2
  190. package/src/review/threads.ts +1 -1
  191. package/src/review/trailer-desk.ts +3 -3
  192. package/src/review/trailer-media.ts +8 -5
  193. package/src/review/trailer-model.ts +1 -1
  194. package/src/review/trailer-routes.ts +1 -1
  195. package/src/review/trailer-shots.ts +22 -5
  196. package/src/review/unit.ts +2 -2
  197. package/src/scaffold/files/agent-handoff.md +3 -0
  198. package/src/scaffold/files/agent-index.md +4 -12
  199. package/src/scaffold/files/tsconfig.json +1 -1
  200. package/src/scaffold/project-scaffold.ts +6 -5
  201. package/src/serve/embed.ts +2 -2
  202. package/src/serve/hub-app/check-words.ts +1 -1
  203. package/src/serve/hub-app/col-card.tsx +3 -17
  204. package/src/serve/hub-app/col-tables-view.tsx +2 -1
  205. package/src/serve/hub-app/cols-svc.ts +0 -13
  206. package/src/serve/hub-app/dock-st.ts +4 -2
  207. package/src/serve/hub-app/dock-view.tsx +2 -0
  208. package/src/serve/hub-app/frames-st.ts +35 -0
  209. package/src/serve/hub-app/hash-route.ts +64 -1
  210. package/src/serve/hub-app/home-st.ts +32 -8
  211. package/src/serve/hub-app/home-strip.css +9 -1
  212. package/src/serve/hub-app/home-strip.tsx +7 -6
  213. package/src/serve/hub-app/home.html +5 -0
  214. package/src/serve/hub-app/hub-app.tsx +51 -7
  215. package/src/serve/hub-app/hub.css +29 -11
  216. package/src/serve/hub-app/icons.tsx +16 -1
  217. package/src/serve/hub-app/identities-st.ts +210 -0
  218. package/src/serve/hub-app/identities-view.tsx +353 -0
  219. package/src/serve/hub-app/identities.css +48 -0
  220. package/src/serve/hub-app/identity-address.ts +52 -0
  221. package/src/serve/hub-app/inbox-st.ts +60 -7
  222. package/src/serve/hub-app/inbox-view.tsx +49 -7
  223. package/src/serve/hub-app/inbox.css +12 -1
  224. package/src/serve/hub-app/index.html +3 -0
  225. package/src/serve/hub-app/kept-cols.tsx +30 -0
  226. package/src/serve/hub-app/keys.ts +10 -2
  227. package/src/serve/hub-app/list-walk.ts +89 -0
  228. package/src/serve/hub-app/machine-st.ts +12 -0
  229. package/src/serve/hub-app/media-svc.ts +1 -1
  230. package/src/serve/hub-app/media-view.tsx +2 -1
  231. package/src/serve/hub-app/pages-frames.tsx +134 -0
  232. package/src/serve/hub-app/pages-svc.ts +111 -0
  233. package/src/serve/hub-app/palette-st.ts +18 -3
  234. package/src/serve/hub-app/palette-view.tsx +9 -2
  235. package/src/serve/hub-app/planned-view.tsx +2 -1
  236. package/src/serve/hub-app/project-list.css +18 -14
  237. package/src/serve/hub-app/project-list.tsx +88 -49
  238. package/src/serve/hub-app/projects-svc.ts +33 -3
  239. package/src/serve/hub-app/repo-sections.ts +19 -2
  240. package/src/serve/hub-app/repo-st.ts +76 -20
  241. package/src/serve/hub-app/review/review-board.tsx +1 -1
  242. package/src/serve/hub-app/review/review-cells.tsx +6 -5
  243. package/src/serve/hub-app/review/review-kit.ts +30 -7
  244. package/src/serve/hub-app/review/review-page.tsx +6 -5
  245. package/src/serve/hub-app/review/review-st.ts +34 -15
  246. package/src/serve/hub-app/review/review-thread.tsx +63 -14
  247. package/src/serve/hub-app/review/review-views.tsx +133 -51
  248. package/src/serve/hub-app/review/thread-st.ts +80 -37
  249. package/src/serve/hub-app/review/trailer-page.tsx +7 -5
  250. package/src/serve/hub-app/review/trailer-st.ts +1 -1
  251. package/src/serve/hub-app/review.css +26 -9
  252. package/src/serve/hub-app/site/site-part.tsx +173 -0
  253. package/src/serve/hub-app/site/site-st.ts +157 -0
  254. package/src/serve/hub-app/site.css +35 -0
  255. package/src/serve/hub-app/social/calendar.tsx +182 -0
  256. package/src/serve/hub-app/social/comms-page.tsx +330 -0
  257. package/src/serve/hub-app/social/kit.tsx +244 -0
  258. package/src/serve/hub-app/social/post-card.tsx +456 -0
  259. package/src/serve/hub-app/social/problems.tsx +60 -0
  260. package/src/serve/hub-app/social/social-model.ts +154 -0
  261. package/src/serve/hub-app/social/social-page.tsx +681 -0
  262. package/src/serve/hub-app/social/social-st.ts +1014 -0
  263. package/src/serve/hub-app/social.css +289 -0
  264. package/src/serve/hub-app/stores/stores-page.tsx +312 -0
  265. package/src/serve/hub-app/stores/stores-st.ts +286 -0
  266. package/src/serve/hub-app/stores.css +54 -0
  267. package/src/serve/hub-app/timeline-geometry.ts +1 -1
  268. package/src/serve/hub-app/timeline-view.tsx +3 -2
  269. package/src/serve/hub-app/tree-build.ts +6 -0
  270. package/src/serve/hub-app/tree-row.tsx +27 -4
  271. package/src/serve/hub-app/tree-svc.ts +18 -49
  272. package/src/serve/hub-app/veille/veille-page.tsx +515 -0
  273. package/src/serve/hub-app/veille/veille-st.ts +443 -0
  274. package/src/serve/hub-app/veille.css +84 -0
  275. package/src/serve/hub-runtime.ts +20 -11
  276. package/src/serve/project-gutter-route.ts +44 -12
  277. package/src/serve/run-lanes.ts +7 -4
  278. package/src/serve/same-origin.ts +1 -1
  279. package/src/serve/serve-hub.ts +20 -12
  280. package/src/serve/tracked-watch.ts +24 -3
  281. package/src/serve/warm-cell.ts +5 -1
  282. package/src/shipkit-files.ts +15 -4
  283. package/src/shipkit.ts +0 -1
  284. package/src/shot/box.ts +160 -0
  285. package/src/shot/browser-slot.ts +74 -0
  286. package/src/shot/client.ts +42 -7
  287. package/src/shot/clip-encoder.ts +108 -24
  288. package/src/shot/film-box.ts +292 -0
  289. package/src/shot/shooter.ts +71 -17
  290. package/src/shot/shot-ask.ts +10 -2
  291. package/src/shot/stepped-clip.ts +5 -4
  292. package/src/site/desk.ts +242 -0
  293. package/src/site/routes.ts +66 -0
  294. package/src/site/unit.ts +62 -0
  295. package/src/social/brands.ts +22 -0
  296. package/src/social/card-drafts.ts +24 -0
  297. package/src/social/compose.ts +97 -0
  298. package/src/social/desk-index.ts +123 -0
  299. package/src/social/desk-wire.ts +64 -0
  300. package/src/social/drafts.ts +183 -0
  301. package/src/social/house.ts +24 -0
  302. package/src/social/load.ts +332 -0
  303. package/src/social/md.ts +70 -0
  304. package/src/social/media-facts.ts +53 -0
  305. package/src/social/media-kind.ts +189 -0
  306. package/src/social/media-limit.ts +42 -0
  307. package/src/social/media-of.ts +30 -0
  308. package/src/social/migrate.ts +123 -0
  309. package/src/social/open.ts +17 -0
  310. package/src/social/post-url.ts +158 -0
  311. package/src/social/presence.ts +332 -0
  312. package/src/social/public-read.ts +53 -0
  313. package/src/social/publish/bluesky.ts +168 -0
  314. package/src/social/publish/discord.ts +76 -0
  315. package/src/social/publish/index.ts +24 -0
  316. package/src/social/publish/secret.ts +13 -0
  317. package/src/social/push.ts +37 -0
  318. package/src/social/richtext.ts +37 -0
  319. package/src/social/routes.ts +186 -0
  320. package/src/social/stats.ts +134 -0
  321. package/src/social/text.ts +267 -0
  322. package/src/social/tracker-route.ts +39 -0
  323. package/src/social/tracker.ts +255 -0
  324. package/src/social/unit.ts +53 -0
  325. package/src/social/writes.ts +130 -0
  326. package/src/start-repo.ts +14 -9
  327. package/src/stores/collection.ts +27 -0
  328. package/src/stores/desk.ts +336 -0
  329. package/src/stores/model.ts +187 -0
  330. package/src/stores/routes.ts +126 -0
  331. package/src/stores/unit.ts +57 -0
  332. package/src/suite/calibrate.ts +127 -0
  333. package/src/suite/core-counters.ts +91 -0
  334. package/src/suite/judge-suites.ts +95 -35
  335. package/src/suite/suite-cli.ts +44 -10
  336. package/src/suite/suite-cpu-preload.ts +34 -9
  337. package/src/trace/tracer.ts +12 -5
  338. package/src/trailer/adapter.ts +5 -1
  339. package/src/trailer/build.ts +45 -12
  340. package/src/trailer/ffmpeg.ts +11 -0
  341. package/src/trailer/footage.ts +30 -13
  342. package/src/trailer/grammar.ts +18 -2
  343. package/src/trailer/graph.ts +28 -6
  344. package/src/trailer/holes.ts +1 -1
  345. package/src/trailer/passage.ts +18 -6
  346. package/src/trailer/plan.ts +74 -3
  347. package/src/trailer/prune.ts +1 -1
  348. package/src/trailer/states.ts +1 -1
  349. package/src/trailer/stitch.ts +67 -26
  350. package/src/trailer/url.ts +1 -1
  351. package/src/trailer/versions.ts +24 -0
  352. package/src/trailer/words.ts +1 -1
  353. package/src/ts/gate-typecheck.ts +32 -0
  354. package/src/ts/typecheck-cli.ts +9 -11
  355. package/src/tui/run-tui.ts +1 -1
  356. package/src/tui/tui-app.tsx +0 -1
  357. package/src/tui/tui-store.ts +1 -1
  358. package/src/veille/asks.ts +155 -0
  359. package/src/veille/auto.ts +31 -0
  360. package/src/veille/batch.ts +27 -0
  361. package/src/veille/chrome.ts +127 -0
  362. package/src/veille/collection.ts +28 -0
  363. package/src/veille/desk.ts +242 -0
  364. package/src/veille/identity.ts +80 -0
  365. package/src/veille/import.ts +68 -0
  366. package/src/veille/log.ts +183 -0
  367. package/src/veille/platforms.ts +118 -0
  368. package/src/veille/reads.ts +66 -0
  369. package/src/veille/replied.ts +110 -0
  370. package/src/veille/routes.ts +185 -0
  371. package/src/veille/service.ts +81 -0
  372. package/src/veille/watch.ts +116 -0
  373. package/src/veille/worth.ts +46 -0
  374. package/src/wiki/scan-md.ts +18 -0
  375. package/src/collections/posts.ts +0 -142
  376. package/src/contracts/manifests/social.contract.ts +0 -20
  377. package/src/scaffold/files/agent-coding.md +0 -35
  378. package/src/ts/typecheck-cache.ts +0 -11
@@ -1,35 +1,44 @@
1
1
  // the commit-message predicate of the commit-msg hook, which blocks at write
2
2
  // time. mechanical text rules only, so this stays publishable.
3
+ //
4
+ // an inline " - " in a commit body is math or a key name ((1 - s), "+ and -")
5
+ // far more often than a separator, so a body blocks only the em dash (the
6
+ // tell) and an en dash outside a number range, and the subject " - " too.
7
+ // an accented proper noun is a name, not a language choice, so French needs
8
+ // two signals on one line.
3
9
 
4
10
  export type OffenseKind = 'dash' | 'language'
5
11
  export type Offense = { line: number; text: string; kind: OffenseKind; why: string }
6
12
 
7
- /** git surfaces are English, always (identity/writing-voice.md). cheap French
8
- * detector: an accented letter, or two distinct French function words on one
9
- * line. quoted spans are exempt: they carry product copy under discussion
10
- * ("Modification refusée"), not the message's own voice. single quotes stay
11
- * in (they are French apostrophes: stripping l'écran would hide the French).
12
- * `languageAllow` (repo.config hooks) exempts listed words, for proper nouns
13
- * that carry accents without being a language choice. */
13
+ /** quoted spans carry product copy or code under discussion ("Modification
14
+ * refusée", `a - b`), not the message's own voice. single quotes stay in
15
+ * (they are French apostrophes: stripping l'écran would hide the French). */
14
16
  const QUOTED_SPANS = /`[^`\n]*`|"[^"\n]*"|“[^”\n]*”|«[^»\n]*»/g
15
- const FRENCH_ACCENTS = /[àâçéèêëîïôùûœÀÂÇÉÈÊËÎÏÔÙÛŒ]/
17
+ const EM_DASH = /—/
18
+ /** an en dash between digits is a range (⌥1–6, 2026–2027), not punctuation */
19
+ const EN_DASH_PUNCT = /(?<!\d\s?)–|–(?!\s?\d)/
20
+ const ACCENTED_WORDS = /[\p{L}'’]*[àâçéèêëîïôùûœÀÂÇÉÈÊËÎÏÔÙÛŒ][\p{L}'’]*/gu
21
+ // unicode boundaries: with \b an accent is a boundary, so Hélène would hide "ne"
16
22
  const FRENCH_STOPWORDS =
17
- /\b(?:le|la|les|un|une|des|du|au|aux|et|est|sont|avec|pour|dans|sur|pas|que|qui|ne|se|ce|cette|ces|chaque|tout|toute|tous|toutes|jamais|toujours|mais|donc|sans|sous|vers|chez|depuis|encore|aussi|devient|deviennent|nouvelle|ancienne)\b/gi
23
+ /(?<!\p{L})(?:le|la|les|un|une|des|du|au|aux|et|est|sont|avec|pour|dans|sur|pas|que|qui|ne|se|ce|cette|ces|chaque|tout|toute|tous|toutes|jamais|toujours|mais|donc|sans|sous|vers|chez|depuis|encore|aussi|devient|deviennent|nouvelle|ancienne)(?!\p{L})/giu
18
24
 
19
25
  const escapeRe = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
20
26
 
27
+ /** French = two distinct signals on one line: French function words and
28
+ * accented words. one accented name (Zoé, Hélène) or one stray "et" is not a
29
+ * language. `languageAllow` (repo.config hooks) drops listed words first. */
21
30
  export function frenchHits(line: string, languageAllow: string[] = []): boolean {
22
31
  let prose = line.replace(QUOTED_SPANS, ' ')
23
32
  for (const word of languageAllow) prose = prose.replace(new RegExp(`(?:^|(?<=[^\\p{L}]))${escapeRe(word)}(?:'s)?(?=$|[^\\p{L}])`, 'giu'), ' ')
24
- if (FRENCH_ACCENTS.test(prose)) return true
25
- const words = new Set<string>()
33
+ const signals = new Set<string>()
34
+ for (const m of prose.matchAll(ACCENTED_WORDS)) signals.add(m[0].toLowerCase().replace(/['’]s$/, ''))
26
35
  // an ALL-CAPS token is an acronym (UN, EST, CE), not a French word
27
36
  for (const m of prose.matchAll(FRENCH_STOPWORDS)) {
28
37
  const w = m[0]
29
38
  if (w.length > 1 && w === w.toUpperCase()) continue
30
- words.add(w.toLowerCase())
39
+ signals.add(w.toLowerCase())
31
40
  }
32
- return words.size >= 2
41
+ return signals.size >= 2
33
42
  }
34
43
 
35
44
  /** everything below git's scissors line is the verbose-mode diff, which git
@@ -41,20 +50,20 @@ export function stripNonMessage(message: string): string {
41
50
 
42
51
  /** offenses in ONE commit message (or one commit body from `git log`).
43
52
  * `#` comment lines never land in the message and are ignored; a `Revert "…"`
44
- * title quotes the reverted subject verbatim and is exempt; a line-start
45
- * `- ` bullet is a list marker, not punctuation. */
53
+ * title quotes the reverted subject verbatim and is exempt. */
46
54
  export function commitMessageOffenses(message: string, opts?: { languageAllow?: string[] }): Offense[] {
47
55
  const offenses: Offense[] = []
48
56
  stripNonMessage(message).split('\n').forEach((raw, i) => {
49
57
  if (raw.startsWith('#')) return
50
58
  if (i === 0 && /^Revert "/.test(raw)) return
51
- if (/[—–]/.test(raw))
59
+ const prose = raw.replace(QUOTED_SPANS, ' ')
60
+ if (EM_DASH.test(prose) || EN_DASH_PUNCT.test(prose))
52
61
  offenses.push({ line: i + 1, text: raw, kind: 'dash', why: 'em/en dash: use a comma, a period, parentheses, or a new sentence' })
53
- const body = raw.replace(/^\s*[-*] /, '')
54
- if (body.includes(' - '))
55
- offenses.push({ line: i + 1, text: raw, kind: 'dash', why: 'inline " - " separator: same fix' })
62
+ // the subject is a title, where " - " is a separator and never math
63
+ else if (i === 0 && prose.includes(' - '))
64
+ offenses.push({ line: i + 1, text: raw, kind: 'dash', why: 'inline " - " separator in the subject: use a comma or a colon' })
56
65
  if (frenchHits(raw, opts?.languageAllow))
57
- offenses.push({ line: i + 1, text: raw, kind: 'language', why: 'French: git surfaces are English, always (identity/writing-voice.md); quote product copy in "…" or `…` to exempt it' })
66
+ offenses.push({ line: i + 1, text: raw, kind: 'language', why: 'French: git surfaces are English, always (preferences/writing-voice/index.md); quote product copy in "…" or `…` to exempt it' })
58
67
  })
59
68
  return offenses
60
69
  }
@@ -23,7 +23,7 @@ export const HOOK_GATES = [
23
23
  export type HookGateId = (typeof HOOK_GATES)[number]['id']
24
24
 
25
25
  /** the page that owns every commit gate */
26
- export const HOOK_GATES_OWNER = 'build/shipkit/commit-gates.md'
26
+ export const HOOK_GATES_OWNER = 'tools/shipkit/commit-gates.md'
27
27
 
28
28
  /** the whole pre-commit hook, boot included, past which it warns */
29
29
  export const HOOK_BUDGET_MS = 1_000
@@ -21,7 +21,9 @@ import { basename, join } from 'path'
21
21
  import { gitBin } from '../core/git-bin.ts'
22
22
  import { KEYWORD_FILE, MACHINE_PRIVATE } from '../core/layout.ts'
23
23
 
24
- export type LeakHit = { where: string; pattern: string; file?: string }
24
+ /** `over`: an entry with a `count` named this pattern in this file, and the
25
+ * file now holds more, so every match blocks again until a person reviews it */
26
+ export type LeakHit = { where: string; pattern: string; file?: string; over?: { count: number; found: number; source: string } }
25
27
  export type LeakWaiver = LeakHit & { reason: string; source: string }
26
28
 
27
29
  /** what a hit REPORTS. The matched string is private by construction, and a
@@ -65,6 +67,12 @@ export type LeakAllowEntry = {
65
67
  * are arithmetic, not prose, so a keyword inside one is noise. The same
66
68
  * keyword on a normal line of the same file still blocks. */
67
69
  inHashes?: boolean
70
+ /** the most matches of the pattern the file may hold: one more and every
71
+ * match blocks again. Takes exactly one exact file in `paths` and one
72
+ * pattern, so the entry reads as « this word, this file, this many ».
73
+ * No readable label rides with it: a short keyword's label is the
74
+ * keyword, and the hit and waiver lines print it outside git. */
75
+ count?: number
68
76
  }
69
77
 
70
78
  export type LeakGuardResult =
@@ -84,6 +92,11 @@ const escapeRegex = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$
84
92
  * or `desk-lamp-...` is a word that ends in `sk`, never a key */
85
93
  export const SK_KEY_ROW = 're:(?<![A-Za-z0-9_-])sk-[A-Za-z0-9_-]{20,}'
86
94
 
95
+ /** the generic secret shapes: a private key, an AWS key id, an sk- key, a GitHub token, a Slack token. Built into
96
+ * every scan (`withBuiltinRows`), never copied into a keyword file, and the rows the backup refuses a file on
97
+ * (media-store/backup/secret.ts) */
98
+ export const SECRET_ROWS: readonly string[] = ['re:-----BEGIN [A-Z ]*PRIVATE KEY-----', 're:AKIA[0-9A-Z]{16}', SK_KEY_ROW, 're:ghp_[A-Za-z0-9]{36}', 're:xox[baprs]-[A-Za-z0-9-]{10,}']
99
+
87
100
  /** rows the hooks seeded before their shape was fixed, read as the fixed
88
101
  * shape. Their id stays the seeded row, so a waiver written against its
89
102
  * fingerprint keeps working */
@@ -104,7 +117,10 @@ export function parsePatterns(text: string): ParsedPatterns {
104
117
  const row = raw.trim()
105
118
  if (row === '' || row.startsWith('#')) continue
106
119
  if (row.startsWith('re:')) {
107
- try { regexes.push({ row, re: new RegExp((SEEDED_ROW_FIXES[row] ?? row).slice(3), 'i') }) }
120
+ // a secret shape is exact, like the token it matches (a key is `sk-`, never `SK-`, which a public plugin
121
+ // name carries); every other regex row is case-insensitive
122
+ const source = SEEDED_ROW_FIXES[row] ?? row
123
+ try { regexes.push({ row, re: new RegExp(source.slice(3), SECRET_ROWS.includes(source) ? '' : 'i') }) }
108
124
  catch { /* a malformed row must not disable the whole guard */ }
109
125
  } else if (row.startsWith('w:')) {
110
126
  const word = row.slice(2).trim().toLowerCase()
@@ -116,6 +132,36 @@ export function parsePatterns(text: string): ParsedPatterns {
116
132
  return { substrings, words, regexes }
117
133
  }
118
134
 
135
+ /** the keyword text a scan reads: the built-in secret shapes, then the files' rows */
136
+ export const withBuiltinRows = (fileTexts: string[]): string => [...SECRET_ROWS, ...fileTexts].join('\n')
137
+
138
+ /** what makes two rows one row: a `w:` row and a substring row of the same word, in any case, or two `re:` rows of
139
+ * one regex (a seeded row and its fix included). null for a blank line or a comment */
140
+ function rowKey(raw: string): string | null {
141
+ const row = raw.trim()
142
+ if (row === '' || row.startsWith('#')) return null
143
+ if (row.startsWith('re:')) return SEEDED_ROW_FIXES[row] ?? row
144
+ return (row.startsWith('w:') ? row.slice(2).trim() : row).toLowerCase()
145
+ }
146
+
147
+ /** a repo's keyword file holds its ADDITIONS only: the official list is the machine's
148
+ * (~/.shipkit/private/banned-keywords.txt) and the secret shapes are built in. `copies` are the rows either already
149
+ * holds; `text` is the file without them, its comments and its own rows kept. The official row's shape wins: a
150
+ * repo's `foo` beside an official `w:foo` is a copy that stays stricter than the list decided */
151
+ export function repoAdditions(repoText: string, officialText: string): { text: string; copies: string[]; own: number } {
152
+ const held = new Set([...SECRET_ROWS, ...officialText.split('\n')].map(rowKey).filter((k): k is string => k != null))
153
+ const copies: string[] = []
154
+ let own = 0
155
+ const kept = repoText.split('\n').filter((line) => {
156
+ const k = rowKey(line)
157
+ if (k == null) return true
158
+ if (held.has(k)) { copies.push(line.trim()); return false }
159
+ own++
160
+ return true
161
+ })
162
+ return { text: kept.join('\n'), copies, own }
163
+ }
164
+
119
165
  type Span = [start: number, end: number]
120
166
 
121
167
  // a substring row is matched by a case-insensitive REGEX rather than by
@@ -132,15 +178,18 @@ const substringRegex = (s: string): RegExp => {
132
178
  }
133
179
 
134
180
  /** every occurrence of every pattern, keyed by the id a hit reports. */
135
- function occurrences(haystack: string, p: ParsedPatterns): Map<string, Span[]> {
181
+ export function occurrences(haystack: string, p: ParsedPatterns): Map<string, Span[]> {
136
182
  const found = new Map<string, Span[]>()
137
183
  const push = (id: string, span: Span): void => {
138
184
  const prev = found.get(id)
139
185
  if (prev == null) found.set(id, [span])
140
186
  else prev.push(span)
141
187
  }
142
- for (const s of p.substrings) for (const m of haystack.matchAll(substringRegex(s))) push(s, [m.index, m.index + m[0].length])
143
- for (const w of p.words) for (const m of haystack.matchAll(w.re)) push(w.word, [m.index, m.index + m[0].length])
188
+ // a cheap prefilter before each regex: a row whose lowercase text the lowercased haystack lacks cannot match, so a
189
+ // scan over a whole tarball pays one regex per row that is there, not one per row
190
+ const lower = haystack.toLowerCase()
191
+ for (const s of p.substrings) if (lower.includes(s)) for (const m of haystack.matchAll(substringRegex(s))) push(s, [m.index, m.index + m[0].length])
192
+ for (const w of p.words) if (lower.includes(w.word)) for (const m of haystack.matchAll(w.re)) push(w.word, [m.index, m.index + m[0].length])
144
193
  for (const r of p.regexes) {
145
194
  const g = new RegExp(r.re.source, r.re.flags.includes('g') ? r.re.flags : r.re.flags + 'g')
146
195
  for (const m of haystack.matchAll(g)) push(r.row, [m.index, m.index + m[0].length])
@@ -187,23 +236,28 @@ export function evaluateLeak(targets: ScanTarget[], p: ParsedPatterns, allow: Lo
187
236
  if (seen.has(key)) continue
188
237
  seen.add(key)
189
238
  const fp = patternFingerprint(id)
239
+ let over: LeakHit['over']
190
240
  const entry = allow.find((a) => {
191
241
  if (a.paths != null && !pathCovered(t.file, a.paths)) return false
192
242
  if (a.patterns != null && !a.patterns.some((x) => x === fp || x.toLowerCase() === id)) return false
243
+ if (a.count != null && (a.paths?.[0] !== t.file || spans.length > a.count)) {
244
+ if (a.paths?.[0] === t.file) over = { count: a.count, found: spans.length, source: a.source }
245
+ return false
246
+ }
193
247
  if (a.inHashes === true) {
194
248
  hashes ??= hashSpans(t.content)
195
249
  if (!spans.every((s) => inside(s, hashes!))) return false
196
250
  }
197
251
  return true
198
252
  })
199
- if (entry == null) hits.push({ where: t.where, pattern: id, file: t.file })
253
+ if (entry == null) hits.push({ where: t.where, pattern: id, file: t.file, ...(over == null ? {} : { over }) })
200
254
  else waived.push({ where: t.where, pattern: id, file: t.file, reason: entry.reason, source: entry.source })
201
255
  }
202
256
  }
203
257
  return { hits, waived }
204
258
  }
205
259
 
206
- const ALLOW_KEYS = ['reason', 'paths', 'patterns', 'inHashes']
260
+ const ALLOW_KEYS = ['reason', 'paths', 'patterns', 'inHashes', 'count']
207
261
  const FINGERPRINT = /^fp:[0-9a-f]{12}$/
208
262
 
209
263
  /** why an entry cannot be used, or null. `tracked` = the source is committed
@@ -223,6 +277,13 @@ export function leakAllowProblem(entry: unknown, where: string, tracked: boolean
223
277
  return `${where}: '${k}' is a non-empty array of non-empty strings`
224
278
  }
225
279
  if (e['inHashes'] != null && typeof e['inHashes'] !== 'boolean') return `${where}: 'inHashes' is a boolean`
280
+ if (e['count'] != null) {
281
+ const n = e['count']
282
+ if (typeof n !== 'number' || !Number.isInteger(n) || n < 1) return `${where}: 'count' is a whole number of at least 1`
283
+ const paths = e['paths'] as string[] | undefined
284
+ if (paths?.length !== 1 || paths[0]!.endsWith('/')) return `${where}: 'count' takes exactly one file in 'paths', never a folder`
285
+ if ((e['patterns'] as string[] | undefined)?.length !== 1) return `${where}: 'count' takes exactly one entry in 'patterns'`
286
+ }
226
287
  if (tracked)
227
288
  for (const x of (e['patterns'] as string[] | undefined) ?? [])
228
289
  if (!FINGERPRINT.test(x))
@@ -351,9 +412,8 @@ export function runLeakGuard(root: string, o: LeakGuardOpts = {}): LeakGuardResu
351
412
  const file = join(root, rel)
352
413
  const sources = [existsSync(file) ? file : null, globalKeywordFile()].filter((f): f is string => f != null)
353
414
  if (sources.length === 0) return { status: 'skipped', reason: `${rel} not found and no machine-global banned-keywords.txt — no keyword list, no leak guard` }
354
- const patterns = parsePatterns(sources.map((f) => readFileSync(f, 'utf8')).join('\n'))
415
+ const patterns = parsePatterns(withBuiltinRows(sources.map((f) => readFileSync(f, 'utf8'))))
355
416
  const count = patterns.substrings.length + patterns.words.length + patterns.regexes.length
356
- if (count === 0) return { status: 'skipped', reason: `keyword file(s) have no patterns (${sources.join(', ')})` }
357
417
 
358
418
  const notes: string[] = []
359
419
  const allow: LoadedAllow[] = []
@@ -8,7 +8,7 @@ import { dirname, join, relative } from 'path'
8
8
  import { fileURLToPath } from 'url'
9
9
  import { KEYWORD_FILE, LAYOUT } from '../core/layout.ts'
10
10
  import { commitMessageOffenses } from './commit-message.ts'
11
- import { globalAllowFile, globalKeywordFile, maskPattern, patternFingerprint, runLeakGuard, SK_KEY_ROW, type LeakAllowEntry, type LeakHit, type LeakWaiver } from './leak-guard.ts'
11
+ import { globalAllowFile, globalKeywordFile, maskPattern, patternFingerprint, runLeakGuard, type LeakAllowEntry, type LeakHit, type LeakWaiver } from './leak-guard.ts'
12
12
  import { runRootIdentity } from './root-identity.ts'
13
13
  import { readStaged } from './staged.ts'
14
14
  import { ALLOW_MASS_DELETE, runTreeShrink } from './tree-shrink.ts'
@@ -62,7 +62,7 @@ export type HooksConfig = {
62
62
  languageAllow?: string[]
63
63
  /** RETIRED, read as `off` while SK029 ports it there: a commit gate is
64
64
  * turned off like any check, `off: { <gate id>: '<why>' }`
65
- * (build/shipkit/runs.md). Dies once `shipkit fleet` shows no repo
65
+ * (tools/shipkit/runs.md). Dies once `shipkit fleet` shows no repo
66
66
  * carrying it */
67
67
  disable?: HookGateId[]
68
68
  }
@@ -152,31 +152,27 @@ export function installHooks(root: string, binInvocation: string, keywordFile?:
152
152
  }
153
153
  }
154
154
 
155
- // a starter so the leak guard bites from day one instead of skipping forever:
156
- // generic secret shapes only. private names live in the machine-global
157
- // ~/.shipkit/private/banned-keywords.txt, which the guard reads on every run
158
- // (never copied into a repo: a copy rots and a copy can leak)
159
- export const KEYWORD_STARTER = `# banned-keywords — the leak guard greps every commit (added lines, paths,
160
- # message) for these rows. one row = one case-insensitive substring, or
161
- # re:<regex>. add repo-specific names here; machine-wide private names go in
162
- # ~/.shipkit/private/banned-keywords.txt, read automatically alongside this file.
155
+ // a starter that names what belongs here: this repo's ADDITIONS. The official list is the machine's
156
+ // ~/.shipkit/private/banned-keywords.txt and the secret shapes are built into the guard, so neither is copied
157
+ // into a repo (a copy rots: SK037 strips one)
158
+ export const KEYWORD_STARTER = `# banned-keywords: THIS repo's additions to the leak guard, which greps every
159
+ # commit (added lines, paths, message) and every npm tarball for these rows.
160
+ # one row = one case-insensitive substring, w:<word> (whole words), or re:<regex>.
161
+ # the official list is ~/.shipkit/private/banned-keywords.txt and the generic
162
+ # secret shapes are built in: both are read with this file, never copied here.
163
+ # a word the list bans that this repo must say: repo.config.ts hooks.leakAllow.
163
164
  # this file is gitignored on purpose: the list itself is private.
164
- re:-----BEGIN [A-Z ]*PRIVATE KEY-----
165
- re:AKIA[0-9A-Z]{16}
166
- ${SK_KEY_ROW}
167
- re:ghp_[A-Za-z0-9]{36}
168
- re:xox[baprs]-[A-Za-z0-9-]{10,}
169
165
  `
170
166
 
171
- /** seed the configured keyword file with the generic starter so the guard is
172
- * ARMED, not a skip. an existing file is never touched. */
167
+ /** seed the configured keyword file with the starter: its presence ARMS the guard (the built-in secret shapes
168
+ * scan from then on), and it says what the repo adds. an existing file is never touched. */
173
169
  function seedKeywordFile(root: string, keywordFile?: string): string | null {
174
170
  const rel = keywordFile ?? KEYWORD_FILE
175
171
  const dest = join(root, rel)
176
172
  if (existsSync(dest)) return null
177
173
  mkdirSync(dirname(dest), { recursive: true })
178
174
  writeFileSync(dest, KEYWORD_STARTER)
179
- return `${rel} (starter shapes)`
175
+ return `${rel} (the repo's additions, empty)`
180
176
  }
181
177
 
182
178
  export type GateOutcome = { id: string; ok: boolean; lines: string[] }
@@ -186,7 +182,7 @@ export type GateOutcome = { id: string; ok: boolean; lines: string[] }
186
182
  * exempt it. The file rides along for a content hit; a staged-PATH hit adds
187
183
  * nothing, because there the path IS what matched. */
188
184
  const hitLine = (x: LeakHit): string =>
189
- ` ${x.where}${x.where === 'staged content' && x.file != null ? ` ${x.file}` : ''}: ${maskPattern(x.pattern)} [${patternFingerprint(x.pattern)}]`
185
+ ` ${x.where}${x.where === 'staged content' && x.file != null ? ` ${x.file}` : ''}: ${maskPattern(x.pattern)} [${patternFingerprint(x.pattern)}]${x.over == null ? '' : `, ${x.over.found} added where ${x.over.source} allows ${x.over.count}`}`
190
186
 
191
187
  /** what the allowlist let through, one line per waiver. An allowlist that
192
188
  * fires invisibly is a silent weakening, so a waived match is as loud as a
@@ -219,7 +215,7 @@ export function blockedStaged(staged: string[], config: RepoConfig): string[] {
219
215
  const draftsOpen = (c: RepoConfig): boolean => c.visibility === 'private'
220
216
 
221
217
  /** the pre-commit gate: built-in leak guard, then the repo's own commands.
222
- * A commit takes ~1s (build/shipkit/commit-gates.md): the gate times itself, and going
218
+ * A commit takes ~1s (tools/shipkit/commit-gates.md): the gate times itself, and going
223
219
  * over budget WARNs naming the fix, so drift back to slow commits is loud. */
224
220
  export async function runPreCommit(root: string, config: RepoConfig): Promise<GateOutcome[]> {
225
221
  const started = performance.now()
@@ -311,7 +307,7 @@ export async function runPreCommit(root: string, config: RepoConfig): Promise<Ga
311
307
  out.push({
312
308
  id: 'hook-budget',
313
309
  ok: true,
314
- lines: [`WARN pre-commit took ${(elapsed / 1000).toFixed(1)}s (budget ${HOOK_BUDGET_MS / 1000}s) — move slow preCommit commands to ci tasks, or a check off onPreCommit (build/shipkit/runs.md)`],
310
+ lines: [`WARN pre-commit took ${(elapsed / 1000).toFixed(1)}s (budget ${HOOK_BUDGET_MS / 1000}s) — move slow preCommit commands to ci tasks, or a check off onPreCommit (tools/shipkit/runs.md)`],
315
311
  })
316
312
  return out
317
313
  }
@@ -351,7 +347,7 @@ async function runPreCommitChecks(root: string, config: RepoConfig): Promise<Gat
351
347
  out.push({
352
348
  id: 'slow-import',
353
349
  ok: true,
354
- lines: [`WARN ${relative(root, s.path)} took ${Math.round(s.ms)}ms to import, over ${SLOW_IMPORT_MS}ms: every surface that lists the checks pays it, so move its heavy imports inside \`run\` (build/shipkit/writing-a-check.md)`],
350
+ lines: [`WARN ${relative(root, s.path)} took ${Math.round(s.ms)}ms to import, over ${SLOW_IMPORT_MS}ms: every surface that lists the checks pays it, so move its heavy imports inside \`run\` (tools/shipkit/writing-a-check.md)`],
355
351
  })
356
352
  const pass = new CheckPass(root, config, undefined, false)
357
353
  for (const k of found.checks) {