rvlib-shipkit 2.27.0 → 2.28.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 (338) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +1 -1
  3. package/src/agent-time/hooks.ts +10 -3
  4. package/src/agent-time/live.ts +11 -5
  5. package/src/agent-time/registry.ts +289 -0
  6. package/src/agent-time/store.ts +2 -2
  7. package/src/annex/born.ts +2 -2
  8. package/src/annex/offload.ts +12 -11
  9. package/src/asks/ask-after.ts +6 -2
  10. package/src/asks/ask-bar-fold.ts +57 -0
  11. package/src/asks/ask-migrate.ts +280 -0
  12. package/src/asks/ask-steps-fold.ts +166 -0
  13. package/src/asks/ask-store.ts +586 -0
  14. package/src/assets/kits/identity-kit.ts +106 -38
  15. package/src/assets/kits/poster-thumbnail.ts +282 -0
  16. package/src/checks/SK003-claude-md-shape.check.ts +92 -25
  17. package/src/checks/SK004-gitignore-policy.check.ts +8 -4
  18. package/src/checks/SK013-one-way-in-policy.check.ts +10 -0
  19. package/src/checks/SK026-asks-autoclose.check.ts +9 -23
  20. package/src/checks/SK038-speaks-as.check.ts +3 -3
  21. package/src/checks/SK042-post-kinds.check.ts +26 -24
  22. package/src/checks/SK049-thread-answers-hook.check.ts +81 -0
  23. package/src/checks/SK050-retired-commands.check.ts +127 -0
  24. package/src/cli/cmd_Asks.ts +204 -53
  25. package/src/cli/cmd_Backup.ts +151 -8
  26. package/src/cli/cmd_Calls.ts +1 -0
  27. package/src/cli/cmd_Commands.ts +140 -34
  28. package/src/cli/cmd_Contracts.ts +1 -0
  29. package/src/cli/cmd_Keys.ts +1 -0
  30. package/src/cli/cmd_Lanes.ts +15 -4
  31. package/src/cli/cmd_Messages.ts +152 -1
  32. package/src/cli/cmd_Needs.ts +1 -0
  33. package/src/cli/cmd_Review.ts +931 -229
  34. package/src/cli/cmd_Secret.ts +255 -34
  35. package/src/cli/cmd_Social.ts +36 -33
  36. package/src/cli/cmd_SocialDrafts.ts +235 -0
  37. package/src/cli/cmd_Sound.ts +22 -1
  38. package/src/cli/cmd_Start.ts +3 -2
  39. package/src/cli/cmd_ThreadHolds.ts +34 -0
  40. package/src/cli/cmd_ThreadKinds.ts +146 -0
  41. package/src/cli/cmd_ThreadReflect.ts +83 -0
  42. package/src/cli/cmd_ThreadSyncNeeds.ts +62 -0
  43. package/src/cli/cmd_Vault.ts +1 -1
  44. package/src/cli/cmd_When.ts +1 -0
  45. package/src/cli/family-help.ts +2 -2
  46. package/src/cli/family-pages.ts +1 -1
  47. package/src/cli/kit/builtins.ts +1 -0
  48. package/src/cli/kit/verb.ts +6 -2
  49. package/src/cli/registry.ts +21 -2
  50. package/src/cli.ts +5 -2
  51. package/src/collections/actions.ts +25 -74
  52. package/src/collections/collection-types.ts +9 -5
  53. package/src/collections/md-body.ts +5 -3
  54. package/src/collections/pings.ts +13 -6
  55. package/src/collections/providers.ts +53 -61
  56. package/src/collections/reflections.ts +9 -4
  57. package/src/core/discover-checks.ts +18 -3
  58. package/src/core/git.ts +31 -0
  59. package/src/core/house-layout.ts +17 -0
  60. package/src/core/layout.ts +10 -5
  61. package/src/core/locked-write.ts +4 -1
  62. package/src/core/machine-db.ts +5 -3
  63. package/src/core/migrate-layout.ts +8 -10
  64. package/src/home/activity.ts +8 -15
  65. package/src/home/daemon-jobs.ts +13 -1
  66. package/src/home/home-paths.ts +6 -3
  67. package/src/home/home-routes.ts +8 -0
  68. package/src/home/inbox-shape.ts +233 -100
  69. package/src/home/inbox.ts +26 -71
  70. package/src/home/machine-fold.ts +10 -15
  71. package/src/home/machine-host.ts +19 -1
  72. package/src/home/other-macs.ts +2 -2
  73. package/src/home/serve-web.ts +6 -5
  74. package/src/home/space-page.ts +1 -1
  75. package/src/home/vault-page.ts +51 -17
  76. package/src/home/vault-words.ts +2 -2
  77. package/src/hooks/one-way-in-guard.ts +24 -2
  78. package/src/hq/files-send.ts +27 -28
  79. package/src/hq/hq-db.ts +4 -1
  80. package/src/hq/hq-local.ts +37 -4
  81. package/src/hq/hq-routes.ts +10 -2
  82. package/src/hq/hq-store.ts +6 -2
  83. package/src/hq/kinds/ask.ts +6 -6
  84. package/src/hq/outbox.ts +5 -3
  85. package/src/hq/replica.ts +1 -2
  86. package/src/hq/vault-route.ts +112 -0
  87. package/src/identities/collection.ts +2 -2
  88. package/src/identities/identities.ts +9 -8
  89. package/src/identities/machine-route.ts +8 -3
  90. package/src/ledger/db.ts +8 -1
  91. package/src/media-store/backup/daemon.ts +48 -8
  92. package/src/media-store/backup/keys.ts +1 -1
  93. package/src/media-store/backup/manifest.ts +20 -2
  94. package/src/media-store/backup/prune.ts +365 -0
  95. package/src/media-store/backup/retention.ts +122 -0
  96. package/src/media-store/backup/run.ts +14 -8
  97. package/src/media-store/backup/sources.ts +18 -17
  98. package/src/media-store/backup/thread-copy.ts +340 -0
  99. package/src/media-store/copy/config.ts +3 -4
  100. package/src/media-store/copy/store.ts +2 -2
  101. package/src/media-store/db.ts +2 -2
  102. package/src/media-store/forget.ts +118 -0
  103. package/src/media-store/purge.ts +3 -2
  104. package/src/media-store/space-listing.ts +20 -4
  105. package/src/media-store/space.ts +6 -5
  106. package/src/messages/guard.ts +49 -0
  107. package/src/messages/model.ts +1 -1
  108. package/src/messages/objects.ts +201 -0
  109. package/src/messages/routes.ts +2 -2
  110. package/src/messages/score.ts +1 -1
  111. package/src/messages/write.ts +285 -0
  112. package/src/pages/frame-client.ts +181 -4
  113. package/src/reflections/reflections-queue.ts +1 -1
  114. package/src/release/gate-checkout.ts +2 -1
  115. package/src/release/git-facts.ts +3 -2
  116. package/src/release/public-clean.ts +3 -2
  117. package/src/repo-config.ts +40 -18
  118. package/src/review/anim.ts +1 -1
  119. package/src/review/answer-kinds.ts +131 -0
  120. package/src/review/band.ts +53 -0
  121. package/src/review/branch-hold.ts +84 -0
  122. package/src/review/card-db.ts +16 -6
  123. package/src/review/card-rows.ts +4 -3
  124. package/src/review/cells.ts +297 -65
  125. package/src/review/close.ts +92 -0
  126. package/src/review/draft-card.ts +8 -16
  127. package/src/review/draft-model.ts +2 -2
  128. package/src/review/events.ts +171 -0
  129. package/src/review/format.ts +128 -14
  130. package/src/review/glyphs.ts +63 -0
  131. package/src/review/gone.ts +1 -1
  132. package/src/review/holds-sync.ts +62 -0
  133. package/src/review/holds.ts +85 -0
  134. package/src/review/house-kind-defs.ts +41 -0
  135. package/src/review/inbox-hook.ts +22 -9
  136. package/src/review/inbox-read.ts +201 -0
  137. package/src/review/instructions.ts +199 -0
  138. package/src/review/kind-apply.ts +61 -0
  139. package/src/review/kind-catalog.ts +96 -0
  140. package/src/review/kinds.ts +278 -0
  141. package/src/review/lane-ask.ts +109 -0
  142. package/src/review/model.ts +396 -86
  143. package/src/review/move.ts +3 -3
  144. package/src/review/need-address.ts +15 -0
  145. package/src/review/need-threads.ts +93 -0
  146. package/src/review/object-card.ts +48 -0
  147. package/src/review/object-read.ts +31 -0
  148. package/src/review/owner-verdict.ts +36 -0
  149. package/src/review/parties.ts +182 -0
  150. package/src/review/previews.ts +3 -1
  151. package/src/review/projections.ts +235 -0
  152. package/src/review/referring.ts +54 -0
  153. package/src/review/reflection-object.ts +195 -0
  154. package/src/review/routes.ts +137 -32
  155. package/src/review/secret-route.ts +80 -0
  156. package/src/review/snooze.ts +38 -0
  157. package/src/review/stage-card.ts +4 -4
  158. package/src/review/store.ts +366 -85
  159. package/src/review/supersede.ts +116 -0
  160. package/src/review/take-back.ts +52 -0
  161. package/src/review/thread-fold.ts +20 -7
  162. package/src/review/threads.ts +236 -39
  163. package/src/review/traces.ts +218 -0
  164. package/src/review/trailer-card.ts +2 -2
  165. package/src/review/unit.ts +71 -5
  166. package/src/review/verdict-items.ts +73 -0
  167. package/src/review/verdict-write.ts +15 -0
  168. package/src/review/wait.ts +85 -0
  169. package/src/review/watchers.ts +22 -9
  170. package/src/scaffold/files/claude-settings-local.json +2 -0
  171. package/src/secrets/archive-mark.ts +52 -0
  172. package/src/secrets/archive.ts +83 -0
  173. package/src/secrets/copy.ts +14 -14
  174. package/src/secrets/keychain-write.ts +48 -0
  175. package/src/secrets/keychain.ts +8 -5
  176. package/src/secrets/lapse-mark.ts +33 -0
  177. package/src/secrets/lapse.ts +60 -0
  178. package/src/secrets/list.ts +16 -22
  179. package/src/secrets/manager.ts +31 -16
  180. package/src/secrets/read.ts +161 -33
  181. package/src/secrets/tail.ts +31 -0
  182. package/src/serve/hub-app/asks-page.tsx +2 -1
  183. package/src/serve/hub-app/auto-text.tsx +14 -6
  184. package/src/serve/hub-app/benign-errors.ts +15 -1
  185. package/src/serve/hub-app/card-head.tsx +49 -0
  186. package/src/serve/hub-app/check-view.tsx +3 -2
  187. package/src/serve/hub-app/code-copy.ts +35 -0
  188. package/src/serve/hub-app/col-card.tsx +31 -40
  189. package/src/serve/hub-app/col-list-page.tsx +5 -2
  190. package/src/serve/hub-app/col-tables-view.tsx +7 -4
  191. package/src/serve/hub-app/col-tables.ts +5 -5
  192. package/src/serve/hub-app/cols-svc.ts +4 -79
  193. package/src/serve/hub-app/commands/commands-page.tsx +2 -1
  194. package/src/serve/hub-app/controls.css +83 -0
  195. package/src/serve/hub-app/frames-st.ts +17 -1
  196. package/src/serve/hub-app/git-view.tsx +3 -2
  197. package/src/serve/hub-app/home-st.ts +57 -6
  198. package/src/serve/hub-app/home-strip.css +1 -6
  199. package/src/serve/hub-app/home-strip.tsx +2 -1
  200. package/src/serve/hub-app/home.html +3 -0
  201. package/src/serve/hub-app/house-wiki-view.tsx +20 -0
  202. package/src/serve/hub-app/hub-app.tsx +48 -32
  203. package/src/serve/hub-app/hub-types.ts +2 -0
  204. package/src/serve/hub-app/hub.css +50 -61
  205. package/src/serve/hub-app/icons.tsx +14 -4
  206. package/src/serve/hub-app/identities-view.tsx +4 -3
  207. package/src/serve/hub-app/inbox-st.ts +203 -42
  208. package/src/serve/hub-app/inbox-view.tsx +189 -101
  209. package/src/serve/hub-app/inbox.css +47 -44
  210. package/src/serve/hub-app/index.html +3 -0
  211. package/src/serve/hub-app/instructions.css +30 -0
  212. package/src/serve/hub-app/keys.ts +5 -3
  213. package/src/serve/hub-app/machine-st.ts +2 -2
  214. package/src/serve/hub-app/machines-view.tsx +4 -11
  215. package/src/serve/hub-app/machines.css +0 -9
  216. package/src/serve/hub-app/markdown.css +51 -0
  217. package/src/serve/hub-app/md-copy.tsx +18 -40
  218. package/src/serve/hub-app/md.ts +25 -9
  219. package/src/serve/hub-app/media-view.tsx +2 -2
  220. package/src/serve/hub-app/messages/messages-page.tsx +2 -1
  221. package/src/serve/hub-app/messages/messages-st.ts +1 -1
  222. package/src/serve/hub-app/messages.css +0 -1
  223. package/src/serve/hub-app/objects.css +51 -0
  224. package/src/serve/hub-app/page-keys.ts +1 -1
  225. package/src/serve/hub-app/pages-frames.tsx +11 -1
  226. package/src/serve/hub-app/palette-st.ts +4 -4
  227. package/src/serve/hub-app/pane-boundary.tsx +72 -0
  228. package/src/serve/hub-app/pane-errors.ts +54 -0
  229. package/src/serve/hub-app/plan-view.tsx +3 -2
  230. package/src/serve/hub-app/planned-view.tsx +3 -3
  231. package/src/serve/hub-app/planned.css +0 -4
  232. package/src/serve/hub-app/processes-view.tsx +3 -2
  233. package/src/serve/hub-app/project-list.css +5 -13
  234. package/src/serve/hub-app/project-list.tsx +3 -6
  235. package/src/serve/hub-app/projects-svc.ts +6 -2
  236. package/src/serve/hub-app/readme.css +9 -15
  237. package/src/serve/hub-app/reflections-page.tsx +54 -1
  238. package/src/serve/hub-app/releases/releases-page.tsx +3 -2
  239. package/src/serve/hub-app/releases.css +0 -1
  240. package/src/serve/hub-app/review/code-colors.ts +30 -0
  241. package/src/serve/hub-app/review/diff-view.tsx +75 -0
  242. package/src/serve/hub-app/review/dock.tsx +104 -0
  243. package/src/serve/hub-app/review/draft-card.tsx +2 -2
  244. package/src/serve/hub-app/review/group-block.tsx +209 -0
  245. package/src/serve/hub-app/review/instructions-view.tsx +116 -0
  246. package/src/serve/hub-app/review/item-verdict.tsx +38 -0
  247. package/src/serve/hub-app/review/kind-states.tsx +193 -0
  248. package/src/serve/hub-app/review/kind-view.tsx +1 -37
  249. package/src/serve/hub-app/review/kit.tsx +57 -54
  250. package/src/serve/hub-app/review/lane-bar.tsx +64 -0
  251. package/src/serve/hub-app/review/object-card.tsx +62 -0
  252. package/src/serve/hub-app/review/object-panel.tsx +179 -0
  253. package/src/serve/hub-app/review/question-views.tsx +385 -0
  254. package/src/serve/hub-app/review/review-cells.tsx +86 -105
  255. package/src/serve/hub-app/review/review-list.tsx +104 -47
  256. package/src/serve/hub-app/review/review-page.tsx +5 -4
  257. package/src/serve/hub-app/review/review-st.ts +68 -28
  258. package/src/serve/hub-app/review/review-thread.tsx +171 -40
  259. package/src/serve/hub-app/review/review-views.tsx +35 -31
  260. package/src/serve/hub-app/review/thread-close.tsx +124 -0
  261. package/src/serve/hub-app/review/thread-control.tsx +4 -4
  262. package/src/serve/hub-app/review/thread-st.ts +222 -22
  263. package/src/serve/hub-app/review/trailer-card.tsx +1 -1
  264. package/src/serve/hub-app/review/trailer-timeline.tsx +2 -2
  265. package/src/serve/hub-app/review.css +216 -57
  266. package/src/serve/hub-app/section-head.tsx +51 -0
  267. package/src/serve/hub-app/social/calendar.tsx +5 -11
  268. package/src/serve/hub-app/social/comms-page.tsx +23 -10
  269. package/src/serve/hub-app/social/kit.tsx +8 -15
  270. package/src/serve/hub-app/social/next-release.tsx +3 -5
  271. package/src/serve/hub-app/social/post-card.tsx +3 -0
  272. package/src/serve/hub-app/social/post-page.tsx +80 -0
  273. package/src/serve/hub-app/social/problems.tsx +5 -9
  274. package/src/serve/hub-app/social/social-model.ts +13 -5
  275. package/src/serve/hub-app/social/social-page.tsx +1 -1
  276. package/src/serve/hub-app/social/social-st.ts +42 -5
  277. package/src/serve/hub-app/social.css +7 -17
  278. package/src/serve/hub-app/space.css +1 -1
  279. package/src/serve/hub-app/stores/stores-page.tsx +6 -2
  280. package/src/serve/hub-app/thread-row.tsx +101 -0
  281. package/src/serve/hub-app/time-ago.tsx +3 -2
  282. package/src/serve/hub-app/time-view.tsx +2 -1
  283. package/src/serve/hub-app/time.css +2 -5
  284. package/src/serve/hub-app/tree-row.tsx +1 -9
  285. package/src/serve/hub-app/vault-view.tsx +4 -4
  286. package/src/serve/hub-app/veille/veille-page.tsx +2 -11
  287. package/src/serve/hub-app/veille.css +0 -1
  288. package/src/serve/hub-app/waiting-svc.ts +4 -4
  289. package/src/serve/hub-app/when-view.tsx +6 -3
  290. package/src/serve/hub-app/wiki-st.ts +30 -4
  291. package/src/serve/hub-app/wikis-view.tsx +4 -3
  292. package/src/serve/hub-runtime.ts +20 -6
  293. package/src/serve/project-gutter-route.ts +16 -6
  294. package/src/serve/project-gutter.ts +6 -53
  295. package/src/serve/same-origin.ts +3 -0
  296. package/src/serve/secret-gate.ts +21 -0
  297. package/src/serve/serve-hub.ts +29 -20
  298. package/src/serve/tailnet-caller.ts +117 -0
  299. package/src/shipkit.ts +2 -2
  300. package/src/site/desk.ts +2 -2
  301. package/src/smoke/run-smoke.ts +3 -4
  302. package/src/social/brands.ts +4 -0
  303. package/src/social/card-drafts.ts +11 -19
  304. package/src/social/desk-index.ts +34 -13
  305. package/src/social/drafts.ts +4 -4
  306. package/src/social/import-drafts.ts +244 -0
  307. package/src/social/kind-pages.ts +3 -3
  308. package/src/social/kinds.ts +1 -1
  309. package/src/social/load.ts +89 -64
  310. package/src/social/media-kind.ts +68 -161
  311. package/src/social/media-of.ts +5 -4
  312. package/src/social/open.ts +3 -2
  313. package/src/social/post-object.ts +120 -0
  314. package/src/social/post-sources.ts +136 -0
  315. package/src/social/post-text.ts +103 -0
  316. package/src/social/posts.ts +378 -0
  317. package/src/social/presence.ts +7 -5
  318. package/src/social/publish/index.ts +17 -5
  319. package/src/social/publish/secret.ts +2 -2
  320. package/src/social/release-stage.ts +58 -57
  321. package/src/social/routes.ts +64 -24
  322. package/src/social/stage.ts +42 -57
  323. package/src/social/text.ts +4 -3
  324. package/src/social/thumbnail.ts +135 -43
  325. package/src/social/tracker.ts +1 -1
  326. package/src/social/writes.ts +12 -29
  327. package/src/stores/desk.ts +16 -11
  328. package/src/stores/unit.ts +2 -2
  329. package/src/trailer/sound/eleven.ts +33 -3
  330. package/src/urls/rows.ts +1 -1
  331. package/src/vault/vault-http.ts +11 -3
  332. package/src/vault/vault-import.ts +6 -1
  333. package/src/veille/identity.ts +2 -2
  334. package/src/wiki/graph-pages.ts +13 -1
  335. package/src/wiki/scan-md.ts +1 -1
  336. package/src/asks/asks-queue.ts +0 -424
  337. package/src/messages/suggest.ts +0 -96
  338. package/src/social/migrate.ts +0 -123
@@ -0,0 +1,385 @@
1
+ // what an agent asks of the owner in a thread, answered in one click (wiki tools/shipkit/threads.md, A question, A proposed
2
+ // change): a question's options, each words or a media drawn as a view, and a proposed change, each field drawn by its
3
+ // type and applied alone. The owner's words go with the click; words with no click answer « none of these »
4
+ import { observer } from 'mobx-react-lite'
5
+ import { useEffect, useRef, useState, type ReactNode } from 'react'
6
+ import type { ReplyCell } from '../../../review/cells.ts'
7
+ import { kindOfValue, type ValueKind } from '../../../review/kinds.ts'
8
+ import { CodeHunk, Swatches, WordDiff } from './diff-view.tsx'
9
+ import { AutoText } from '../auto-text.tsx'
10
+ import { renderMdInline } from '../md.ts'
11
+ import { keepFocus } from './kit.tsx'
12
+ import type { ReviewSt } from './review-st.ts'
13
+ import { ViewCell } from './review-views.tsx'
14
+ import type { ThreadSt } from './thread-st.ts'
15
+
16
+ type Field = NonNullable<ReplyCell['propose']>['fields'][number]
17
+
18
+ /** an option's or a field's media, a view of the item the message sits on, drawn read only */
19
+ const MessageView = observer(({ rv, card, c, i }: { rv: ReviewSt; card: ThreadSt; c: ReplyCell; i: number }) => {
20
+ const version = card.versionOf(c.on)
21
+ const v = version?.item.views[i]
22
+ if (!version || !v) return <div className="rv-dim">the media is gone from the store</div>
23
+ return <ViewCell ver={{ rv, card, cell: version, live: false, claim: false }} v={v} i={i} noted={false} />
24
+ })
25
+
26
+ /** an agent's question: one button per option, its media over it, its pick marked; one click answers, the words box goes
27
+ * with it, and words alone say none of them */
28
+ export const AskBody = observer(({ rv, card, c, ask }: { rv: ReviewSt; card: ThreadSt; c: ReplyCell; ask: NonNullable<ReplyCell['ask']> }) => {
29
+ if (ask.kind !== undefined && ask.kind !== 'choice') return <KindAskBody rv={rv} card={card} c={c} ask={ask} />
30
+ const done = ask.answered
31
+ const media = ask.views?.some((v) => v !== null) === true
32
+ const words = (card.hints[c.id] ?? '').trim() !== ''
33
+ const button = (o: string, i: number) => (
34
+ <button
35
+ key={i}
36
+ className={`rv-askopt${done?.option === i ? ' picked' : ''}${ask.pick === i ? ' pick' : ''}`}
37
+ disabled={done !== undefined || card.busy}
38
+ onMouseDown={keepFocus}
39
+ onClick={() => void card.answer(c, { option: i })}
40
+ title={ask.pick === i ? "the agent's pick" : undefined}
41
+ >
42
+ <span className="rv-askn">{i + 1}</span>
43
+ <span className="rv-askoptlabel mdi" dangerouslySetInnerHTML={{ __html: renderMdInline(o) }} />
44
+ {ask.pick === i ? <span className="rv-mypick">my pick</span> : null}
45
+ {done?.option === i ? <span className="rv-badge">✓ yours</span> : null}
46
+ </button>
47
+ )
48
+ return (
49
+ <div className="rv-ask">
50
+ {done || c.superseded ? null : <AnswerWords card={card} c={c} placeholder="a word with your answer (optional), then click an option" />}
51
+ {media ? (
52
+ <div className="rv-askmedia">
53
+ {ask.options.map((o, i) => (
54
+ <div key={i} className={`rv-askcard${done?.option === i ? ' picked' : ''}${ask.pick === i ? ' pick' : ''}`}>
55
+ {ask.views?.[i] != null ? <MessageView rv={rv} card={card} c={c} i={ask.views[i]!} /> : null}
56
+ {button(o, i)}
57
+ </div>
58
+ ))}
59
+ </div>
60
+ ) : (
61
+ <div className="rv-askopts">{ask.options.map(button)}</div>
62
+ )}
63
+ {!done && words ? (
64
+ <div className="rv-askopts">
65
+ <button className="rv-askopt" disabled={card.busy} onMouseDown={keepFocus} onClick={() => void card.noneOf(c)}>none of these: send my words</button>
66
+ </div>
67
+ ) : null}
68
+ </div>
69
+ )
70
+ })
71
+
72
+ type CellAsk = NonNullable<ReplyCell['ask']>
73
+
74
+ /** a question of another answer kind (wiki tools/shipkit/threads-asks.md, Answer kinds): a checklist's boxes, a confirm's
75
+ * « done », a text's or a url's field, a secret's place; the owner's words alone answer it as none, or ride on a checklist */
76
+ const KindAskBody = observer(({ rv, card, c, ask }: { rv: ReviewSt; card: ThreadSt; c: ReplyCell; ask: CellAsk }) => {
77
+ const words = (card.hints[c.id] ?? '').trim() !== ''
78
+ return (
79
+ <div className={`rv-ask rv-ask-${ask.kind}`}>
80
+ {ask.kind === 'checklist' ? <Checklist card={card} c={c} ask={ask} /> : null}
81
+ {ask.kind === 'confirm' ? <Confirm card={card} c={c} ask={ask} /> : null}
82
+ {ask.kind === 'text' || ask.kind === 'url' ? <ValueField card={card} c={c} ask={ask} /> : null}
83
+ {ask.kind === 'secret' ? <SecretPlace rv={rv} card={card} c={c} ask={ask} /> : null}
84
+ {ask.kind === 'file' ? <div className="rv-dim">{ask.value ? `his file: view ${(ask.value.view ?? 0) + 1}` : 'a file he drops: not built in the hub yet'}</div> : null}
85
+ {ask.none !== undefined ? <div className="rv-dim">answered with words: {ask.none}</div> : null}
86
+ {(ask.open || ask.kind === 'checklist') && ask.kind !== 'secret' && !c.superseded ? (
87
+ <div className="rv-askwords">
88
+ <AnswerWords card={card} c={c} placeholder={ask.kind === 'checklist' ? 'a word on these steps (optional)' : 'or answer with words alone'} />
89
+ {words ? (
90
+ <button className="rv-askopt" disabled={card.busy} onMouseDown={keepFocus} onClick={() => void card.noneOf(c)}>
91
+ {ask.kind === 'checklist' ? 'send my words' : 'send my words, not this'}
92
+ </button>
93
+ ) : null}
94
+ </div>
95
+ ) : null}
96
+ </div>
97
+ )
98
+ })
99
+
100
+ /** a checklist: a box a line, ticked or unticked in one click, « 2 of 5 » over it */
101
+ const Checklist = observer(({ card, c, ask }: { card: ThreadSt; c: ReplyCell; ask: CellAsk }) => {
102
+ const lines = (ask.lines ?? []).map((l, i) => ({ ...l, tick: card.ticking[`${c.id}#${i}`] ?? l.tick }))
103
+ const done = lines.filter((l) => l.tick).length
104
+ return (
105
+ <div className="rv-checklist">
106
+ <div className={`rv-checkcount${done === lines.length ? ' all' : ''}`}>{done === lines.length ? `✓ all ${lines.length} done` : `${done} of ${lines.length} done`}</div>
107
+ {lines.map((l, i) => (
108
+ <label key={i} className={`rv-checkline${l.tick ? ' ticked' : ''}`}>
109
+ <input type="checkbox" checked={l.tick} onChange={() => void card.tick(c, i, !l.tick)} />
110
+ <span className="rv-checkn">{i + 1}</span>
111
+ <span className="rv-checktext"><InlineMd text={l.text} /></span>
112
+ </label>
113
+ ))}
114
+ </div>
115
+ )
116
+ })
117
+
118
+ /** a step he does in the real world: one « done » */
119
+ const Confirm = observer(({ card, c, ask }: { card: ThreadSt; c: ReplyCell; ask: CellAsk }) => {
120
+ const line = ask.lines?.[0]
121
+ if (line?.tick) return <div className="rv-checkcount all">✓ done{line.at ? ` · ${new Date(line.at).toLocaleString()}` : ''}</div>
122
+ return (
123
+ <div className="rv-askopts">
124
+ <button className="rv-askopt pick" disabled={card.busy || !ask.open} onMouseDown={keepFocus} onClick={() => void card.tick(c, 0, true)}>
125
+ done
126
+ </button>
127
+ </div>
128
+ )
129
+ })
130
+
131
+ /** a value he types, a text or a url; once given, what he gave */
132
+ const ValueField = observer(({ card, c, ask }: { card: ThreadSt; c: ReplyCell; ask: CellAsk }) => {
133
+ const box = card.fieldBox(c, 'value')
134
+ const value = card.hints[box] ?? ''
135
+ if (ask.value && !ask.open)
136
+ return (
137
+ <div className="rv-askvalue">
138
+ <span className="rv-badge">✓ given</span> {ask.kind === 'url' ? <a href={ask.value.text} target="_blank" rel="noreferrer noopener">{ask.value.text}</a> : <span className="rv-valuetext">{ask.value.text}</span>}
139
+ {ask.kind === 'url' ? <span className="rv-dim">{ask.value.opens ? ` opens (${ask.value.opens})` : ' did not open from this Mac'}</span> : null}
140
+ </div>
141
+ )
142
+ const send = (): void => void card.answer(c, { value })
143
+ const bad = ask.kind === 'url' && value.trim() !== '' && !/^https?:\/\/\S+$/.test(value.trim())
144
+ return (
145
+ <div className="rv-askfield">
146
+ {ask.kind === 'url' ? (
147
+ <input type="url" value={value} placeholder="https://…" spellCheck={false} onChange={(e) => card.setHint(box, e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter' && !bad) send() }} />
148
+ ) : (
149
+ <AutoText className="rv-answerwords" value={value} placeholder="your answer" onText={(t) => card.setHint(box, t)} />
150
+ )}
151
+ <button className="rv-askopt pick" disabled={card.busy || value.trim() === '' || bad} onMouseDown={keepFocus} onClick={send}>
152
+ send
153
+ </button>
154
+ {bad ? <div className="rv-dim">a link starts with https:// or http://</div> : null}
155
+ </div>
156
+ )
157
+ })
158
+
159
+ type SecretFacts = { name: string; login: boolean; readers: { words: string; short: string }; held: { held: string; at?: number | null }; refused?: string }
160
+
161
+ /** a secret's place in the thread (wiki tools/shipkit/threads-asks.md, The secret field): once stored, its name and
162
+ * when; open, the field, or why this browser may not type it */
163
+ const SecretPlace = observer(({ rv, card, c, ask }: { rv: ReviewSt; card: ThreadSt; c: ReplyCell; ask: CellAsk }) => {
164
+ const s = ask.secret
165
+ if (s?.stored) return <div className="rv-askvalue"><span className="rv-badge">🔒 stored</span> as <code>{s.name}</code> · {new Date(s.stored).toLocaleString()}</div>
166
+ if (!ask.open) return <div className="rv-dim">🔒 <code>{s?.name}</code>: not given</div>
167
+ return <SecretField rv={rv} card={card} c={c} name={s?.name ?? ''} />
168
+ })
169
+
170
+ /** the field itself: a password input, its value in this component's state alone (never the answer box's draft, never
171
+ * the browser's storage), sent once to the hub on this Mac, emptied whatever the answer; while it shows, the hub
172
+ * unloads the repo pages it keeps alive */
173
+ const SecretField = observer(({ rv, card, c, name }: { rv: ReviewSt; card: ThreadSt; c: ReplyCell; name: string }) => {
174
+ const [facts, setFacts] = useState<SecretFacts | null>(null)
175
+ const [value, setValue] = useState('')
176
+ const [account, setAccount] = useState('')
177
+ const [err, setErr] = useState<string | null>(null)
178
+ const [busy, setBusy] = useState(false)
179
+ const [decline, setDecline] = useState(false)
180
+ const re = c.id.slice(c.on.length + 1)
181
+ const url = rv.url(`/api/review/${c.on}/secret`)
182
+ const embedded = rv.home.embedded
183
+ useEffect(() => (embedded ? undefined : rv.home.frames.hold()), [embedded, rv])
184
+ useEffect(() => {
185
+ let live = true
186
+ fetch(`${url}?re=${encodeURIComponent(re)}`)
187
+ .then(async (r) => (r.ok ? ((await r.json()) as SecretFacts) : Promise.reject(new Error(await r.text()))))
188
+ .then((f) => live && setFacts(f))
189
+ .catch((e: Error) => live && setErr(e.message))
190
+ return () => {
191
+ live = false
192
+ }
193
+ }, [url, re])
194
+ const send = async (): Promise<void> => {
195
+ const v = value
196
+ setValue('')
197
+ if (v.trim() === '' || busy) return
198
+ setBusy(true)
199
+ setErr(null)
200
+ try {
201
+ const r = await fetch(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ re, value: v, ...(facts?.login ? { account } : {}) }) })
202
+ if (!r.ok) setErr(await r.text())
203
+ else void card.refresh()
204
+ } catch (e) {
205
+ setErr((e as Error).message)
206
+ } finally {
207
+ setBusy(false)
208
+ }
209
+ }
210
+ const refused = embedded ? 'a secret is typed in the hub itself, not in a page that frames it: open this thread in the hub' : facts?.refused
211
+ return (
212
+ <div className="rv-keyfield">
213
+ <div className="rv-keyhead">
214
+ 🔒 <code>{name}</code>
215
+ {facts ? <span className="rv-dim"> · read by {facts.readers.short}</span> : null}
216
+ {facts?.held.held === 'stored' ? <span className="rv-dim"> · replaces the value held{facts.held.at ? ` since ${new Date(facts.held.at).toLocaleDateString()}` : ''}</span> : null}
217
+ </div>
218
+ {facts ? <div className="rv-dim rv-keywho" title={facts.readers.words}>{facts.readers.words}</div> : null}
219
+ {refused ? (
220
+ <div className="rv-keyno">{refused}</div>
221
+ ) : facts ? (
222
+ <div className="rv-askfield">
223
+ {facts.login ? <input type="text" autoComplete="off" spellCheck={false} data-1p-ignore="" data-lpignore="true" placeholder="account (the email or user name you sign in with)" value={account} onChange={(e) => setAccount(e.target.value)} /> : null}
224
+ <input
225
+ type="password"
226
+ className="rv-keyvalue"
227
+ autoComplete="off"
228
+ spellCheck={false}
229
+ data-1p-ignore=""
230
+ data-lpignore="true"
231
+ placeholder={facts.login ? 'password' : `paste the value of ${name}`}
232
+ value={value}
233
+ onChange={(e) => setValue(e.target.value)}
234
+ onKeyDown={(e) => {
235
+ if (e.key === 'Enter') void send()
236
+ }}
237
+ />
238
+ <button className="rv-askopt pick" disabled={busy || value.trim() === '' || (facts.login && account.trim() === '')} onMouseDown={keepFocus} onClick={() => void send()}>
239
+ store
240
+ </button>
241
+ </div>
242
+ ) : null}
243
+ {facts && !refused ? <div className="rv-dim">one line; a key of several lines (a PEM file): <code>sk secret set {name} &lt; file</code></div> : null}
244
+ {err ? <div className="err">✗ {err}</div> : null}
245
+ {decline ? (
246
+ <div className="rv-askwords">
247
+ <AnswerWords card={card} c={c} placeholder="why not (never the key itself)" />
248
+ <button className="rv-askopt" disabled={card.busy || (card.hints[c.id] ?? '').trim() === ''} onMouseDown={keepFocus} onClick={() => void card.noneOf(c)}>send my words</button>
249
+ </div>
250
+ ) : (
251
+ <button className="ghost rv-keydecline" onClick={() => setDecline(true)}>I will not give it</button>
252
+ )}
253
+ </div>
254
+ )
255
+ })
256
+
257
+ /** one line of markdown as a checklist line holds it: bold, `code` and [links](url), nothing else */
258
+ function InlineMd({ text }: { text: string }) {
259
+ const out: ReactNode[] = []
260
+ const re = /\*\*\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)\*\*|\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)|\*\*([^*]+)\*\*|`([^`]+)`/g
261
+ let at = 0
262
+ for (let m = re.exec(text); m !== null; m = re.exec(text)) {
263
+ if (m.index > at) out.push(text.slice(at, m.index))
264
+ const k = out.length
265
+ if (m[1] !== undefined) out.push(<b key={k}><a href={m[2]} target="_blank" rel="noreferrer noopener">{m[1]}</a></b>)
266
+ else if (m[3] !== undefined) out.push(<a key={k} href={m[4]} target="_blank" rel="noreferrer noopener">{m[3]}</a>)
267
+ else if (m[5] !== undefined) out.push(<b key={k}>{m[5]}</b>)
268
+ else out.push(<code key={k}>{m[6]}</code>)
269
+ at = m.index + m[0].length
270
+ }
271
+ if (at < text.length) out.push(text.slice(at))
272
+ return <>{out}</>
273
+ }
274
+
275
+ type DiffProps = { rv: ReviewSt; card: ThreadSt; c: ReplyCell; f: Field; after: string }
276
+
277
+ /** each diff view a house kind names (review/kinds.ts): a new kind names one of these, or brings its own page */
278
+ const DIFF_VIEWS: Record<ValueKind['diff'], (p: DiffProps) => ReactNode> = {
279
+ words: ({ f, after }) => <WordDiff {...(f.before !== undefined ? { before: f.before } : {})} after={after} />,
280
+ swatches: ({ f, after }) => <Swatches {...(f.before !== undefined ? { before: f.before } : {})} after={after} />,
281
+ hunk: ({ f, after }) => <CodeHunk {...(f.before !== undefined ? { before: f.before } : {})} after={after} {...(f.lang ? { lang: f.lang } : {})} />,
282
+ media: ({ rv, card, c, f }) => (f.view !== undefined ? <MessageView rv={rv} card={card} c={c} i={f.view} /> : <div className="rv-dim">the files are gone from the store</div>),
283
+ }
284
+
285
+ /** one field's change, drawn by the diff view of its kind */
286
+ const FieldDiff = observer(({ rv, card, c, f }: { rv: ReviewSt; card: ThreadSt; c: ReplyCell; f: Field }) => DIFF_VIEWS[kindOfValue(f.type).diff]({ rv, card, c, f, after: f.applied?.text ?? f.after }))
287
+
288
+ /** the owner's edit of one field's value before he applies it, as its kind edits: a colour's picker and value, a box for words
289
+ * or code (behind « edit », so a table he applies as it is stays short) */
290
+ const FieldEdit = observer(({ card, c, f }: { card: ThreadSt; c: ReplyCell; f: Field }) => {
291
+ const box = card.fieldBox(c, f.key)
292
+ const value = card.hints[box] ?? ''
293
+ const edit = kindOfValue(f.type).edit
294
+ if (edit === null) return null
295
+ if (edit === 'color')
296
+ return (
297
+ <span className="rv-coloredit">
298
+ <input type="color" value={/^#[0-9a-f]{6}$/i.test(value || f.after) ? value || f.after : '#000000'} onChange={(e) => card.setHint(box, e.target.value)} title="pick another colour before you apply" />
299
+ <input type="text" value={value} placeholder={f.after} onChange={(e) => card.setHint(box, e.target.value)} />
300
+ </span>
301
+ )
302
+ if (card.hints[box] === undefined)
303
+ return (
304
+ <button className="ghost rv-fieldeditbtn" onMouseDown={keepFocus} onClick={() => card.setHint(box, f.after)} title="change the value before you apply it">
305
+ edit
306
+ </button>
307
+ )
308
+ return <AutoText className={`rv-answerwords${edit === 'code' ? ' code' : ''}`} autoFocus value={value} onText={(t) => card.setHint(box, t)} />
309
+ })
310
+
311
+ const ApplyButton = observer(({ card, c, f }: { card: ThreadSt; c: ReplyCell; f: Field }) => {
312
+ if (f.applied) return <span className="rv-badge" title={f.applied.text}>✓ applied</span>
313
+ const edited = (card.hints[card.fieldBox(c, f.key)] ?? '').trim() !== '' && card.hints[card.fieldBox(c, f.key)] !== f.after
314
+ return (
315
+ <button className="rv-askopt pick" disabled={card.busy} onMouseDown={keepFocus} onClick={() => void card.answer(c, { apply: true, field: f.key })}>
316
+ {edited ? 'apply my edit' : 'apply'}
317
+ </button>
318
+ )
319
+ })
320
+
321
+ /** an agent's proposed change: one field drawn alone, several as a table of rows; each row its own « apply », « apply all »
322
+ * under it; a kind with its own diff page frames it above */
323
+ export const ProposeBody = observer(({ rv, card, c, p }: { rv: ReviewSt; card: ThreadSt; c: ReplyCell; p: NonNullable<ReplyCell['propose']> }) => {
324
+ const left = p.fields.filter((f) => !f.applied)
325
+ const one = p.fields.length === 1 ? p.fields[0]! : null
326
+ return (
327
+ <div className="rv-propose">
328
+ <div className="rv-dim">on {p.on}</div>
329
+ {p.page ? <DiffPage rv={rv} c={c} page={p.page} on={p.on} /> : null}
330
+ {one ? (
331
+ <>
332
+ <FieldDiff rv={rv} card={card} c={c} f={one} />
333
+ {p.open && !one.applied ? <FieldEdit card={card} c={c} f={one} /> : null}
334
+ <div className="rv-askopts">{p.open || one.applied ? <ApplyButton card={card} c={c} f={one} /> : <span className="rv-badge">answered with words</span>}</div>
335
+ </>
336
+ ) : (
337
+ <div className="rv-fieldtable">
338
+ {p.fields.map((f) => (
339
+ <div key={f.key} className={`rv-fieldrow${f.applied ? ' applied' : ''}`}>
340
+ <div className="rv-fieldkey">{f.key}<span className="rv-dim"> {f.type === 'code' && f.lang ? f.lang : kindOfValue(f.type).label}</span></div>
341
+ <div className="rv-fieldval">
342
+ <FieldDiff rv={rv} card={card} c={c} f={f} />
343
+ {p.open && !f.applied ? <FieldEdit card={card} c={c} f={f} /> : null}
344
+ </div>
345
+ <div className="rv-fieldgo">{p.open || f.applied ? <ApplyButton card={card} c={c} f={f} /> : null}</div>
346
+ </div>
347
+ ))}
348
+ </div>
349
+ )}
350
+ {p.open && !c.superseded ? <AnswerWords card={card} c={c} placeholder="a word with it (optional); words alone, sent with « send my words », answer it without applying" /> : null}
351
+ {p.open ? (
352
+ <div className="rv-askopts">
353
+ {!one && left.length > 1 ? (
354
+ <button className="rv-askopt pick" disabled={card.busy} onMouseDown={keepFocus} onClick={() => void card.applyAll(c, left.map((f) => f.key))}>apply all {left.length}</button>
355
+ ) : null}
356
+ {(card.hints[c.id] ?? '').trim() !== '' ? (
357
+ <button className="rv-askopt" disabled={card.busy} onMouseDown={keepFocus} onClick={() => void card.noneOf(c)}>send my words</button>
358
+ ) : null}
359
+ </div>
360
+ ) : null}
361
+ </div>
362
+ )
363
+ })
364
+
365
+ /** the repo's own page that draws this change, framed with its keys: the thread, the message, the object; it reads the
366
+ * fields from the hub's api, and its keys stay in its own frame */
367
+ const DiffPage = ({ rv, c, page, on }: { rv: ReviewSt; c: ReplyCell; page: string; on: string }) => {
368
+ const ref = useRef<HTMLIFrameElement>(null)
369
+ const keys = `thread=${encodeURIComponent(c.on)}&re=${encodeURIComponent(c.id.slice(c.on.length + 1))}&on=${encodeURIComponent(on)}`
370
+ useEffect(() => {
371
+ const onMessage = (e: MessageEvent): void => {
372
+ if (e.source !== ref.current?.contentWindow || e.origin !== location.origin) return
373
+ const m = (e.data ?? {}) as { shipkit?: unknown }
374
+ if (m.shipkit === 'ready') ref.current?.contentWindow?.postMessage({ shipkit: 'hello', keys, theme: document.documentElement.dataset.theme === 'light' ? 'light' : 'dark', identity: null, on: true }, location.origin)
375
+ }
376
+ window.addEventListener('message', onMessage)
377
+ return () => window.removeEventListener('message', onMessage)
378
+ }, [keys])
379
+ return <iframe ref={ref} className="rv-diffpage" title={`${page}: the change`} src={`${rv.url(`/page/${page}/`)}?${keys}`} />
380
+ }
381
+
382
+ /** the words that go with an answer: the hint box of the cell, kept per cell until sent */
383
+ export const AnswerWords = observer(({ card, c, placeholder }: { card: ThreadSt; c: ReplyCell; placeholder: string }) => (
384
+ <AutoText className="rv-answerwords" placeholder={placeholder} value={card.hints[c.id] ?? ''} onText={(t) => card.setHint(c.id, t)} />
385
+ ))