rvlib-shipkit 2.29.0 → 2.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (512) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/package.json +2 -1
  3. package/src/advisors/app-graph.ts +1 -1
  4. package/src/advisors/expose.ts +5 -1
  5. package/src/advisors/r2.ts +7 -9
  6. package/src/advisors/routes.ts +29 -2
  7. package/src/advisors/scan.ts +11 -0
  8. package/src/agent-time/accounts-usage.ts +8 -0
  9. package/src/agent-time/claude-sessions.ts +32 -0
  10. package/src/agent-time/hooks.ts +1 -1
  11. package/src/agent-time/live.ts +5 -2
  12. package/src/agent-time/registry.ts +186 -89
  13. package/src/agent-time/store.ts +6 -4
  14. package/src/asks/ask-doc.ts +2 -2
  15. package/src/asks/ask-store.ts +22 -7
  16. package/src/check.ts +9 -1
  17. package/src/checks/SK001-package-json-shape.check.ts +1 -0
  18. package/src/checks/SK003-claude-md-shape.check.ts +1 -0
  19. package/src/checks/SK004-gitignore-policy.check.ts +12 -6
  20. package/src/checks/SK008-reviewer-agent.check.ts +4 -7
  21. package/src/checks/SK013-one-way-in-policy.check.ts +1 -0
  22. package/src/checks/SK017-vscode-hub-task.check.ts +1 -0
  23. package/src/checks/SK024-identity-colors.check.ts +1 -1
  24. package/src/checks/SK027-agent-wiki-links.check.ts +2 -1
  25. package/src/checks/SK033-global-contribution.check.ts +1 -0
  26. package/src/checks/SK034-commit-gates-armed.check.ts +1 -0
  27. package/src/checks/SK039-vscode-watch-generated.check.ts +1 -0
  28. package/src/checks/SK049-thread-answers-hook.check.ts +9 -5
  29. package/src/checks/SK050-retired-commands.check.ts +1 -0
  30. package/src/checks/SK051-no-formatter.check.ts +1 -0
  31. package/src/cli/channel-run.ts +17 -0
  32. package/src/cli/cmd_Advisors.ts +28 -7
  33. package/src/cli/cmd_Asks.ts +2 -2
  34. package/src/cli/cmd_Backup.ts +5 -1
  35. package/src/cli/cmd_CacheAudit.ts +1 -1
  36. package/src/cli/cmd_Channel.ts +43 -0
  37. package/src/cli/cmd_GlobalProcesses.ts +1 -0
  38. package/src/cli/cmd_Home.ts +12 -5
  39. package/src/cli/cmd_Hooks.ts +1 -1
  40. package/src/cli/cmd_Hq.ts +43 -0
  41. package/src/cli/cmd_Lanes.ts +15 -3
  42. package/src/cli/cmd_Media.ts +8 -3
  43. package/src/cli/cmd_Orchestrator.ts +253 -84
  44. package/src/cli/cmd_OrchestratorRole.ts +163 -0
  45. package/src/cli/cmd_Review.ts +142 -165
  46. package/src/cli/cmd_Secret.ts +44 -14
  47. package/src/cli/cmd_Shot.ts +2 -4
  48. package/src/cli/cmd_Sound.ts +1 -0
  49. package/src/cli/cmd_Urls.ts +3 -3
  50. package/src/cli/inbox-hook-run.ts +109 -0
  51. package/src/cli/registry.ts +6 -2
  52. package/src/cli/review-here.ts +136 -0
  53. package/src/cli.ts +45 -14
  54. package/src/collections/actions.ts +5 -4
  55. package/src/collections/checks.ts +5 -0
  56. package/src/collections/collection-types.ts +4 -3
  57. package/src/collections/pings.ts +4 -1
  58. package/src/collections/providers.ts +6 -4
  59. package/src/collections/tests.ts +7 -4
  60. package/src/core/app-icon-frame.ts +62 -0
  61. package/src/core/app-icon.ts +179 -17
  62. package/src/core/archived.ts +10 -7
  63. package/src/core/check-ctx.ts +38 -4
  64. package/src/core/check-pass.ts +7 -0
  65. package/src/core/foreign.ts +87 -0
  66. package/src/core/gui-color.ts +75 -0
  67. package/src/core/hub-theme.ts +1 -3
  68. package/src/core/layout.ts +3 -0
  69. package/src/core/machine-commit.ts +9 -1
  70. package/src/core/one-lib.ts +2 -1
  71. package/src/core/one-way-in-policy.ts +17 -12
  72. package/src/core/owner-word-policy.ts +123 -0
  73. package/src/core/panel-shades.ts +140 -0
  74. package/src/core/repo-gui-color.ts +16 -0
  75. package/src/core/role-policy.ts +17 -0
  76. package/src/core/scope.ts +6 -3
  77. package/src/core/tmux-policy.ts +264 -0
  78. package/src/core/unit-icon.ts +43 -0
  79. package/src/fleet/push-fleet.ts +2 -0
  80. package/src/fleet/scan-fleet.ts +3 -0
  81. package/src/gate/cache-audit.ts +7 -1
  82. package/src/gate/gate-checks.ts +14 -9
  83. package/src/gate/run-fix.ts +30 -5
  84. package/src/gate/run-fixers.ts +8 -3
  85. package/src/home/activity-shape.ts +2 -0
  86. package/src/home/activity.ts +2 -1
  87. package/src/home/daemon-guard.ts +20 -2
  88. package/src/home/daemon-jobs.ts +26 -18
  89. package/src/home/gui-app/ShipkitGui.swift +2012 -144
  90. package/src/home/gui-app/icon.svg +8 -0
  91. package/src/home/gui-app.ts +94 -30
  92. package/src/home/home-routes.ts +53 -9
  93. package/src/home/home-start.ts +27 -3
  94. package/src/home/inbox-shape.ts +7 -3
  95. package/src/home/log-follow.ts +117 -0
  96. package/src/home/machine-fold.ts +1 -1
  97. package/src/home/open-app.ts +9 -3
  98. package/src/home/page-build.ts +5 -1
  99. package/src/home/page-held.ts +1 -1
  100. package/src/home/pm-config.ts +0 -8
  101. package/src/home/pm.ts +62 -5
  102. package/src/home/process-apps.ts +70 -23
  103. package/src/home/process-rows.ts +16 -1
  104. package/src/home/push-sources.ts +18 -13
  105. package/src/home/resources.ts +16 -7
  106. package/src/home/run-daemon.ts +4 -1
  107. package/src/home/run-pm.ts +1 -1
  108. package/src/home/serve-daemon.ts +13 -4
  109. package/src/home/serve-web.ts +141 -17
  110. package/src/home/space-page.ts +3 -3
  111. package/src/home/space-route.ts +2 -2
  112. package/src/home/supervise.ts +2 -1
  113. package/src/home/vault-page.ts +2 -1
  114. package/src/home/web-places.ts +239 -0
  115. package/src/home/widgets.ts +16 -2
  116. package/src/hooks/commit-message.ts +11 -9
  117. package/src/hooks/one-way-in-guard.ts +145 -68
  118. package/src/hooks/run-hooks.ts +15 -5
  119. package/src/hooks/shared-file.ts +273 -83
  120. package/src/hooks/shell-writes.ts +620 -0
  121. package/src/hooks/write-log.ts +149 -0
  122. package/src/hq/door-route.ts +63 -7
  123. package/src/hq/door.ts +45 -12
  124. package/src/hq/history-send.ts +3 -1
  125. package/src/hq/hq-db.ts +10 -3
  126. package/src/hq/hq-local.ts +24 -5
  127. package/src/hq/hq-routes.ts +3 -1
  128. package/src/hq/hq-store.ts +9 -3
  129. package/src/hq/kinds/index.ts +2 -1
  130. package/src/hq/kinds/kind.ts +9 -4
  131. package/src/hq/kinds/presence-rule.ts +56 -0
  132. package/src/hq/kinds/presence.ts +210 -0
  133. package/src/hq/kinds/report.ts +8 -5
  134. package/src/hq/lead-order.ts +68 -0
  135. package/src/hq/outbox.ts +7 -0
  136. package/src/hq/replica.ts +5 -7
  137. package/src/hq/report-facts.ts +14 -7
  138. package/src/hq/report.ts +47 -2
  139. package/src/hq/switch.ts +1 -0
  140. package/src/hq/terminal-hop.ts +64 -0
  141. package/src/hq/thread-sync.ts +13 -6
  142. package/src/http/door-forward.ts +10 -12
  143. package/src/http/door-names.ts +9 -0
  144. package/src/http/hop-caller.ts +23 -0
  145. package/src/http/hop-names.ts +14 -0
  146. package/src/http/loopback-serve.ts +28 -6
  147. package/src/http/owner-word.ts +128 -0
  148. package/src/http/same-origin.ts +12 -0
  149. package/src/{serve → http}/secret-gate.ts +3 -3
  150. package/src/ledger/run-log.ts +25 -1
  151. package/src/media-store/backup/sources.ts +53 -6
  152. package/src/media-store/backup/thread-copy.ts +9 -5
  153. package/src/media-store/copy/config.ts +10 -9
  154. package/src/media-store/daemon.ts +5 -2
  155. package/src/media-store/put.ts +3 -0
  156. package/src/media-store/space.ts +14 -16
  157. package/src/media-store/upload.ts +4 -0
  158. package/src/messages/collection.ts +2 -2
  159. package/src/messages/model.ts +6 -1
  160. package/src/messages/routes.ts +3 -0
  161. package/src/orchestrator/brief.md +8 -6
  162. package/src/orchestrator/channel-declare.ts +58 -0
  163. package/src/orchestrator/channel.ts +226 -0
  164. package/src/orchestrator/guards.ts +12 -3
  165. package/src/orchestrator/host.ts +35 -0
  166. package/src/orchestrator/lead-shape.ts +86 -0
  167. package/src/orchestrator/now.ts +88 -0
  168. package/src/orchestrator/phone.ts +4 -1
  169. package/src/orchestrator/places-file.ts +38 -0
  170. package/src/orchestrator/places-look.ts +180 -0
  171. package/src/orchestrator/places-shape.ts +151 -0
  172. package/src/orchestrator/places.ts +50 -0
  173. package/src/orchestrator/presence-shape.ts +13 -2
  174. package/src/orchestrator/presence.ts +26 -15
  175. package/src/orchestrator/push.ts +5 -10
  176. package/src/orchestrator/role-shape.ts +270 -0
  177. package/src/orchestrator/role.ts +242 -0
  178. package/src/orchestrator/routes.ts +136 -31
  179. package/src/orchestrator/sessions-shape.ts +78 -0
  180. package/src/orchestrator/sessions.ts +86 -0
  181. package/src/orchestrator/share.ts +71 -0
  182. package/src/orchestrator/start-notice.ts +61 -0
  183. package/src/orchestrator/start.ts +137 -0
  184. package/src/orchestrator/started.ts +55 -0
  185. package/src/orchestrator/stuck.ts +196 -0
  186. package/src/orchestrator/unheard.ts +18 -7
  187. package/src/pages/frame-client.ts +44 -6
  188. package/src/problems/failure-words.ts +80 -0
  189. package/src/release/run-bump.ts +26 -5
  190. package/src/release/run-release.ts +34 -14
  191. package/src/repo-config.ts +37 -9
  192. package/src/review/aside-at.ts +19 -0
  193. package/src/review/band.ts +3 -3
  194. package/src/review/doc-save.ts +1 -1
  195. package/src/review/inbox-hook.ts +12 -4
  196. package/src/review/inbox-read.ts +20 -7
  197. package/src/review/instruction-guards.ts +137 -0
  198. package/src/review/instructions.ts +14 -2
  199. package/src/review/item-db.ts +52 -2
  200. package/src/review/mentions.ts +6 -4
  201. package/src/review/model.ts +3 -2
  202. package/src/review/parties.ts +88 -19
  203. package/src/review/push.ts +32 -15
  204. package/src/review/routes.ts +12 -4
  205. package/src/review/secret-route.ts +5 -5
  206. package/src/review/snooze.ts +1 -16
  207. package/src/review/store-parties.ts +4 -2
  208. package/src/review/take-back.ts +2 -1
  209. package/src/review/threads.ts +13 -2
  210. package/src/review/unit.ts +3 -2
  211. package/src/review/view-layout.ts +8 -1
  212. package/src/review/watchers.ts +25 -4
  213. package/src/secrets/key-pair.ts +14 -0
  214. package/src/secrets/lapse.ts +3 -3
  215. package/src/secrets/manager.ts +5 -1
  216. package/src/secrets/name-template.ts +83 -0
  217. package/src/secrets/name.ts +3 -0
  218. package/src/secrets/read.ts +10 -6
  219. package/src/secrets/secrets-view.ts +299 -0
  220. package/src/secrets/who-reads.ts +2 -1
  221. package/src/serve/frame-part.ts +49 -0
  222. package/src/serve/hub-app/accounts-line.tsx +33 -45
  223. package/src/serve/hub-app/activity-st.ts +6 -5
  224. package/src/serve/hub-app/activity-view.tsx +10 -9
  225. package/src/serve/hub-app/advice-box.tsx +6 -5
  226. package/src/serve/hub-app/advisor-app.tsx +2 -0
  227. package/src/serve/hub-app/advisor-face.tsx +3 -2
  228. package/src/serve/hub-app/advisor.html +1 -0
  229. package/src/serve/hub-app/advisors-view.tsx +52 -10
  230. package/src/serve/hub-app/advisors.css +4 -0
  231. package/src/serve/hub-app/app-bridge.ts +31 -5
  232. package/src/serve/hub-app/asked-page.ts +24 -0
  233. package/src/serve/hub-app/asks-page.tsx +10 -6
  234. package/src/serve/hub-app/auto-text.tsx +7 -5
  235. package/src/serve/hub-app/card-head.tsx +3 -2
  236. package/src/serve/hub-app/check-view.tsx +10 -9
  237. package/src/serve/hub-app/checks-svc.ts +96 -32
  238. package/src/serve/hub-app/clock-svc.ts +24 -8
  239. package/src/serve/hub-app/code-copy.ts +1 -1
  240. package/src/serve/hub-app/col-card.tsx +2 -1
  241. package/src/serve/hub-app/col-list-page.tsx +12 -6
  242. package/src/serve/hub-app/col-list-st.ts +12 -2
  243. package/src/serve/hub-app/col-tables-view.tsx +8 -44
  244. package/src/serve/hub-app/col-tables.ts +0 -14
  245. package/src/serve/hub-app/cols-svc.ts +6 -12
  246. package/src/serve/hub-app/columns.ts +94 -0
  247. package/src/serve/hub-app/comfy-view.tsx +8 -7
  248. package/src/serve/hub-app/commands/commands-page.tsx +4 -3
  249. package/src/serve/hub-app/commands/commands-st.ts +2 -2
  250. package/src/serve/hub-app/controls.css +69 -23
  251. package/src/serve/hub-app/cycle-button.tsx +2 -1
  252. package/src/serve/hub-app/database-st.ts +1 -1
  253. package/src/serve/hub-app/database-view.tsx +4 -2
  254. package/src/serve/hub-app/deaf.tsx +27 -0
  255. package/src/serve/hub-app/dock-st.ts +21 -16
  256. package/src/serve/hub-app/dock-view.tsx +19 -12
  257. package/src/serve/hub-app/empty-section.tsx +30 -0
  258. package/src/serve/hub-app/entry-bar.css +1 -1
  259. package/src/serve/hub-app/entry-bar.tsx +11 -6
  260. package/src/serve/hub-app/entry-list.css +32 -0
  261. package/src/serve/hub-app/entry-list.tsx +123 -0
  262. package/src/serve/hub-app/entry-pick.ts +1 -1
  263. package/src/serve/hub-app/entry-sections.ts +140 -0
  264. package/src/serve/hub-app/event-stream-reader.ts +56 -0
  265. package/src/serve/hub-app/floating.tsx +68 -14
  266. package/src/serve/hub-app/geometry-view.tsx +3 -2
  267. package/src/serve/hub-app/git-view.tsx +3 -2
  268. package/src/serve/hub-app/hash-route.ts +14 -2
  269. package/src/serve/hub-app/header-bar.tsx +53 -36
  270. package/src/serve/hub-app/home-st.ts +131 -14
  271. package/src/serve/hub-app/home-strip.css +24 -13
  272. package/src/serve/hub-app/home-strip.tsx +131 -66
  273. package/src/serve/hub-app/home.html +5 -0
  274. package/src/serve/hub-app/hub-app.tsx +94 -102
  275. package/src/serve/hub-app/hub.css +61 -94
  276. package/src/serve/hub-app/icons.tsx +16 -0
  277. package/src/serve/hub-app/identities-st.ts +19 -54
  278. package/src/serve/hub-app/identities-view.tsx +25 -24
  279. package/src/serve/hub-app/identity-address.ts +2 -2
  280. package/src/serve/hub-app/in-sight.ts +10 -0
  281. package/src/serve/hub-app/inbox-st.ts +20 -2
  282. package/src/serve/hub-app/inbox-view.tsx +16 -9
  283. package/src/serve/hub-app/inbox.css +1 -0
  284. package/src/serve/hub-app/index.html +5 -0
  285. package/src/serve/hub-app/insights-view.tsx +6 -5
  286. package/src/serve/hub-app/instructions.css +4 -1
  287. package/src/serve/hub-app/kept-cols.tsx +83 -20
  288. package/src/serve/hub-app/kept-width.tsx +76 -0
  289. package/src/serve/hub-app/keys.ts +116 -38
  290. package/src/serve/hub-app/layout-st.ts +109 -99
  291. package/src/serve/hub-app/lightbox-zoom.css +36 -0
  292. package/src/serve/hub-app/list-filter.tsx +15 -6
  293. package/src/serve/hub-app/list-head.tsx +29 -0
  294. package/src/serve/hub-app/list-row.ts +8 -0
  295. package/src/serve/hub-app/list-walk.ts +26 -105
  296. package/src/serve/hub-app/live-socket.ts +274 -0
  297. package/src/serve/hub-app/live-sources.ts +189 -0
  298. package/src/serve/hub-app/live-svc.ts +2 -2
  299. package/src/serve/hub-app/machine-st.ts +75 -14
  300. package/src/serve/hub-app/main-panel.css +211 -0
  301. package/src/serve/hub-app/main-panel.tsx +259 -0
  302. package/src/serve/hub-app/md.ts +4 -4
  303. package/src/serve/hub-app/media-svc.ts +5 -5
  304. package/src/serve/hub-app/media-view.tsx +13 -12
  305. package/src/serve/hub-app/messages/messages-page.tsx +8 -7
  306. package/src/serve/hub-app/messages/messages-st.ts +5 -2
  307. package/src/serve/hub-app/new-thread-st.ts +170 -0
  308. package/src/serve/hub-app/new-thread.tsx +133 -107
  309. package/src/serve/hub-app/orchestrator-line.tsx +115 -45
  310. package/src/serve/hub-app/orchestrator-places.tsx +86 -0
  311. package/src/serve/hub-app/orchestrator.css +57 -5
  312. package/src/serve/hub-app/page-keys.ts +107 -68
  313. package/src/serve/hub-app/page-reload.ts +46 -6
  314. package/src/serve/hub-app/pages-frames.tsx +40 -3
  315. package/src/serve/hub-app/pages-svc.ts +3 -1
  316. package/src/serve/hub-app/palette-st.ts +198 -43
  317. package/src/serve/hub-app/palette-view.tsx +32 -8
  318. package/src/serve/hub-app/panel-head-action.tsx +39 -0
  319. package/src/serve/hub-app/panel-head.tsx +70 -0
  320. package/src/serve/hub-app/panel-repo.ts +42 -0
  321. package/src/serve/hub-app/panel-source.ts +195 -0
  322. package/src/serve/hub-app/panel-tint.css +6 -0
  323. package/src/serve/hub-app/panel-tint.ts +23 -0
  324. package/src/serve/hub-app/panel-walk.ts +107 -0
  325. package/src/serve/hub-app/pill-row.tsx +2 -1
  326. package/src/serve/hub-app/place-path.ts +4 -0
  327. package/src/serve/hub-app/places-svc.ts +75 -0
  328. package/src/serve/hub-app/plan-view.tsx +3 -2
  329. package/src/serve/hub-app/polled.ts +11 -1
  330. package/src/serve/hub-app/presence-st.ts +66 -32
  331. package/src/serve/hub-app/processes-view.tsx +2 -2
  332. package/src/serve/hub-app/project-bar.tsx +116 -0
  333. package/src/serve/hub-app/project-list.css +20 -173
  334. package/src/serve/hub-app/project-list.tsx +30 -298
  335. package/src/serve/hub-app/projects-svc.ts +59 -32
  336. package/src/serve/hub-app/push-sign.tsx +2 -1
  337. package/src/serve/hub-app/push-svc.ts +86 -69
  338. package/src/serve/hub-app/quiet-st.ts +5 -3
  339. package/src/serve/hub-app/rail-groups.ts +144 -0
  340. package/src/serve/hub-app/reader-chips.tsx +2 -1
  341. package/src/serve/hub-app/recordings-st.ts +2 -1
  342. package/src/serve/hub-app/recordings-view.tsx +19 -47
  343. package/src/serve/hub-app/recordings.css +0 -2
  344. package/src/serve/hub-app/reflections-page.tsx +10 -6
  345. package/src/serve/hub-app/releases/releases-page.tsx +6 -5
  346. package/src/serve/hub-app/repo-sections.ts +127 -38
  347. package/src/serve/hub-app/repo-st.ts +57 -36
  348. package/src/serve/hub-app/review/advisor-bar.tsx +3 -2
  349. package/src/serve/hub-app/review/ask-proof.tsx +79 -0
  350. package/src/serve/hub-app/review/attach-view.tsx +11 -10
  351. package/src/serve/hub-app/review/box-view.ts +479 -0
  352. package/src/serve/hub-app/review/box-zoom.tsx +70 -0
  353. package/src/serve/hub-app/review/diff-view.tsx +3 -2
  354. package/src/serve/hub-app/review/doc-body.tsx +2 -1
  355. package/src/serve/hub-app/review/dock.tsx +3 -2
  356. package/src/serve/hub-app/review/draft-body.tsx +4 -3
  357. package/src/serve/hub-app/review/faces.tsx +0 -8
  358. package/src/serve/hub-app/review/group-block.tsx +8 -7
  359. package/src/serve/hub-app/review/heard-line.tsx +4 -3
  360. package/src/serve/hub-app/review/instructions-view.tsx +3 -2
  361. package/src/serve/hub-app/review/item-verdict.tsx +40 -40
  362. package/src/serve/hub-app/review/kind-states.tsx +5 -4
  363. package/src/serve/hub-app/review/kit.tsx +24 -4
  364. package/src/serve/hub-app/review/lane-bar.tsx +30 -28
  365. package/src/serve/hub-app/review/lightbox.tsx +6 -4
  366. package/src/serve/hub-app/review/live-bar.tsx +7 -6
  367. package/src/serve/hub-app/review/live-view.tsx +6 -5
  368. package/src/serve/hub-app/review/object-card.tsx +2 -1
  369. package/src/serve/hub-app/review/object-panel.tsx +11 -10
  370. package/src/serve/hub-app/review/pano-view.tsx +3 -2
  371. package/src/serve/hub-app/review/question-views.tsx +6 -5
  372. package/src/serve/hub-app/review/review-cells.tsx +21 -20
  373. package/src/serve/hub-app/review/review-host.ts +3 -0
  374. package/src/serve/hub-app/review/review-kit.ts +7 -5
  375. package/src/serve/hub-app/review/review-list.tsx +98 -52
  376. package/src/serve/hub-app/review/review-page.tsx +3 -3
  377. package/src/serve/hub-app/review/review-st.ts +70 -14
  378. package/src/serve/hub-app/review/review-thread.tsx +234 -138
  379. package/src/serve/hub-app/review/review-views.tsx +166 -191
  380. package/src/serve/hub-app/review/space3d.tsx +17 -9
  381. package/src/serve/hub-app/review/thread-close.tsx +24 -32
  382. package/src/serve/hub-app/review/thread-st.ts +39 -25
  383. package/src/serve/hub-app/review/trailer-body.tsx +5 -4
  384. package/src/serve/hub-app/review/trailer-page.tsx +18 -16
  385. package/src/serve/hub-app/review/trailer-st.ts +3 -2
  386. package/src/serve/hub-app/review/trailer-timeline.tsx +10 -9
  387. package/src/serve/hub-app/review/trailer-voices.tsx +29 -28
  388. package/src/serve/hub-app/review.css +159 -42
  389. package/src/serve/hub-app/row-acts.tsx +126 -0
  390. package/src/serve/hub-app/row-face.tsx +29 -0
  391. package/src/serve/hub-app/running-rows.tsx +142 -0
  392. package/src/serve/hub-app/running-st.ts +110 -0
  393. package/src/serve/hub-app/search-view.tsx +3 -2
  394. package/src/serve/hub-app/secrets-page.tsx +290 -0
  395. package/src/serve/hub-app/secrets-st.ts +181 -0
  396. package/src/serve/hub-app/secrets.css +65 -0
  397. package/src/serve/hub-app/section-head.tsx +3 -2
  398. package/src/serve/hub-app/session-chips.tsx +55 -0
  399. package/src/serve/hub-app/shell.ts +56 -0
  400. package/src/serve/hub-app/site/site-part.tsx +6 -5
  401. package/src/serve/hub-app/site/site-st.ts +0 -6
  402. package/src/serve/hub-app/site.css +0 -1
  403. package/src/serve/hub-app/social/calendar.tsx +7 -6
  404. package/src/serve/hub-app/social/comms-page.tsx +29 -26
  405. package/src/serve/hub-app/social/group-editor.tsx +2 -1
  406. package/src/serve/hub-app/social/kit.tsx +12 -11
  407. package/src/serve/hub-app/social/next-release.tsx +3 -2
  408. package/src/serve/hub-app/social/post-card.tsx +21 -20
  409. package/src/serve/hub-app/social/post-page.tsx +2 -1
  410. package/src/serve/hub-app/social/problems.tsx +3 -2
  411. package/src/serve/hub-app/social/social-page.tsx +29 -27
  412. package/src/serve/hub-app/social/social-st.ts +4 -2
  413. package/src/serve/hub-app/social/stage-popup.tsx +11 -10
  414. package/src/serve/hub-app/social.css +7 -5
  415. package/src/serve/hub-app/source-acts.ts +79 -0
  416. package/src/serve/hub-app/source-page.tsx +17 -0
  417. package/src/serve/hub-app/space-view.tsx +5 -4
  418. package/src/serve/hub-app/stores/stores-page.tsx +21 -19
  419. package/src/serve/hub-app/stores/stores-st.ts +1 -1
  420. package/src/serve/hub-app/stores.css +1 -1
  421. package/src/serve/hub-app/terminal-history-st.ts +112 -0
  422. package/src/serve/hub-app/terminal-keys.ts +79 -0
  423. package/src/serve/hub-app/terminal-lib.ts +110 -0
  424. package/src/serve/hub-app/terminal-links.ts +55 -0
  425. package/src/serve/hub-app/terminal-list-st.ts +304 -0
  426. package/src/serve/hub-app/terminal-log-st.ts +242 -0
  427. package/src/serve/hub-app/terminal-out.ts +135 -0
  428. package/src/serve/hub-app/terminal-pages.tsx +115 -0
  429. package/src/serve/hub-app/terminal-panel.tsx +60 -9
  430. package/src/serve/hub-app/terminal-sources.tsx +335 -0
  431. package/src/serve/hub-app/terminal-st.ts +447 -167
  432. package/src/serve/hub-app/terminal-stream.ts +233 -0
  433. package/src/serve/hub-app/terminal-tab.tsx +64 -0
  434. package/src/serve/hub-app/terminal-widths.ts +30 -0
  435. package/src/serve/hub-app/terminal.css +50 -4
  436. package/src/serve/hub-app/test-view.tsx +5 -3
  437. package/src/serve/hub-app/tests-view.tsx +16 -15
  438. package/src/serve/hub-app/theme-st.ts +5 -0
  439. package/src/serve/hub-app/thread-row.tsx +39 -31
  440. package/src/serve/hub-app/time-ago.tsx +3 -2
  441. package/src/serve/hub-app/time-view.tsx +2 -1
  442. package/src/serve/hub-app/time.css +1 -1
  443. package/src/serve/hub-app/timeline-chart.tsx +5 -4
  444. package/src/serve/hub-app/timeline-view.tsx +10 -9
  445. package/src/serve/hub-app/tips.ts +247 -0
  446. package/src/serve/hub-app/tree-build.ts +40 -8
  447. package/src/serve/hub-app/tree-svc.ts +167 -134
  448. package/src/serve/hub-app/unit-icons.ts +26 -0
  449. package/src/serve/hub-app/url-address.ts +154 -0
  450. package/src/serve/hub-app/url-faces.ts +88 -0
  451. package/src/serve/hub-app/url-forms.tsx +183 -0
  452. package/src/serve/hub-app/urls-svc.ts +167 -5
  453. package/src/serve/hub-app/urls-view.tsx +56 -20
  454. package/src/serve/hub-app/urls.css +26 -0
  455. package/src/serve/hub-app/vault-view.tsx +5 -4
  456. package/src/serve/hub-app/veille/veille-page.tsx +34 -33
  457. package/src/serve/hub-app/veille/veille-st.ts +6 -3
  458. package/src/serve/hub-app/view-layout.css +3 -3
  459. package/src/serve/hub-app/when-view.tsx +5 -4
  460. package/src/serve/hub-app/wikis-view.tsx +6 -5
  461. package/src/serve/hub-app/words.tsx +9 -2
  462. package/src/serve/hub-runtime.ts +3 -2
  463. package/src/serve/orchestrator-host.ts +58 -0
  464. package/src/serve/page-live.ts +147 -0
  465. package/src/serve/project-gutter-route.ts +63 -2
  466. package/src/serve/read-worker.ts +7 -2
  467. package/src/serve/runs-stamp.ts +33 -0
  468. package/src/serve/secrets-read.ts +156 -0
  469. package/src/serve/serve-hub.ts +71 -22
  470. package/src/serve/terminal-claudes.ts +185 -0
  471. package/src/serve/terminal-guard.ts +10 -5
  472. package/src/serve/terminal-host.ts +517 -0
  473. package/src/serve/terminal-record.ts +104 -0
  474. package/src/serve/terminal-route.ts +466 -103
  475. package/src/serve/terminal-shells.ts +3 -0
  476. package/src/serve/terminal-watch.ts +102 -0
  477. package/src/shipkit-files.ts +9 -4
  478. package/src/shot/client.ts +4 -9
  479. package/src/shot/shooter.ts +2 -4
  480. package/src/shot/shot-ask.ts +2 -7
  481. package/src/shot/shot-theme.ts +6 -17
  482. package/src/social/routes.ts +2 -2
  483. package/src/social/writes.ts +3 -0
  484. package/src/suite/test-units.ts +6 -2
  485. package/src/trailer/sound/eleven.ts +1 -0
  486. package/src/urls/added.ts +111 -0
  487. package/src/urls/icons.ts +294 -0
  488. package/src/urls/places.ts +139 -0
  489. package/src/urls/routes.ts +17 -7
  490. package/src/urls/rows.ts +48 -15
  491. package/src/urls/unit.ts +57 -3
  492. package/src/urls/write-routes.ts +207 -0
  493. package/src/vault/vault-destroy.ts +2 -1
  494. package/src/vault/vault-import.ts +4 -11
  495. package/src/vault/vault-restore.ts +3 -2
  496. package/src/veille/chrome.ts +18 -3
  497. package/src/veille/identity.ts +6 -0
  498. package/src/view3d/cam.ts +30 -46
  499. package/src/view3d/lib.ts +20 -2
  500. package/src/view3d/viewer.ts +62 -88
  501. package/src/wiki/agent-paths.ts +2 -1
  502. package/src/orchestrator/deliver.ts +0 -81
  503. package/src/orchestrator/drill.ts +0 -129
  504. package/src/orchestrator/keeper.ts +0 -332
  505. package/src/orchestrator/pm.ts +0 -20
  506. package/src/orchestrator/state.ts +0 -92
  507. package/src/orchestrator/switch.ts +0 -86
  508. package/src/orchestrator/tmux.ts +0 -82
  509. package/src/serve/hub-app/rail-fly.tsx +0 -95
  510. package/src/serve/hub-app/side-lists.ts +0 -72
  511. package/src/serve/hub-app/sidebar.tsx +0 -62
  512. package/src/serve/hub-app/tree-row.tsx +0 -125
@@ -0,0 +1,87 @@
1
+ // `foreign: true` in repo.config.ts (wiki tools/shipkit/home-pages.md, Foreign): the tree is not the owner's to publish, a
2
+ // company's or a client's repo where others commit. Nothing of it leaves this Mac through shipkit: no push, no release,
3
+ // nothing to the Space, nothing to the hq. Its hub, processes, urls, threads and orchestrator stay, all local. Read as
4
+ // TEXT like `archived` (core/archived.ts): the daemon and the cross repo passes read many configs per look.
5
+ // Its own tree stays the team's too: no git hook armed, no write by a check outside what git ignores, no suite
6
+ // of the team run from the daemon on a save (the readers: hooks/run-hooks.ts, core/check-ctx.ts, gate/run-fix.ts,
7
+ // gate/gate-checks.ts).
8
+ // The one constraint a reader breaks first: such a repo keeps its config out of git, so a linked worktree of it holds
9
+ // none, and its main checkout answers for it
10
+ import { lstatSync, readFileSync } from 'fs'
11
+ import { dirname, join, resolve, sep } from 'path'
12
+ import { flagOfText } from './archived.ts'
13
+ import { gitBin } from './git-bin.ts'
14
+
15
+ /** the words every refusal carries after its own verb */
16
+ export const FOREIGN_WHY = 'foreign: true in its repo.config.ts, nothing of it leaves this Mac through shipkit'
17
+
18
+ /** does the config text mark the repo foreign */
19
+ export const foreignOfText = (text: string): boolean => flagOfText(text, 'foreign')
20
+
21
+ const configText = (root: string): string | null => {
22
+ try {
23
+ return readFileSync(join(root, 'repo.config.ts'), 'utf8')
24
+ } catch {
25
+ return null
26
+ }
27
+ }
28
+
29
+ /** the main checkout of a work tree root: itself, or for a linked worktree (its `.git` a file naming
30
+ * `<main>/.git/worktrees/<name>`) that main. Two reads, no git */
31
+ export function mainCheckoutOf(root: string): string {
32
+ try {
33
+ if (!lstatSync(join(root, '.git')).isFile()) return root
34
+ const dir = /^gitdir:\s*(.+)$/m.exec(readFileSync(join(root, '.git'), 'utf8'))?.[1]?.trim()
35
+ if (dir == null) return root
36
+ const abs = resolve(root, dir)
37
+ const at = abs.lastIndexOf(`${sep}.git${sep}worktrees${sep}`)
38
+ return at === -1 ? root : abs.slice(0, at)
39
+ } catch {
40
+ return root
41
+ }
42
+ }
43
+
44
+ /** is the repo at `root` foreign: its own config says so, or, with none, its main checkout's */
45
+ export function isForeign(root: string): boolean {
46
+ const own = configText(root)
47
+ if (own != null) return foreignOfText(own)
48
+ const main = mainCheckoutOf(root)
49
+ const text = main === root ? null : configText(main)
50
+ return text != null && foreignOfText(text)
51
+ }
52
+
53
+ /** what `sk ci` and `sk hooks list` say of a foreign repo's commit gates: shipkit arms none, `core.hooksPath` stays */
54
+ export const FOREIGN_HOOKS = "hooks: the team's (foreign), core.hooksPath left as it is"
55
+
56
+ /** a write, a process or a git verb that a foreign repo refused before it ran. The fix pass and the check
57
+ * runner know it by name and print its message as a skip line, never as a broken body */
58
+ export class ForeignRefused extends Error {
59
+ override name = 'ForeignRefused'
60
+ }
61
+
62
+ /** null when `rel` (repo relative) is a path the team's git never sees, ignored by `.gitignore` or
63
+ * `.git/info/exclude`, else why a write there is refused. A tracked file is never ignored, whatever matches it.
64
+ * One `git check-ignore` spawn; an answer git cannot give refuses */
65
+ export function teamPathRefusal(root: string, rel: string): string | null {
66
+ const p = Bun.spawnSync([gitBin(), 'check-ignore', '-q', '--', rel], { cwd: root, stdout: 'ignore', stderr: 'pipe' })
67
+ if (p.exitCode === 0) return null
68
+ if (p.exitCode === 1) return `${rel} is a path the team's git sees (not ignored, not in .git/info/exclude)`
69
+ return `git cannot say whether ${rel} is ignored (${p.stderr.toString().trim().split('\n')[0]?.slice(0, 120) ?? `exit ${p.exitCode}`})`
70
+ }
71
+
72
+ /** the main checkout of the foreign repo that holds `path`, or null: the nearest folder with a `.git` decides */
73
+ export function foreignRepoOf(path: string): string | null {
74
+ let dir = resolve(path)
75
+ for (;;) {
76
+ let st: ReturnType<typeof lstatSync> | undefined
77
+ try {
78
+ st = lstatSync(join(dir, '.git'))
79
+ } catch {
80
+ st = undefined
81
+ }
82
+ if (st != null) return isForeign(dir) ? mainCheckoutOf(dir) : null
83
+ const up = dirname(dir)
84
+ if (up === dir) return null
85
+ dir = up
86
+ }
87
+ }
@@ -0,0 +1,75 @@
1
+ // a repo's window colour, as Peacock tints its VSCode window: the chrome of
2
+ // its app (title bar, tab bar), its rail tile in the hub, the plate of its
3
+ // letter icon. One answer for every surface: the repo config's `guiColor`,
4
+ // else its `.vscode/settings.json` `peacock.color`, else a dark tone hashed
5
+ // from its name.
6
+ //
7
+ // the one constraint a reader breaks first: no fs here, the hub's browser
8
+ // bundle imports it (textOn); the files are read by core/repo-gui-color.ts,
9
+ // as text, never by loading the config: the hub reads every repo's colour on
10
+ // each poll
11
+ import { configDepths, hslHex, nameHue } from './identity-color.ts'
12
+
13
+ export type GuiColorSource = 'config' | 'peacock' | 'name'
14
+ /** the colour and where it came from; `problem`: a declared `guiColor` that is no colour, so the next source answered,
15
+ * and the app build fails on it with that line */
16
+ export type GuiColor = { color: string; source: GuiColorSource; problem?: string }
17
+
18
+ const HEX6 = /^#[0-9a-fA-F]{6}$/
19
+ const HEX3 = /^#[0-9a-fA-F]{3}$/
20
+ /** #rgb grows to #rrggbb, lower case; anything else is null */
21
+ export function hexOf(v: string): string | null {
22
+ if (HEX6.test(v)) return v.toLowerCase()
23
+ if (HEX3.test(v)) return `#${[...v.slice(1)].map((c) => c + c).join('')}`.toLowerCase()
24
+ return null
25
+ }
26
+
27
+ const KEY_RE = /(?:^|[{,])\s*(['"]?)guiColor\1\s*:\s*['"`]([^'"`]*)['"`]/gm
28
+
29
+ /** the top level `guiColor` of `defineRepo({…})`, as written: a key nested deeper, in a string or a comment is not it */
30
+ export function guiColorDeclared(configText: string): string | null {
31
+ const depth = configDepths(configText)
32
+ for (const m of configText.matchAll(KEY_RE)) {
33
+ const sep = /^[{,]/.test(m[0]) ? m.index : m.index - 1
34
+ if (sep >= 0 && depth[sep] === 1) return m[2]!
35
+ }
36
+ return null
37
+ }
38
+
39
+ /** Peacock's colour in a VSCode settings text (jsonc: comments and trailing commas allowed, so read by pattern) */
40
+ export function peacockOf(settingsText: string): string | null {
41
+ const v = /"peacock\.color"\s*:\s*"([^"]*)"/.exec(settingsText)?.[1]
42
+ return v == null ? null : hexOf(v)
43
+ }
44
+
45
+ /** the tone a name hashes to, as dark as a Peacock colour: light text reads on it */
46
+ export const guiColorOfName = (name: string): string => hslHex(nameHue(name), 0.5, 0.22)
47
+
48
+ /** the window colour from the repo's texts: its config, its VSCode settings (either '' when absent) and its name */
49
+ export function guiColorOfTexts(o: { config: string; settings: string; name: string; configPath?: string }): GuiColor {
50
+ const declared = guiColorDeclared(o.config)
51
+ const color = declared == null ? null : hexOf(declared)
52
+ if (color != null) return { color, source: 'config' }
53
+ const problem = declared == null ? {} : { problem: `${o.configPath ?? 'repo.config.ts'}: guiColor '${declared}' is no #rrggbb colour` }
54
+ const peacock = peacockOf(o.settings)
55
+ if (peacock != null) return { color: peacock, source: 'peacock', ...problem }
56
+ return { color: guiColorOfName(o.name), source: 'name', ...problem }
57
+ }
58
+
59
+ const channel = (v: number): number => {
60
+ const c = v / 255
61
+ return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4
62
+ }
63
+ /** WCAG relative luminance of a #rrggbb */
64
+ export function luminance(hex: string): number {
65
+ const n = Number.parseInt(hex.slice(1), 16)
66
+ return 0.2126 * channel((n >> 16) & 255) + 0.7152 * channel((n >> 8) & 255) + 0.0722 * channel(n & 255)
67
+ }
68
+
69
+ export const LIGHT_TEXT = '#ffffff'
70
+ export const DARK_TEXT = '#1d1d1f'
71
+ /** the text colour that reads on this background: of light and dark text, the one of the higher contrast ratio */
72
+ export function textOn(bg: string): string {
73
+ const l = luminance(bg)
74
+ return 1.05 / (l + 0.05) >= (l + 0.05) / (luminance(DARK_TEXT) + 0.05) ? LIGHT_TEXT : DARK_TEXT
75
+ }
@@ -1,4 +1,4 @@
1
- // the hub's themes and its rail fold, shared by the page (hub-app/theme-st.ts, layout-st.ts) and what draws it from
1
+ // the hub's themes, shared by the page (hub-app/theme-st.ts) and what draws it from
2
2
  // outside (sk shot, the browser checks): no import, so a shot never loads the hub's graph.
3
3
 
4
4
  export const THEMES = ['dark', 'dim', 'grey', 'light', 'auto'] as const
@@ -10,7 +10,5 @@ export const schemeOf = (t: Theme): Scheme => (t === 'dark' || t === 'dim' ? 'da
10
10
 
11
11
  /** the local storage key that keeps the page's pick */
12
12
  export const THEME_KEY = 'hub:theme'
13
- /** the local storage key that keeps the project list folded to its rail ('1') or open ('0') */
14
- export const RAIL_KEY = 'hub:list-rail'
15
13
 
16
14
  export const isTheme = (v: unknown): v is Theme => typeof v === 'string' && v !== 'auto' && (THEMES as readonly string[]).includes(v)
@@ -27,6 +27,9 @@ export const LAYOUT = {
27
27
  // plans, arc boards and lane files: live state a crashed session resumes
28
28
  // from. Tracked in a private repo only, since a board quotes the owner
29
29
  plans: sk('plans'),
30
+ // the urls added from the hub, their logins (vault names, never a value) and how each opens (wiki
31
+ // tools/shipkit/urls.md). Tracked in a private repo only, like plans: a LAN address names a machine
32
+ urls: sk('urls.json'),
30
33
  // the release files: next.md and one <version>.md a release, each change's picture a key in the Space, never a
31
34
  // file here (wiki tools/shipkit/units.md, The release files)
32
35
  releases: sk('releases'),
@@ -33,6 +33,9 @@ export type MachineCommit = {
33
33
  message: string
34
34
  /** absolute paths, all inside that repo */
35
35
  paths: string[]
36
+ /** a path git does not track yet is added first, as an intent (`git add -N`, that path's entry alone), so the
37
+ * pathspec commit takes it; undone when the commit does not land */
38
+ add?: boolean
36
39
  }
37
40
 
38
41
  /** true when a commit landed. false means "nothing was committed", never an error */
@@ -55,13 +58,18 @@ export function machineCommit(o: MachineCommit): boolean {
55
58
  const ignored = new Set(check.stdout.toString().split('\0').filter(Boolean))
56
59
  const rels = all.filter((p) => !ignored.has(p))
57
60
  if (rels.length === 0) return false
61
+ const tracked = o.add === true ? new Set(git(root, ['ls-files', '--', ...rels]).out.split('\n').filter(Boolean)) : null
62
+ const fresh = tracked == null ? [] : rels.filter((p) => !tracked.has(p))
63
+ if (fresh.length > 0 && !git(root, ['add', '-N', '--', ...fresh]).ok) return false
58
64
  // one retry: a neighbour committing right now holds index.lock
59
65
  for (let attempt = 0; attempt < 2; attempt++) {
60
66
  const r = git(root, ['commit', '-m', o.message, '--', ...rels])
61
67
  if (r.ok) return true
62
- if (!r.out.includes('index.lock')) return false
68
+ if (!r.out.includes('index.lock')) break
63
69
  Bun.sleepSync(300)
64
70
  }
71
+ // the intent entries alone, never a file: the path stays on disk, untracked as it was
72
+ if (fresh.length > 0) git(root, ['rm', '--cached', '-q', '--', ...fresh])
65
73
  return false
66
74
  } catch {
67
75
  return false
@@ -7,7 +7,8 @@
7
7
  // and a native class only accepts instances of its own copy.
8
8
  //
9
9
  // the one constraint a reader breaks first: register it BEFORE the first repo
10
- // config is imported. A module already loaded keeps the copy it resolved.
10
+ // config is imported. A module already loaded keeps the copy it resolved. A
11
+ // worker thread does not inherit the hook: its entry registers its own.
11
12
  import { existsSync, readFileSync, realpathSync } from 'fs'
12
13
  import { dirname, extname, join } from 'path'
13
14
  import { LIB_ROOT } from './lib-root.ts'
@@ -157,26 +157,29 @@ export const LEGACY_STASH_RULE = `Bash(${GIT_STASH_HEAD}*)`
157
157
  /** git's global options that take their value as the NEXT word */
158
158
  const GIT_VALUE_OPTS = new Set(['-C', '-c', '--git-dir', '--work-tree', '--namespace', '--config-env', '--exec-path'])
159
159
 
160
- const unquote = (w: string): string => w.replace(/^(['"])(.*)\1$/, '$2')
160
+ export const unquote = (w: string): string => w.replace(/^(['"])(.*)\1$/s, '$2')
161
161
 
162
162
  /** a segment's words, a quoted run kept as one word, subshell and group
163
163
  * brackets dropped */
164
- const quotedWords = (seg: string): string[] =>
164
+ export const quotedWords = (seg: string): string[] =>
165
165
  (seg.match(/(?:'[^']*'|"(?:[^"\\]|\\.)*"|[^\s'"])+/g) ?? []).map((w) => w.replace(/^[({]+|[)}]+$/g, '')).filter((w) => w !== '')
166
166
 
167
- /** the bodies of `$(...)` and backtick substitutions outside single quotes,
168
- * where a shell runs them */
169
- function substitutions(seg: string): string[] {
170
- const out: string[] = []
167
+ /** each `$(...)` and backtick substitution a shell runs, with where it sits (`end` is its last character): outside
168
+ * single quotes, inside double quotes too, never one whose opener a backslash escapes */
169
+ export function substitutionSpans(seg: string): { start: number; end: number; body: string }[] {
170
+ const out: { start: number; end: number; body: string }[] = []
171
171
  let single = false
172
+ let double = false
172
173
  for (let i = 0; i < seg.length; i++) {
173
174
  const ch = seg[i]!
174
- if (ch === "'") { single = !single; continue }
175
- if (single) continue
175
+ if (single) { if (ch === "'") single = false; continue }
176
+ if (ch === '\\') { i++; continue }
177
+ if (ch === "'" && !double) { single = true; continue }
178
+ if (ch === '"') { double = !double; continue }
176
179
  if (ch === '`') {
177
180
  const end = seg.indexOf('`', i + 1)
178
181
  if (end < 0) break
179
- out.push(seg.slice(i + 1, end))
182
+ out.push({ start: i, end, body: seg.slice(i + 1, end) })
180
183
  i = end
181
184
  } else if (ch === '$' && seg[i + 1] === '(') {
182
185
  let depth = 0
@@ -185,16 +188,18 @@ function substitutions(seg: string): string[] {
185
188
  if (seg[j] === '(') depth++
186
189
  else if (seg[j] === ')' && --depth === 0) break
187
190
  }
188
- out.push(seg.slice(i + 2, j))
191
+ out.push({ start: i, end: Math.min(j, seg.length - 1), body: seg.slice(i + 2, j) })
189
192
  i = j
190
193
  }
191
194
  }
192
195
  return out
193
196
  }
194
197
 
198
+ const substitutions = (seg: string): string[] => substitutionSpans(seg).map((s) => s.body)
199
+
195
200
  /** the script a segment hands to another shell: `bash -c '<script>'`,
196
201
  * `sh -c`, `zsh -c`, or `eval <words>` */
197
- function innerScript(words: string[], seg: string): string | null {
202
+ export function innerScript(words: string[], seg: string): string | null {
198
203
  const program = words[0]?.split('/').pop() ?? ''
199
204
  if (program === 'eval') {
200
205
  const all = quotedWords(seg)
@@ -326,7 +331,7 @@ export function shellParts(command: string): { seg: string; op: '|' | ';' | '' }
326
331
  /** the words of a segment from its program on: leading `VAR=value`
327
332
  * assignments, then wrapper words with their own flags and durations
328
333
  * (`timeout 60 bun test`), dropped repeatedly */
329
- function programWords(seg: string): string[] {
334
+ export function programWords(seg: string): string[] {
330
335
  let s = seg.trim().replace(/^[(){}\s]+/, '')
331
336
  let wrapped = false
332
337
  for (;;) {
@@ -0,0 +1,123 @@
1
+ // a request to one of the owner's routes of the hub with a header written by hand to look like his browser, refused by
2
+ // the Bash guard (hooks/one-way-in-guard.ts). The servers take a word as the owner from a page of the hub alone
3
+ // (http/owner-word.ts), on headers a program can write: this is the half that tells an agent so before it tries.
4
+ // A hub page's socket and the terminal's routes are his word too (what he types there), so a forged upgrade is the
5
+ // same forgery, and so is a terminal hop to another place (`/door/_terminal/`) with the door key written by hand.
6
+ // A pattern, never a proof. It does not see: a script file that builds the request, a header whose name sits in a
7
+ // variable or a file (curl -H @file, -K), a heredoc piped into a shell, a path or a port put together by code (a
8
+ // variable set in another command, strings joined in a script, `/ap""i/`), a word route of a hub served alone on
9
+ // its own port (no `/r/<repo>`, the shape any project's dev server has too). It refuses too much in one place, by
10
+ // choice: a project's own `/api/live` or `/api/terminal/` on a port of 4800 to 4979, where hubs served alone sit
11
+ // beside the projects' own processes (no house repo has such a route). And a word as the owner has other doors
12
+ // no header guards: a command to tmux's own socket, a browser a program drives, a write straight into the store.
13
+ // The one constraint a reader breaks first: it reads only what a shell would RUN. The words of a commit, a reply, a
14
+ // search or a file written through a heredoc are data, so telling the forgery is never refused
15
+ import { HOP_PATH } from '../http/hop-names.ts'
16
+ import { ownerWordPath, PAGE_SOCKET } from '../http/owner-word.ts'
17
+ import { programWords, shellParts, substitutionSpans } from './one-way-in-policy.ts'
18
+
19
+ /** programs that send nothing: their arguments and their heredoc are words, only a substitution inside them runs */
20
+ const DATA_HEADS = new Set(['sk', 'shipkit', 'git', 'gh', 'echo', 'printf', 'cat', 'tee', 'grep', 'egrep', 'fgrep', 'rg', 'sed', 'awk', 'jq', 'head', 'tail', 'wc', 'ls', 'find', 'less', 'mkdir', 'touch', 'cd', 'sort', 'uniq', 'cut', 'tr', 'column', 'nl', 'pbcopy'])
21
+
22
+ const NAMES = 'origin|sec-fetch-[a-z]+|x-shipkit-[a-z-]+|x-forwarded-(?:for|host|proto)|tailscale-user-[a-z-]+'
23
+ /** a header only a browser, the web or tailscaled writes: as a curl flag, a wget flag, an httpie word, a key of an
24
+ * object, or a line of a request printed by hand (after its `\r\n`) */
25
+ const FORGED_KEY = new RegExp(`(?:^|[\\s'"\`{,([]|--header=|\\\\[rn])(${NAMES})['"\`]?\\]?\\s*:`, 'im')
26
+ /** the same as a pair: `['Origin', value]`, `headers.set('origin', value)` */
27
+ const FORGED_PAIR = new RegExp(`['"\`](${NAMES})['"\`]\\s*,`, 'i')
28
+ /** the Origin as a socket client takes it: a flag (`websocat --origin`, `wscat -o`), an argument by its name
29
+ * (`create_connection(url, origin='…')`) */
30
+ const FORGED_FLAG = /(?:^|\s)(?:--(origin)(?:[=\s]|$)|-o\s+['"]?https?:\/\/)|[(,]\s*(origin)\s*=\s*['"]/i
31
+
32
+ const LOCAL_NAME = /^(?:localhost|[\w.-]+\.localhost|[\w.-]+\.ts\.net)$/i
33
+ const LOCAL_ANYWHERE = /\blocalhost\b|\b127\.\d{1,3}(?:\.\d{1,3}){0,2}\b|\b0\.0\.0\.0\b|\[::1\]|\.ts\.net\b/i
34
+ /** what stands right before a path: a scheme, a host (a name, an address in brackets, a shell variable), a port */
35
+ const HOST_BEFORE = /(?:https?:\/\/)?(\[[^\]\s]+\]|\$\{?\w+\}?|[\w.-]+)(?::(?:\d+|\$\{?\w+\}?))?$/
36
+
37
+ /** the ports the house serves a hub on (home/home-paths.ts: pm 4797, the daemon 4798, the home 4799, a hub alone
38
+ * 4800 to 4979): right before a path, or named anywhere in the command */
39
+ const HUB_PORT = /:(?:479[7-9]|48\d\d|49[0-7]\d)$/
40
+ const HUB_PORT_NEAR = /[:\s=+(](?:479[7-9]|48\d\d|49[0-7]\d)\b/
41
+ /** a host or a port that is a variable of the shell: it counts as the hub's only when the command names a hub port */
42
+ const IN_VARIABLE = /\$\{?\w+\}?$/
43
+
44
+ /** the text as the shell and curl send its paths: quotes gone (`"…/api/"live`, `l''ive`), dot segments resolved
45
+ * (`/api/x/../live`, `/api/./live`), and each word of curl's first braces (`/api/{live,x}`) */
46
+ function asSent(text: string): string[] {
47
+ let t = text.replace(/['"]/g, '')
48
+ for (let n = 0; n < 4 && /\/\.\.?(?=\/)/.test(t); n++) t = t.replace(/\/[\w%-]+\/\.\.(?=\/)/g, '').replace(/\/\.(?=\/)/g, '')
49
+ const braces = /\{([\w./%-]*(?:,[\w./%-]*)+)\}/.exec(t)
50
+ return braces == null ? [t] : braces[1]!.split(',').slice(0, 8).map((word) => t.replace(braces[0], word))
51
+ }
52
+
53
+ /** whether the text names one of the owner's routes as the home serves it (`/r/<repo>/api/…`, `/api/home/…`: a bare
54
+ * `/api/messages` is any project's own) on a server that may be this machine's: a loopback or a tailnet name, an
55
+ * address in numbers, a variable, or no host beside it while the text names this machine elsewhere. A page's
56
+ * socket and the terminal's routes are the home's own under no repo too (`/api/live`, `/api/terminal/machine`):
57
+ * bare, they count on a port of the hub only, since a project's dev server may have a route of that name */
58
+ const ownRouteIn = (sent: string): boolean => asSent(sent).some(ownRouteInText)
59
+
60
+ /** whether the text names a terminal hop to another place: its path is the hop's on any host, the place being
61
+ * another machine of the tailnet (hq/terminal-hop.ts), and no project serves a path of that name */
62
+ const hopIn = (sent: string): boolean => asSent(sent).some((t) => t.includes(HOP_PATH))
63
+
64
+ function ownRouteInText(text: string): boolean {
65
+ const near = HUB_PORT_NEAR.test(text)
66
+ for (let i = text.indexOf('/api/'); i >= 0; i = text.indexOf('/api/', i + 1)) {
67
+ const path = /^\/api\/[\w/.%-]+/.exec(text.slice(i, i + 300))?.[0]
68
+ if (path == null || !(ownerWordPath(path) || PAGE_SOCKET.test(path))) continue
69
+ const raw = text.slice(Math.max(0, i - 200), i)
70
+ const before = raw.replace(/\/r\/[\w.%-]+$/, '')
71
+ if (before === raw && !path.startsWith('/api/home/')) {
72
+ if (!PAGE_SOCKET.test(path) && !path.startsWith('/api/terminal/')) continue
73
+ // a request printed by hand has no host before its path, and a url may sit in a variable: the port is then
74
+ // the one the command names beside it (`nc 127.0.0.1 4799`, `B=http://localhost:4799; … "$B/api/live"`)
75
+ if (!HUB_PORT.test(before) && !(near && (IN_VARIABLE.test(before) || HOST_BEFORE.exec(before) == null))) continue
76
+ }
77
+ if (/[)`]$/.test(before)) return true
78
+ const name = HOST_BEFORE.exec(before)?.[1]
79
+ if (name == null) {
80
+ if (LOCAL_ANYWHERE.test(text)) return true
81
+ continue
82
+ }
83
+ if (name.startsWith('$') || name.startsWith('[') || /^(?:0x[0-9a-f]+|[\d.]+)$/i.test(name) || LOCAL_NAME.test(name)) return true
84
+ }
85
+ return false
86
+ }
87
+
88
+ /** what a shell would run of a command: each part whose program can send, whole; of a part that only prints, the
89
+ * substitutions inside it, and the whole of it when it is piped into a program that can send; a heredoc when the
90
+ * program that reads it can send */
91
+ function sent(command: string, depth = 0): string[] {
92
+ if (depth > 3) return []
93
+ // bash's own sockets: what a part prints goes out with no program that sends in view
94
+ if (/\/dev\/(?:tcp|udp)\//.test(command)) return [command]
95
+ const shell = command.split(/<<-?\s*['"]?\w+/)[0] ?? command
96
+ const parts = shellParts(command)
97
+ const silent = parts.map((p) => DATA_HEADS.has(programWords(p.seg)[0]?.split('/').pop() ?? ''))
98
+ const out: string[] = []
99
+ for (const [n, { seg, op }] of parts.entries()) {
100
+ if (silent[n]) {
101
+ if (op === '|' && silent[n + 1] === false) out.push(seg)
102
+ else for (const s of substitutionSpans(seg)) out.push(...sent(s.body, depth + 1))
103
+ continue
104
+ }
105
+ out.push(n === parts.length - 1 && shell.length < command.length ? `${seg}${command.slice(shell.length)}` : seg)
106
+ }
107
+ return out
108
+ }
109
+
110
+ /** the header a command sets by hand on a request to one of the owner's routes, with the part that sends it; or null */
111
+ export function forgedOwnerWordIn(command: string): { header: string; segment: string } | null {
112
+ if (!command.includes('/api/') && !command.includes('_terminal')) return null
113
+ const parts = sent(command)
114
+ const text = parts.join('\n')
115
+ const header = (FORGED_KEY.exec(text) ?? FORGED_PAIR.exec(text))?.[1] ?? (FORGED_FLAG.test(text) ? 'origin' : undefined)
116
+ if (header == null || !(ownRouteIn(text) || hopIn(text))) return null
117
+ return { header, segment: (parts.find((p) => p.includes('/api/') || p.includes('_terminal')) ?? parts[0] ?? '').trim() }
118
+ }
119
+
120
+ export function forgedOwnerWordRefusal(hit: { header: string; segment: string }): string {
121
+ const name = hit.header.replace(/(^|-)([a-z])/g, (_, d: string, c: string) => `${d}${c.toUpperCase()}`)
122
+ return `\`${hit.segment.replace(/\s+/g, ' ').slice(0, 80)}\` calls one of the owner's routes of the hub, or a page's socket, with a header written by hand (${name}), which only his browser, the web or tailscale writes: a word as the owner, a key in his terminals included, comes from a page of the hub, never from a program. An agent writes as itself (\`sk thread reply <address> "…"\`, \`sk thread update\`) and runs commands in its own shell, and a test of the route builds the request in a test file (tests/owner-word.test.ts and tests/page-gate.test.ts hold the shapes). Lifting this is a change of the rule (src/core/owner-word-policy.ts, src/http/owner-word.ts), not a settings edit.`
123
+ }
@@ -0,0 +1,140 @@
1
+ // a project app's main panel shades, derived from the repo's window colour (guiColor) in oklch: the window chrome and
2
+ // the dock keep the full colour, the panel a calmer shade of it. In a dark theme: mixed toward the theme's panel, lower
3
+ // chroma, hover and the active row steps toward the ink. In a light theme: a light tint of the colour's hue a step
4
+ // under the page, its chroma from a table by lightness, hover and the active row a step darker each. The section heads
5
+ // are a step darker in both. Computed here, not in css, because each ink is chosen by its WCAG contrast on the shade it
6
+ // sits on: ink 7:1 at least, dim 4.5:1 on every surface (tests/panel-shades.test.ts)
7
+ import { luminance, textOn } from './gui-color.ts'
8
+
9
+ type Lch = { l: number; c: number; h: number }
10
+
11
+ const toLinear = (v: number): number => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4)
12
+ const toGamma = (v: number): number => (v <= 0.0031308 ? 12.92 * v : 1.055 * v ** (1 / 2.4) - 0.055)
13
+
14
+ /** a #rrggbb in oklch: lightness 0 to 1, chroma, hue in radians */
15
+ export function oklchOf(hex: string): Lch {
16
+ const n = Number.parseInt(hex.slice(1), 16)
17
+ const [r, g, b] = [(n >> 16) & 255, (n >> 8) & 255, n & 255].map((x) => toLinear(x / 255)) as [number, number, number]
18
+ const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)
19
+ const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)
20
+ const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)
21
+ const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s
22
+ const A = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s
23
+ const B = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
24
+ return { l: L, c: Math.hypot(A, B), h: Math.atan2(B, A) }
25
+ }
26
+
27
+ /** linear srgb, a channel under 0 or over 1 where the colour is outside the gamut */
28
+ function linearOfLch({ l: L, c, h }: Lch): number[] {
29
+ const A = c * Math.cos(h)
30
+ const B = c * Math.sin(h)
31
+ const l = (L + 0.3963377774 * A + 0.2158037573 * B) ** 3
32
+ const m = (L - 0.1055613458 * A - 0.0638541728 * B) ** 3
33
+ const s = (L - 0.0894841775 * A - 1.291485548 * B) ** 3
34
+ return [4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s]
35
+ }
36
+
37
+ function hexOfLch(x: Lch): string {
38
+ return `#${linearOfLch(x).map((v) => Math.round(Math.min(1, Math.max(0, toGamma(Math.min(1, Math.max(0, v))))) * 255).toString(16).padStart(2, '0')).join('')}`
39
+ }
40
+
41
+ /** the colour with as much of its chroma as srgb holds at its lightness: a clipped channel would turn its hue */
42
+ function inGamut(x: Lch): Lch {
43
+ let c = x.c
44
+ while (c > 0 && linearOfLch({ ...x, c }).some((v) => v < -0.0005 || v > 1.0005)) c = Math.max(0, c - 0.002)
45
+ return { ...x, c }
46
+ }
47
+
48
+ /** the WCAG contrast ratio of two #rrggbb */
49
+ export function contrast(a: string, b: string): number {
50
+ const [x, y] = [luminance(a), luminance(b)].sort((p, q) => q - p) as [number, number]
51
+ return (x + 0.05) / (y + 0.05)
52
+ }
53
+
54
+ /** a mix of two colours in srgb, `t` of the second */
55
+ export function mixHex(a: string, b: string, t: number): string {
56
+ const p = (hex: string) => [16, 8, 0].map((s) => (Number.parseInt(hex.slice(1), 16) >> s) & 255)
57
+ const [x, y] = [p(a), p(b)]
58
+ return `#${x.map((v, i) => Math.round(v + (y[i]! - v) * t).toString(16).padStart(2, '0')).join('')}`
59
+ }
60
+
61
+ export type PanelShades = { bg: string; head: string; hover: string; cur: string; ink: string; dim: string; line: string }
62
+
63
+ /** how much of the window colour the panel keeps, mixed in oklch toward the theme's panel, and its chroma kept */
64
+ const KEEP = 0.5
65
+ const CHROMA = 0.6
66
+
67
+ /** a theme's surfaces as hub.css has them: `side` its panel background (--bg-side), `page` its page (--bg) */
68
+ export type ThemeBg = { side: string; page: string }
69
+
70
+ /** a theme is light where its page is: read from the page's lightness, never from the theme's name */
71
+ export const isLight = (theme: ThemeBg): boolean => oklchOf(theme.page).l >= 0.6
72
+
73
+ /** the panel's shades from the window colour and the theme's surfaces */
74
+ export const panelShades = (tint: string, theme: ThemeBg): PanelShades => (isLight(theme) ? lightShades(tint, theme.page) : darkShades(tint, theme.side))
75
+
76
+ /** the dim ink, as far toward the panel as 4.5:1 allows on the darkest of the surfaces it sits on, and the line */
77
+ function withInks(ink: string, s: { bg: string; head: string; hover: string; cur: string }): PanelShades {
78
+ let dim = ink
79
+ for (let k = 0.6; k > 0; k -= 0.02) {
80
+ const d = mixHex(ink, s.bg, k)
81
+ if ([s.bg, s.head, s.hover, s.cur].every((x) => contrast(d, x) >= 4.5)) {
82
+ dim = d
83
+ break
84
+ }
85
+ }
86
+ return { ...s, ink, dim, line: mixHex(ink, s.bg, 0.8) }
87
+ }
88
+
89
+ /** a light tint's chroma by its lightness, [lightness, chroma] pairs: enough to name the hue, and never read from the
90
+ * window colour, whose own chroma leaves a dull hue (olive, brown) grey once it is light */
91
+ const LIGHT_CHROMA: [number, number][] = [[0.7, 0.06], [0.85, 0.045], [0.95, 0.032], [1, 0.012]]
92
+ function lightChroma(l: number): number {
93
+ const at = LIGHT_CHROMA.findIndex(([x]) => l <= x)
94
+ if (at <= 0) return LIGHT_CHROMA[at < 0 ? LIGHT_CHROMA.length - 1 : 0]![1]
95
+ const [[l0, c0], [l1, c1]] = [LIGHT_CHROMA[at - 1]!, LIGHT_CHROMA[at]!]
96
+ return c0 + ((l - l0) / (l1 - l0)) * (c1 - c0)
97
+ }
98
+ /** under this chroma a window colour has no hue to keep: its tint fades to a grey with it */
99
+ const HUELESS = 0.02
100
+ /** the light panel sits this far under the page's lightness, so the column still reads as a panel */
101
+ const UNDER_PAGE = 0.012
102
+
103
+ /** a light theme: a light tint of the colour's hue a step under the page, the heads, hover and the active row a step
104
+ * darker each in the same hue (the active one with more colour) */
105
+ function lightShades(tint: string, page: string): PanelShades {
106
+ const t = oklchOf(tint)
107
+ const ink = textOn(page)
108
+ const hue = Math.min(1, t.c / HUELESS)
109
+ const at = (l: number, more = 1): string => hexOfLch(inGamut({ l, c: lightChroma(l) * hue * more, h: t.h }))
110
+ const shades = (l: number) => ({ bg: at(l), head: at(l - 0.045), hover: at(l - 0.03), cur: at(l - 0.075, 1.6) })
111
+ let l = oklchOf(page).l - UNDER_PAGE
112
+ // the ink reads at 7:1 on every surface: a page too dark for it lifts the panel
113
+ for (let i = 0; i < 60 && Math.min(...Object.values(shades(l)).map((h) => contrast(ink, h))) < 7; i++) l += 0.01
114
+ return withInks(ink, shades(l))
115
+ }
116
+
117
+ /** a dark theme: the colour mixed toward the theme's panel background (its `--bg-side`), calmer */
118
+ function darkShades(tint: string, base: string): PanelShades {
119
+ const t = oklchOf(tint)
120
+ const b = oklchOf(base)
121
+ let bg: Lch = { l: b.l + (t.l - b.l) * KEEP, c: t.c * KEEP * CHROMA, h: t.h }
122
+ // the ink is the theme's: a light theme keeps a light panel, a dark one a dark panel, whatever the colour
123
+ const ink = textOn(base)
124
+ // toward the ink: +1 on a dark shade (white ink), -1 on a light one
125
+ const toward = ink === textOn('#000000') ? 1 : -1
126
+ // the heads a step darker, hover and the active row steps toward the ink (the active one with more colour)
127
+ const shades = (x: Lch) => ({ bg: hexOfLch(x), head: hexOfLch({ ...x, l: x.l - 0.05 }), hover: hexOfLch({ ...x, l: x.l + toward * 0.04 }), cur: hexOfLch({ ...x, l: x.l + toward * 0.08, c: x.c * 1.5 }) })
128
+ const worst = (x: Lch): number => Math.min(...Object.values(shades(x)).map((h) => contrast(ink, h)))
129
+ // the ink reads at 7:1 on every surface: the shade moves away from the ink until it does
130
+ for (let i = 0; i < 60 && worst(bg) < 7; i++) bg = { ...bg, l: bg.l - toward * 0.01 }
131
+ return withInks(ink, shades(bg))
132
+ }
133
+
134
+ /** each theme's surfaces, its `--bg-side` and its `--bg` in hub.css (tests/panel-shades.test.ts holds them equal) */
135
+ export const THEME_BG = {
136
+ dark: { side: '#131519', page: '#0d0e10' },
137
+ dim: { side: '#272b32', page: '#22262c' },
138
+ grey: { side: '#c5cad1', page: '#cfd3d9' },
139
+ light: { side: '#e6e9ee', page: '#f1f3f6' },
140
+ } as const satisfies Record<string, ThemeBg>
@@ -0,0 +1,16 @@
1
+ // a repo's window colour read from its files (core/gui-color.ts holds the
2
+ // rules and stays free of fs for the browser): its repo.config.ts, then its
3
+ // .vscode/settings.json, then its name
4
+ import { existsSync, readFileSync } from 'fs'
5
+ import { basename, join } from 'path'
6
+ import { guiColorOfTexts, type GuiColor } from './gui-color.ts'
7
+
8
+ const readOr = (f: string): string => {
9
+ try { return existsSync(f) ? readFileSync(f, 'utf8') : '' } catch { return '' }
10
+ }
11
+
12
+ /** the repo's window colour and its source: `guiColor`, else Peacock's colour, else its name's */
13
+ export function guiColorOf(root: string, name: string = basename(root)): GuiColor {
14
+ const configPath = join(root, 'repo.config.ts')
15
+ return guiColorOfTexts({ config: readOr(configPath), settings: readOr(join(root, '.vscode', 'settings.json')), name, configPath })
16
+ }
@@ -0,0 +1,17 @@
1
+ // the default session policy of the Bash guard (hooks/one-way-in-guard.ts): a lane never runs `sk session default` or
2
+ // `leave` (`sk orchestrator here` and `leave`, their old names). A lane shares its session's ids, so its claim would
3
+ // land on its session and its watch would hear for it. Only the hook input tells a lane from its session (`agent_id`).
4
+ // Leaf module: no import. The words inside quotes or a heredoc body (a commit message, an echo) are no call
5
+ const CALL = /(?:^|[\s;&|(])(?:sk|shipkit|\S*\/cli\.ts)\s+(?:orchestrator\s+(here|leave)|session\s+(default|leave))(?=$|[\s;&|)])/
6
+
7
+ /** the verb a lane's command would run, `default` or `leave` (`here` under its old name); null for a session's call or
8
+ * any other command */
9
+ export function laneRoleCallIn(command: string, agentId: unknown): string | null {
10
+ if (typeof agentId !== 'string' || agentId === '') return null
11
+ const code = command.split('<<')[0]!.replace(/'[^']*'|"(?:\\.|[^"\\])*"/g, ' ')
12
+ const m = CALL.exec(code)
13
+ return m === null ? null : (m[1] ?? m[2] ?? null)
14
+ }
15
+
16
+ export const laneRoleRefusal = (verb: string): string =>
17
+ `a lane never runs sk session ${verb === 'here' ? 'default' : verb}: the default is a top level session, and its session runs it (a lane shares its ids, so the default would land on its session and this lane's watch would hear for it). Your own threads reach you through your own watch: SK_AGENT=<lane> sk thread watch --mine --house --once, as a background command (the Bash tool with run_in_background), and again after each burst it prints. Page: wiki tools/shipkit/sessions.md`
package/src/core/scope.ts CHANGED
@@ -53,8 +53,9 @@ export function inScope(s: Scope | undefined, a: Asker): boolean {
53
53
 
54
54
  const KEYS = { repo: 'repos', identity: 'identities', machine: 'machines' } as const
55
55
 
56
- /** the md cell as a scope; throws on a token that is neither `all`, `repo:`, `identity:` nor `machine:` */
57
- export function parseScope(cell: string): Scope {
56
+ /** the md cell as a scope; throws on a token that is neither `all`, `repo:`, `identity:` nor `machine:`. `parts`: the
57
+ * `<x>` parts of a template row's name (secrets/name-template.ts), which a token may name in place of a name */
58
+ export function parseScope(cell: string, o: { parts?: readonly string[] } = {}): Scope {
58
59
  const text = cell.replaceAll('`', '').trim()
59
60
  if (text === '' || text === 'all') return {}
60
61
  const s: Scope = {}
@@ -63,7 +64,9 @@ export function parseScope(cell: string): Scope {
63
64
  const m = /^(repo|identity|machine):(.*)$/.exec(t)
64
65
  if (m == null) throw new Error(`scope "${cell}": "${t}" is not repo:<name>, repo:<key>, identity:<id> or machine:<name> (or all)`)
65
66
  const kind = m[1] as keyof typeof KEYS
66
- const problem = nameProblem(kind, m[2]!)
67
+ const part = /^<([a-z][a-z0-9-]*)>$/.exec(m[2]!)?.[1]
68
+ if (part != null && !(o.parts ?? []).includes(part)) throw new Error(`scope "${cell}": ${t} names <${part}>, and only a template row whose name holds <${part}> may`)
69
+ const problem = part != null ? null : nameProblem(kind, m[2]!)
67
70
  if (problem != null) throw new Error(`scope "${cell}": ${problem}`)
68
71
  ;(s[KEYS[kind]] ??= []).push(m[2]!)
69
72
  }