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
@@ -8,12 +8,14 @@ import sharp from 'sharp'
8
8
  import { LAYOUT } from '../core/layout.ts'
9
9
  import { isClip } from '../releases/model.ts'
10
10
  import { litStillAt, probe, stillAt } from '../review/media.ts'
11
+ import type { Place } from '../assets/kits/poster-thumbnail.ts'
11
12
  import { coverInPlace, pictureOfClip, type Covered } from './cover.ts'
12
- import { fileList, longVideo, mediaNames, parseDraft, resolveMedia } from './drafts.ts'
13
- import { parseFrontmatter, setMeta } from './md.ts'
14
- import { DRAFT_NAME, draftsDir } from './load.ts'
13
+ import { longVideo, mediaNames } from './drafts.ts'
14
+ import { postMediaBack } from './media-kind.ts'
15
+ import { shaOf } from '../media-store/content.ts'
16
+ import { groupNow, mediaOf, parsedOf, postMediaPath } from './post-sources.ts'
17
+ import { setGroup } from './posts.ts'
15
18
  import { guardWith, type SocialUnit } from './unit.ts'
16
- import { commitPaths } from './writes.ts'
17
19
 
18
20
  /** what makes a thumbnail: a video and a time in it, or a still; the words; the crop of the frame */
19
21
  export type ThumbAsk = {
@@ -33,9 +35,28 @@ export type ThumbAsk = {
33
35
  plain?: boolean
34
36
  /** a draft's videos open on the thumbnail (cover.ts); unset is on, false is kept in the recipe as `--no-cover` */
35
37
  cover?: boolean
38
+ /** `card` (the default): the frame as a tilted card beside the words; `poster`: the frame fills the picture, a
39
+ * game's or a studio's look (poster-thumbnail.ts) */
40
+ layout?: Layout
41
+ /** a poster: the side the words take, the figures standing on the other */
42
+ place?: Place
43
+ /** a poster: the name as a picture, the game's own lettering */
44
+ wordmark?: string
45
+ /** a poster: the studio's mark in a free bottom corner */
46
+ studio?: string
47
+ /** a poster: the labels under the line, a row of pills */
48
+ tag?: string[]
49
+ /** a poster: cut outs on the free side, `<png>:flip` mirrored */
50
+ figure?: string[]
36
51
  }
37
52
 
38
- const FLAGS = ['at', 'frame', 'crop', 'title', 'line', 'chip', 'badge'] as const
53
+ export type Layout = 'card' | 'poster'
54
+ const LAYOUTS: readonly Layout[] = ['card', 'poster']
55
+ const PLACES: readonly Place[] = ['left', 'right', 'center']
56
+ const FLAGS = ['at', 'frame', 'crop', 'title', 'line', 'chip', 'badge', 'layout', 'place', 'wordmark', 'studio'] as const
57
+ const LISTS = ['tag', 'figure'] as const
58
+ /** what a poster adds, refused with --plain as every word is */
59
+ const DRAWN = ['title', 'line', 'chip', 'badge', 'layout', 'place', 'wordmark', 'studio', 'tag', 'figure'] as const
39
60
 
40
61
  /** where a video's thumbnail goes: beside it, its name and `-thumbnail.jpg` */
41
62
  export const thumbnailOfVideo = (video: string): string => join(dirname(video), `${basename(video).replace(/\.[^.]+$/, '')}-thumbnail.jpg`)
@@ -46,6 +67,7 @@ const quoted = (v: string): string => (/^[^\s"']+$/.test(v) ? v : JSON.stringify
46
67
  export function recipeLine(a: ThumbAsk): string {
47
68
  const words = a.video ? [quoted(a.video)] : []
48
69
  for (const f of FLAGS) if (a[f] !== undefined && a[f] !== '') words.push(`--${f}`, quoted(String(a[f])))
70
+ for (const f of LISTS) for (const v of a[f] ?? []) words.push(`--${f}`, quoted(v))
49
71
  if (a.plain) words.push('--plain')
50
72
  if (a.cover === false) words.push('--no-cover')
51
73
  return words.join(' ')
@@ -67,15 +89,31 @@ export function parseRecipe(line: string): ThumbAsk {
67
89
  else out.cover = false
68
90
  continue
69
91
  }
70
- const f = w.slice(2) as (typeof FLAGS)[number]
92
+ const f = w.slice(2)
71
93
  const v = words[++i]
72
- if (!FLAGS.includes(f) || v === undefined) throw new Error(`thumbnail recipe: ${w} ${v === undefined ? 'has no value' : 'is no flag of it'} (${FLAGS.map((x) => `--${x}`).join(' ')} --no-cover)`)
73
- if (f === 'at') out.at = seconds(v)
74
- else out[f] = v
94
+ const known = [...FLAGS, ...LISTS].find((x) => x === f)
95
+ if (known === undefined || v === undefined) throw new Error(`thumbnail recipe: ${w} ${v === undefined ? 'has no value' : 'is no flag of it'} (${[...FLAGS, ...LISTS].map((x) => `--${x}`).join(' ')} --no-cover)`)
96
+ if (known === 'at') out.at = seconds(v)
97
+ else if (known === 'layout') out.layout = layoutOf(v)
98
+ else if (known === 'place') out.place = placeOf(v)
99
+ else if (known === 'tag' || known === 'figure') out[known] = [...(out[known] ?? []), v]
100
+ else out[known] = v
75
101
  }
76
102
  return out
77
103
  }
78
104
 
105
+ export const layoutOf = (v: string): Layout => {
106
+ const l = LAYOUTS.find((x) => x === v)
107
+ if (!l) throw new Error(`--layout: card or poster, not ${v}`)
108
+ return l
109
+ }
110
+
111
+ export const placeOf = (v: string): Place => {
112
+ const p = PLACES.find((x) => x === v)
113
+ if (!p) throw new Error(`--place: left, right or center, not ${v}`)
114
+ return p
115
+ }
116
+
79
117
  const seconds = (v: string): number => {
80
118
  const n = Number(v)
81
119
  if (!(n >= 0)) throw new Error(`--at ${v}: seconds into the video`)
@@ -105,7 +143,7 @@ export async function makeThumbnail(root: string, ask: ThumbAsk, cwd = root, uni
105
143
  const { loadBrand, identityLogo } = await import('../assets/run-assets.ts')
106
144
  const { renderThumbnail, THUMB_MAX_BYTES, TooLong } = await import('../assets/kits/identity-kit.ts')
107
145
  if (ask.plain) {
108
- const drawn = (['title', 'line', 'chip', 'badge'] as const).filter((k) => ask[k] !== undefined)
146
+ const drawn = DRAWN.filter((k) => ask[k] !== undefined)
109
147
  if (drawn.length > 0) throw new Error(`--plain is the frame as it is, nothing drawn on it: no --${drawn.join(', --')}`)
110
148
  }
111
149
  const brand = ask.plain ? null : await loadBrand(root)
@@ -152,16 +190,47 @@ export async function makeThumbnail(root: string, ask: ThumbAsk, cwd = root, uni
152
190
  const recipe: ThumbAsk = { ...(ask.video ? { video: ask.video, ...(at != null ? { at } : {}) } : { frame: ask.frame! }), ...(ask.crop ? { crop: ask.crop } : {}), plain: true }
153
191
  return { file, bytes: out.length, at, recipe, alt, notes: [] }
154
192
  }
193
+ // the brand's kept recipe under the flags: a game's poster, its lettering, figures and studio, in every video
194
+ const kept = brand.thumbnail ?? {}
195
+ const layout = ask.layout ?? kept.layout ?? 'card'
155
196
  const title = ask.title ?? brand.name
156
- let line = ask.line ?? brand.tagline
197
+ const typedLine = ask.line ?? kept.line
198
+ let line = typedLine ?? brand.tagline
199
+ const badge = ask.badge ?? kept.badge
157
200
  const notes: string[] = []
158
- const logo = await identityLogo(root)
159
- const draw = (l: string | undefined): Promise<Buffer> =>
160
- renderThumbnail(brand, root, { title, ...(l ? { line: l } : {}), ...(ask.chip ? { chip: ask.chip } : {}), ...(ask.badge ? { badge: ask.badge } : {}), frame }, logo ? { markFile: join(root, logo) } : {})
201
+ const existing = (p: string, from: string): string => {
202
+ const f = isAbsolute(p) ? p : resolve(from, p)
203
+ if (!existsSync(f)) throw new Error(`no file ${f}`)
204
+ return f
205
+ }
206
+ const picture = (typed: string | undefined, brandOwn: string | undefined): Buffer | undefined =>
207
+ typed ? readFileSync(existing(typed, cwd)) : brandOwn ? readFileSync(existing(brandOwn, root)) : undefined
208
+ const figureOf = (spec: string, from: string): { image: Buffer; flip: boolean } => {
209
+ const flip = spec.endsWith(':flip')
210
+ return { image: readFileSync(existing(flip ? spec.slice(0, -5) : spec, from)), flip }
211
+ }
212
+ const tags = ask.tag ?? kept.tags ?? []
213
+ const poster =
214
+ layout === 'poster'
215
+ ? {
216
+ place: ask.place ?? kept.place ?? 'left',
217
+ wordmark: picture(ask.wordmark, kept.wordmark),
218
+ studio: picture(ask.studio, kept.studio),
219
+ figures: ask.figure ? ask.figure.map((f) => figureOf(f, cwd)) : (kept.figures ?? []).map((f) => figureOf(f, root)),
220
+ }
221
+ : null
222
+ if (!poster && (ask.place || ask.wordmark || ask.studio || ask.tag || ask.figure))
223
+ throw new Error('--place, --wordmark, --studio, --tag and --figure draw a poster: add --layout poster')
224
+ const logo = poster ? null : await identityLogo(root)
225
+ const draw = async (l: string | undefined): Promise<Buffer> => {
226
+ if (!poster) return renderThumbnail(brand, root, { title, ...(l ? { line: l } : {}), ...(ask.chip ? { chip: ask.chip } : {}), ...(badge ? { badge } : {}), frame }, logo ? { markFile: join(root, logo) } : {})
227
+ const { renderPoster } = await import('../assets/kits/poster-thumbnail.ts')
228
+ return renderPoster(brand, root, { title, ...(l ? { line: l } : {}), tags, ...(badge ? { badge } : {}), frame, ...poster })
229
+ }
161
230
  // a default nobody typed is never refused under a flag: a tagline too long is left out, a name too long says whose it is
162
231
  const jpg = await draw(line).catch(async (e: unknown) => {
163
232
  const flag = e instanceof TooLong ? e.flag : null
164
- if (flag === 'line' && ask.line === undefined) {
233
+ if (flag === 'line' && typedLine === undefined) {
165
234
  notes.push(`the brand's tagline is too long for the line, left out: --line "<a few words>" gives one`)
166
235
  line = undefined
167
236
  return draw(undefined)
@@ -170,8 +239,8 @@ export async function makeThumbnail(root: string, ask: ThumbAsk, cwd = root, uni
170
239
  throw e
171
240
  })
172
241
  if (jpg.length > THUMB_MAX_BYTES) throw new Error(`the thumbnail weighs ${(jpg.length / 1e6).toFixed(1)} MB, over the 2 MB YouTube takes: crop a calmer part of the frame`)
173
- const words = [title, line, ask.chip, ask.badge].filter((x): x is string => !!x)
174
- const alt = `${title}${line ? `: ${line}` : ''}, beside a frame of the video`
242
+ const words = [title, line, ask.chip, badge, ...tags].filter((x): x is string => !!x)
243
+ const alt = `${title}${line ? `: ${line}` : ''}, ${poster ? 'over' : 'beside'} a frame of the video`
175
244
  const probeFile = join(dir, 'thumbnail.jpg')
176
245
  writeFileSync(probeFile, jpg)
177
246
  const problems = guardWith(unit, { alt, texts: words, files: [probeFile] })
@@ -179,7 +248,17 @@ export async function makeThumbnail(root: string, ask: ThumbAsk, cwd = root, uni
179
248
  const file = abs(ask.out ?? thumbnailOfVideo(source))
180
249
  mkdirSync(dirname(file), { recursive: true })
181
250
  writeFileSync(file, jpg)
182
- const recipe: ThumbAsk = { ...(ask.video ? { video: ask.video, ...(at != null ? { at } : {}) } : { frame: ask.frame! }), ...(ask.crop ? { crop: ask.crop } : {}), title, ...(line ? { line } : {}), ...(ask.chip ? { chip: ask.chip } : {}), ...(ask.badge ? { badge: ask.badge } : {}) }
251
+ const { layout: l0, place, wordmark, studio, tag, figure } = ask
252
+ const own: ThumbAsk = { ...(l0 ? { layout: l0 } : {}), ...(place ? { place } : {}), ...(wordmark ? { wordmark } : {}), ...(studio ? { studio } : {}), ...(tag ? { tag } : {}), ...(figure ? { figure } : {}) }
253
+ const recipe: ThumbAsk = {
254
+ ...(ask.video ? { video: ask.video, ...(at != null ? { at } : {}) } : { frame: ask.frame! }),
255
+ ...(ask.crop ? { crop: ask.crop } : {}),
256
+ title,
257
+ ...(ask.line ? { line: ask.line } : line && line !== kept.line ? { line } : {}),
258
+ ...(ask.chip ? { chip: ask.chip } : {}),
259
+ ...(ask.badge ? { badge: ask.badge } : {}),
260
+ ...own,
261
+ }
183
262
  return { file, bytes: jpg.length, at, recipe, alt, notes }
184
263
  } finally {
185
264
  rmSync(dir, { recursive: true, force: true })
@@ -192,19 +271,17 @@ const draftVideo = (media: string[]): string | null => media.find(longVideo) ??
192
271
  /** a video of the draft and what the cover did to it, or why it was left as it is */
193
272
  export type DraftCover = { media: string } & (Covered | { did: 'skipped'; why: string })
194
273
 
195
- /** a draft's thumbnail: its recipe (the draft's `thumbnail:` line) with `ask` over it, its video the draft's own unless
196
- * the recipe names one, written in its media as `<the draft's video>-thumbnail.jpg`, placed after that video in its
197
- * `media`, the recipe kept; unless `cover` is false, each of its videos that opens on that picture (pictureOfClip)
198
- * covered in place; the files committed */
274
+ /** a draft's thumbnail: its recipe (the group's `thumbnail` fact) with `ask` over it, its video the group's own unless
275
+ * the recipe names one, kept as `media/<the draft's video>-thumbnail.jpg`, placed after that video in its `media`, the
276
+ * recipe kept; unless `cover` is false, each of its videos that opens on that picture (pictureOfClip) covered, kept again
277
+ * under its own name */
199
278
  export async function thumbnailDraft(root: string, slug: string, ask: ThumbAsk, o: { unit?: SocialUnit | null } = {}): Promise<Thumb & { media: string; covers: DraftCover[] }> {
200
- const ddir = join(draftsDir(root), slug)
201
- const f = join(ddir, 'draft.md')
202
- if (!DRAFT_NAME.test(slug) || !existsSync(f)) throw new Error(`no draft ${slug}`)
203
- let raw = readFileSync(f, 'utf8')
204
- const meta = parseFrontmatter(raw).meta
205
- const media = fileList(meta.media)
279
+ const g = groupNow(root, slug)
280
+ if (g == null) throw new Error(`no draft ${slug}`)
281
+ const files = g.event.content.attachments ?? []
282
+ const media = g.group.media
206
283
  const own = draftVideo(media)
207
- const kept = meta.thumbnail ? parseRecipe(meta.thumbnail) : {}
284
+ const kept = g.group.meta['thumbnail'] ? parseRecipe(g.group.meta['thumbnail']) : {}
208
285
  const merged: ThumbAsk = { ...kept, ...ask }
209
286
  if (ask.frame) delete merged.video
210
287
  if (ask.video) delete merged.frame
@@ -214,36 +291,51 @@ export async function thumbnailDraft(root: string, slug: string, ask: ThumbAsk,
214
291
  }
215
292
  const named = own ?? merged.video ?? merged.frame!
216
293
  const name = join('media', basename(thumbnailOfVideo(named)))
217
- // a draft's media name resolves from its folder first, then the repo, as the load reads it
218
- const from = (p: string | undefined): string | undefined => (p === undefined ? undefined : (resolveMedia(p, ddir, root) ?? p))
294
+ // a name of the group's files is its file, fetched back when the disk lacks it; else a path from the repo's root
295
+ const from = async (p: string | undefined): Promise<string | undefined> => {
296
+ if (p === undefined) return undefined
297
+ const m = mediaOf(root, files, p)
298
+ return m ? await postMediaBack(m) : isAbsolute(p) ? p : resolve(root, p)
299
+ }
219
300
  // the picture an older cover shows, read before it is drawn again: its frames give way to the new one's
220
301
  const scratch = join(root, LAYOUT.tmp, 'thumbnails')
221
302
  mkdirSync(scratch, { recursive: true })
222
303
  const keep = mkdtempSync(join(scratch, 'was-'))
223
304
  try {
224
- const was = existsSync(join(ddir, name)) ? join(keep, 'was.jpg') : null
225
- if (was) copyFileSync(join(ddir, name), was)
226
- const t = await makeThumbnail(root, { ...merged, video: from(merged.video), frame: from(merged.frame), out: join(ddir, name) }, root, o.unit ?? null)
305
+ // none when neither the disk nor the Space gives it back: the cover is then drawn from the recipe alone
306
+ const old = mediaOf(root, files, name)
307
+ const at = old ? await postMediaBack(old) : null
308
+ const was = at != null && existsSync(at) ? join(keep, 'was.jpg') : null
309
+ if (at != null && was) copyFileSync(at, was)
310
+ const out = join(keep, basename(name))
311
+ const t = await makeThumbnail(root, { ...merged, video: await from(merged.video), frame: await from(merged.frame), out }, root, o.unit ?? null)
227
312
  const recipe: ThumbAsk = { ...t.recipe, ...(merged.video ? { video: merged.video } : { frame: merged.frame! }), ...(merged.cover === false ? { cover: false } : {}) }
228
313
  const list = media.filter((m) => m !== name)
229
314
  const after = own ? list.indexOf(own) + 1 : list.length
230
315
  list.splice(after, 0, name)
231
- raw = setMeta(setMeta(raw, 'media', list.join(', ')), 'thumbnail', recipeLine(recipe))
232
- writeFileSync(f, raw)
233
316
  const covers: DraftCover[] = []
317
+ const recovered: { file: string; name: string }[] = []
234
318
  if (merged.cover !== false) {
235
- const names = mediaNames(parseDraft(raw, f))
319
+ const names = mediaNames({ ...parsedOf(g), meta: { ...parsedOf(g).meta, media: list.join(', ') } })
236
320
  for (const v of names.filter(longVideo)) {
237
321
  if (pictureOfClip(names, v) !== name) continue
238
- const at = resolveMedia(v, ddir, root)
239
- if (at == null) covers.push({ media: v, did: 'skipped', why: 'not on the disk' })
322
+ const m = mediaOf(root, files, v)
323
+ const at = m ? await postMediaBack(m) : null
324
+ if (at == null || !existsSync(at)) covers.push({ media: v, did: 'skipped', why: 'not on the disk, nor in the Space' })
240
325
  else if (!/\.(mp4|m4v|mov)$/i.test(v)) covers.push({ media: v, did: 'skipped', why: 'a cover is written as mp4: give the draft an mp4 of it' })
241
- else covers.push({ media: v, ...(await coverInPlace(at, t.file, scratch, was)) })
326
+ else {
327
+ const copy = join(keep, `${recovered.length}-${basename(v)}`)
328
+ copyFileSync(at, copy)
329
+ const c = await coverInPlace(copy, t.file, scratch, was)
330
+ covers.push({ media: v, ...c })
331
+ if (c.did === 'covered' || c.did === 'replaced') recovered.push({ file: copy, name: v })
332
+ }
242
333
  }
243
334
  }
244
- const moved = covers.flatMap((c) => (c.did === 'covered' || c.did === 'replaced' ? [resolveMedia(c.media, ddir, root)!] : []))
245
- commitPaths([f, t.file, ...moved], `social: ${slug} takes its thumbnail`)
246
- return { ...t, recipe, media: name, covers }
335
+ const sha = await shaOf(t.file)
336
+ await setGroup(root, slug, { media: list, meta: { thumbnail: recipeLine(recipe) }, files: [{ file: t.file, name }, ...recovered] }, { why: 'thumbnail' })
337
+ // the picture where the group keeps it: the scratch copy goes with this call
338
+ return { ...t, file: postMediaPath(root, sha, name), recipe, media: name, covers }
247
339
  } finally {
248
340
  rmSync(keep, { recursive: true, force: true })
249
341
  }
@@ -13,7 +13,7 @@ import type { Desk } from './load.ts'
13
13
  import { openDesk } from './open.ts'
14
14
  import { matchPost, type PostMatch, postTime, profileChecks, trackRules } from './post-url.ts'
15
15
  import { hasPublicRead, POLL_AT_MS, publicPosts } from './public-read.ts'
16
- import { setPosted } from './writes.ts'
16
+ import { setPosted } from './posts.ts'
17
17
 
18
18
  /** an open counts this long: a post seen later is no longer taken for it */
19
19
  export const OPEN_FRESH_MS = 30 * 60_000
@@ -1,18 +1,16 @@
1
- // the desks' writes (wiki tools/shipkit/social.md, The desks in the hub): a heading's text, a post's URL, an account's
2
- // profile URL, a setup step. Each lands as a commit of its own paths (`git commit -- <paths>`, so no other staged work
1
+ // the desks' writes (wiki tools/shipkit/social.md, The desks in the hub): a post's words and URL (events, posts.ts), an
2
+ // account's profile URL, a setup step. Each file write lands as a commit of its own paths (`git commit -- <paths>`, so no other staged work
3
3
  // rides along), and the push goes in the background: a backup, never a wait, its failure an error line of the desk (push.ts). A path git ignores (a public repo's
4
4
  // drafts) is saved by its file alone. The post URL's message is the one presence.ts reads the moment of a post from
5
- import { existsSync, readFileSync, writeFileSync } from 'node:fs'
5
+ import { readFileSync, writeFileSync } from 'node:fs'
6
6
  import { join } from 'node:path'
7
7
  import { gitBin } from '../core/git-bin.ts'
8
8
  import { STEP, type Account } from '../identities/identities.ts'
9
9
  import { recordShown, TEXT_FILE } from '../identities/shown.ts'
10
- import { setHeadingText, setPostedLine } from './drafts.ts'
11
- import { accountOf, draftPost, draftsDir, type Desk } from './load.ts'
10
+ import { accountOf, type Desk } from './load.ts'
12
11
  import { setMeta } from './md.ts'
13
12
  import { pushInBackground } from './push.ts'
14
13
 
15
- const SLUG = /^[a-z0-9-]+$/
16
14
  const read = (abs: string): string => readFileSync(abs, 'utf8')
17
15
 
18
16
  /** the hosts a platform also answers on, beside the ones its account.md names */
@@ -70,31 +68,16 @@ export function commitPaths(paths: string[], message: string): void {
70
68
  if (process.env['SHIPKIT_SOCIAL_NO_PUSH'] !== '1') pushInBackground(root)
71
69
  }
72
70
 
73
- /** one heading's text he edited, and its title and tags where given; the heading is the message's `from` */
74
- export function setText(root: string, slug: string, key: string, text: string, title?: string, tags?: string): string[] {
75
- if (!SLUG.test(slug)) throw new Error(`draft ${slug}?`)
76
- const abs = join(draftsDir(root), slug, 'draft.md')
77
- if (!existsSync(abs)) throw new Error(`no drafts/${slug}/draft.md`)
78
- if (text.trim() === '') throw new Error(`## ${key}: an empty text`)
79
- const before = read(abs)
80
- const after = setHeadingText(before, key, text, title, tags)
81
- if (after === before) return []
82
- writeFileSync(abs, after)
83
- commitPaths([abs], `social: ${slug} ## ${key} text edited in the desk`)
84
- return [abs]
71
+ /** one post's words he edited, and its title and tags where given: a new version of the post */
72
+ export function setText(root: string, slug: string, key: string, text: string, title?: string, tags?: string): boolean {
73
+ const { setPostText } = require('./posts.ts') as typeof import('./posts.ts')
74
+ return setPostText(root, slug, key, text, { ...(title !== undefined ? { title } : {}), ...(tags !== undefined ? { tags } : {}), sender: 'owner' })
85
75
  }
86
76
 
87
- /** a post's URL he pasted: its line of `## Posted`; none, the line goes and it waits again */
88
- export function setPosted(desk: Desk, slug: string, key: string, url: string | null): string[] {
89
- const p = draftPost(desk, slug, key)
90
- checkUrl(url, accountOf(desk, p.identity, p.platform))
91
- const abs = join(desk.root, p.file)
92
- const before = read(abs)
93
- const after = setPostedLine(before, key, url)
94
- if (after === before) return []
95
- writeFileSync(abs, after)
96
- commitPaths([abs], `social: ${key}/${slug} ${url == null ? 'is a draft again' : `is posted, ${url}`}`)
97
- return [abs]
77
+ /** a post's URL he pasted, or none: a draft again */
78
+ export function setPosted(desk: Desk, slug: string, key: string, url: string | null): boolean {
79
+ const { setPosted: set } = require('./posts.ts') as typeof import('./posts.ts')
80
+ return set(desk, slug, key, url)
98
81
  }
99
82
 
100
83
  /** the profile URL he pasted, or none: the account is still to create */
@@ -12,6 +12,8 @@ import { loadRepoConfig } from '../repo-config.ts'
12
12
  import type { Subject } from '../review/model.ts'
13
13
  import { notesBy, type SubjectNote } from '../review/notes.ts'
14
14
  import { readAllCached } from '../review/store.ts'
15
+ import { askStepsNow, asksOfRepo, type Ask } from '../asks/ask-store.ts'
16
+ import { hashFor } from '../serve/hub-app/hash-route.ts'
15
17
  import {
16
18
  askSteps,
17
19
  capsuleRows,
@@ -114,8 +116,8 @@ export interface StoreView {
114
116
  page: PageState
115
117
  url: string | null
116
118
  facts: { label: string; value: string; tone: Tone }[]
117
- /** the files to open in the editor: the texts, the ask */
118
- files: { label: string; abs: string }[]
119
+ /** the files to open in the editor (`abs`), and the account ask's thread in the hub (`href`) */
120
+ files: ({ label: string; abs: string } | { label: string; href: string })[]
119
121
  contract: ContractLine[]
120
122
  preamble: string
121
123
  fields: FieldView[]
@@ -290,11 +292,10 @@ async function contract(root: string, store: StoreId): Promise<ContractLine[]> {
290
292
  return lines.length > 0 ? lines : [{ level: 'fail', text: `sk contracts --venue ${store}: ${text.trim() || 'no answer'}` }]
291
293
  }
292
294
 
293
- /** the account's ask by its file name, open, done or declined */
294
- export function askFile(root: string, name: string | undefined): string | null {
295
- if (!name) return null
296
- for (const rel of [`.shipkit/asks/${name}.md`, `.shipkit/asks/done/${name}.md`, `.shipkit/asks/declined/${name}.md`]) if (existsSync(join(root, rel))) return rel
297
- return null
295
+ /** the account's ask by its id, open, done or declined; null when the unit names none or the store holds none */
296
+ export function accountAsk(root: string, id: string | undefined): Ask | null {
297
+ if (!id) return null
298
+ return asksOfRepo(root).find((a) => a.id === id) ?? null
298
299
  }
299
300
 
300
301
  function renderOf(c: Ctx, family: RenderFamily): RenderView | undefined {
@@ -302,14 +303,18 @@ function renderOf(c: Ctx, family: RenderFamily): RenderView | undefined {
302
303
  return r ? { family, cmd: r.cmd.join(' '), about: r.about ?? '', what: RENDER_TARGET[family].what } : undefined
303
304
  }
304
305
 
305
- /** the store's account ask, read when the unit names one: its steps as facts, its answer, its file */
306
+ /** the store's account ask, read when the unit names one: its steps as facts, its answer (the value its steps' first
307
+ * text field holds, an older ask's **Answer** line), the link to its thread */
306
308
  function accountOf(c: Ctx, store: StoreId): { facts: StoreView['facts']; answer: string | null; file: StoreView['files'] } {
307
- const rel = askFile(c.root, partOf(c.unit, store).ask)
308
- const ask = askSteps(rel ? readRel(c.root, rel) : '')
309
+ const a = accountAsk(c.root, partOf(c.unit, store).ask)
310
+ const now = a ? askStepsNow(c.root, a) : null
311
+ const ask: { steps: { title: string; tone: Tone }[]; answer: string | null } = now
312
+ ? { steps: now.steps.map((s) => ({ title: s.title, tone: s.done ? 'done' : 'todo' })), answer: now.values[0] ?? null }
313
+ : askSteps(a?.body ?? '')
309
314
  return {
310
315
  facts: ask.steps.map((s) => ({ label: s.title, value: s.tone === 'done' ? 'done' : s.tone === 'waiting' ? 'waiting' : 'to do', tone: s.tone })),
311
316
  answer: ask.answer,
312
- file: rel ? [{ label: `the ${STORE_NAME[store]} account ask (${ask.status ?? '?'})`, abs: join(c.root, rel) }] : [],
317
+ file: a ? [{ label: `the ${STORE_NAME[store]} account ask (${a.status})`, href: `#${hashFor({ t: 'item', col: 'asks', id: a.address })}` }] : [],
313
318
  }
314
319
  }
315
320
 
@@ -23,7 +23,7 @@ export const RENDER_TARGET: Record<RenderFamily, { store: StoreId; dir: string;
23
23
  export interface StorePart {
24
24
  /** more repo relative text files shown after the store's own, each `## ` section a card */
25
25
  texts?: readonly string[]
26
- /** the account's ask, by its file name in `.shipkit/asks/` (open or done), `.md` left out */
26
+ /** the account's ask, by its id (`sk asks` lists them), open, done or declined */
27
27
  ask?: string
28
28
  }
29
29
 
@@ -43,7 +43,7 @@ export function storesProblem(d: StoresDef): string | null {
43
43
  const p = d[id]
44
44
  if (p === undefined) continue
45
45
  for (const t of p.texts ?? []) if (typeof t !== 'string' || !REL.test(t) || !t.endsWith('.md')) return `stores: ${id}.texts '${String(t)}' is a repo relative .md file`
46
- if (p.ask !== undefined && (typeof p.ask !== 'string' || !/^[\w.-]+$/.test(p.ask))) return `stores: ${id}.ask '${String(p.ask)}' is an ask's file name, .md left out`
46
+ if (p.ask !== undefined && (typeof p.ask !== 'string' || !/^[\w.-]+$/.test(p.ask))) return `stores: ${id}.ask '${String(p.ask)}' is an ask's id (sk asks lists them)`
47
47
  }
48
48
  for (const [f, r] of Object.entries(d.render ?? {})) {
49
49
  if (!(RENDER_FAMILIES as readonly string[]).includes(f)) return `stores: render '${f}' is one of ${RENDER_FAMILIES.join(', ')}`
@@ -64,9 +64,39 @@ export async function elevenSpeak(q: ElevenLine): Promise<{ audio: Uint8Array; c
64
64
  return { audio: new Uint8Array(await r.arrayBuffer()), chars: Number(r.headers.get('character-cost') ?? q.text.length) }
65
65
  }
66
66
 
67
+ /** the house's name of the key, read in the process when no env and no brand argv gives one */
68
+ export const ELEVEN_SECRET = 'rv/elevenlabs/api-key'
69
+
70
+ export type ElevenFetch = (url: string, init: RequestInit) => Promise<Response>
71
+ export type ElevenAccount = { ok: true; used: number; limit: number; resets: Date | null } | { ok: false; status: number; code: string | null; reason: string }
72
+
73
+ /** the account's characters this period, or the API's refusal in its own words: one free GET, no voice spent.
74
+ * The key needs the « User: Access » permission (user_read), else the refusal names it */
75
+ export async function elevenAccount(key: string, fetcher: ElevenFetch = (u, i) => call(u, i, 'subscription')): Promise<ElevenAccount> {
76
+ const r = await fetcher(`${API}/v1/user/subscription`, { headers: { 'xi-api-key': key } })
77
+ const text = await r.text()
78
+ if (!r.ok) {
79
+ let detail: { status?: string; message?: string } | undefined
80
+ try {
81
+ detail = (JSON.parse(text) as { detail?: { status?: string; message?: string } }).detail
82
+ } catch {}
83
+ const reason = (detail?.message ?? (text.trim() || r.statusText)).replaceAll(key, '••••').slice(0, 300)
84
+ return { ok: false, status: r.status, code: detail?.status ?? null, reason }
85
+ }
86
+ const d = JSON.parse(text) as { character_count: number; character_limit: number; next_character_count_reset_unix?: number | null }
87
+ return { ok: true, used: d.character_count, limit: d.character_limit, resets: d.next_character_count_reset_unix ? new Date(d.next_character_count_reset_unix * 1000) : null }
88
+ }
89
+
90
+ /** the one line `sk sound credits` and the probe print */
91
+ export function creditsLine(a: ElevenAccount): string {
92
+ if (!a.ok) return `ElevenLabs refused (${a.status}${a.code ? ` ${a.code}` : ''}): ${a.reason}`
93
+ const n = (x: number): string => x.toLocaleString('en')
94
+ return `ElevenLabs: ${n(a.limit - a.used)} of ${n(a.limit)} characters left this period, resets ${a.resets ? a.resets.toISOString().slice(0, 10) : 'on a date the API did not give'}`
95
+ }
96
+
67
97
  /** the characters used and allowed this billing period */
68
98
  export async function elevenCredits(key: string): Promise<{ used: number; limit: number }> {
69
- const r = await ok(await call(`${API}/v1/user/subscription`, { headers: { 'xi-api-key': key } }, 'subscription'), 'subscription')
70
- const d = (await r.json()) as { character_count: number; character_limit: number }
71
- return { used: d.character_count, limit: d.character_limit }
99
+ const a = await elevenAccount(key)
100
+ if (!a.ok) throw new Error(creditsLine(a))
101
+ return { used: a.used, limit: a.limit }
72
102
  }
package/src/urls/rows.ts CHANGED
@@ -134,7 +134,7 @@ export class UrlsRefusal extends Error {
134
134
  }
135
135
  }
136
136
 
137
- type Reader = (template: string, name: string, field: 'get' | 'account', cwd: string) => string | Promise<string>
137
+ type Reader = (template: string | null, name: string, field: 'get' | 'account', cwd: string) => string | Promise<string>
138
138
 
139
139
  /** one field of one declared login, read as the repo at `root`. The caller names a url and a login by position, never
140
140
  * a secret: only what the repo declares can be read through here */
@@ -4,10 +4,11 @@ import { refuseRealVault } from './vault-config.ts'
4
4
  export type VaultHealth = { code: number; initialized: boolean; sealed: boolean; version: string }
5
5
 
6
6
  /** GET /v1/sys/health: 200 unsealed, 503 sealed, 501 not initialised. Null when nothing answers */
7
- export async function vaultHealth(url: string, timeoutMs = 1_000): Promise<VaultHealth | null> {
7
+ /** `headers`: what a vault behind the hq's vault route also wants (the node's hq token) */
8
+ export async function vaultHealth(url: string, timeoutMs = 1_000, headers: Record<string, string> = {}): Promise<VaultHealth | null> {
8
9
  refuseRealVault({ url })
9
10
  try {
10
- const r = await fetch(`${url}/v1/sys/health`, { signal: AbortSignal.timeout(timeoutMs) })
11
+ const r = await fetch(`${url}/v1/sys/health`, { headers, signal: AbortSignal.timeout(timeoutMs) })
11
12
  const j = (await r.json().catch(() => ({}))) as { initialized?: boolean; sealed?: boolean; version?: string }
12
13
  return { code: r.status, initialized: j.initialized === true, sealed: j.sealed !== false, version: j.version ?? '' }
13
14
  } catch {
@@ -43,11 +44,13 @@ export class VaultApi {
43
44
  private token: string | null = null,
44
45
  /** how long one call may take; a read on a reader's path passes a short one */
45
46
  private readonly timeoutMs: number = 30_000,
47
+ /** sent with every call: the hq token of a node that reads the master through the vault route */
48
+ private readonly headers: Record<string, string> = {},
46
49
  ) {}
47
50
 
48
51
  private async call(method: string, path: string, body?: unknown, raw?: Uint8Array<ArrayBuffer>): Promise<{ status: number; json: Json; bytes: Uint8Array<ArrayBuffer> }> {
49
52
  refuseRealVault({ url: this.url })
50
- const headers: Record<string, string> = {}
53
+ const headers: Record<string, string> = { ...this.headers }
51
54
  if (this.token != null) headers['X-Vault-Token'] = this.token
52
55
  if (body !== undefined) headers['content-type'] = 'application/json'
53
56
  const r = await fetch(`${this.url}/v1/${path}`, { method, headers, body: raw ?? (body === undefined ? undefined : JSON.stringify(body)), signal: AbortSignal.timeout(this.timeoutMs) })
@@ -305,6 +308,11 @@ export class VaultApi {
305
308
  await this.call('DELETE', `${mount}/data/${path}`)
306
309
  }
307
310
 
311
+ /** kv v2's undelete: these soft deleted versions read again */
312
+ async undeleteKv(mount: string, path: string, versions: number[]): Promise<void> {
313
+ await this.call('POST', `${mount}/undelete/${path}`, { versions })
314
+ }
315
+
308
316
  async readKv(mount: string, path: string): Promise<Json | null> {
309
317
  try {
310
318
  const { json } = await this.call('GET', `${mount}/data/${path}`)
@@ -13,7 +13,7 @@ import { vaultPathOf } from './vault-client.ts'
13
13
  import { VaultApi } from './vault-http.ts'
14
14
  import { mintNode, setNodeSlots } from './vault-minter.ts'
15
15
 
16
- export type RegistryRow = { name: string; for?: Scope }
16
+ export type RegistryRow = { name: string; for?: Scope; archived?: { at: string } }
17
17
 
18
18
  /** where one name of this machine's keychain goes: its path, or why it has none */
19
19
  export type Placed = { name: string; scope: string; path?: string; why?: string }
@@ -39,6 +39,11 @@ export async function placeNames(o: { rows: RegistryRow[]; held: string[]; keyOf
39
39
  continue
40
40
  }
41
41
  const scope = scopeText(row.for)
42
+ // a copy into the vault would undo the archive (sk secret archive)
43
+ if (row.archived != null) {
44
+ out.push({ name, scope, why: `archived on ${row.archived.at}: not imported` })
45
+ continue
46
+ }
42
47
  if (scopeRefs(row.for).length > 1) {
43
48
  out.push({ name, scope, why: 'filed under several scopes: the vault carries one scope a secret' })
44
49
  continue
@@ -1,6 +1,6 @@
1
1
  import { existsSync, readFileSync } from 'node:fs'
2
2
  import { join } from 'node:path'
3
- import { LAYOUT } from '../core/layout.ts'
3
+ import { HOUSE_LAYOUT } from '../core/house-layout.ts'
4
4
  import { houseRootOf } from '../home/home-start.ts'
5
5
  import { homeDir } from '../home/home-paths.ts'
6
6
  import { type Identity, speakerOf } from '../identities/identities.ts'
@@ -28,7 +28,7 @@ export const identitiesRoot = (cwd = process.cwd()): string | null => {
28
28
  const env = process.env.SHIPKIT_IDENTITIES_DIR
29
29
  if (env) return env
30
30
  const house = houseRootOf(cwd)
31
- return house == null ? null : join(house, LAYOUT.identities)
31
+ return house == null ? null : join(house, HOUSE_LAYOUT.identities)
32
32
  }
33
33
 
34
34
  /** an identity's log folder in shipkit's home */
@@ -4,7 +4,7 @@
4
4
  // open them. Only a node of the graph is ever read: a client names a node id,
5
5
  // never a path.
6
6
  import { existsSync, readFileSync, statSync } from 'fs'
7
- import { join } from 'path'
7
+ import { extname, join, relative, resolve } from 'path'
8
8
  import type { MdGraph, MdNode } from 'rvlib-shipkit/src/wiki/md-graph.ts'
9
9
 
10
10
  export type WikiHit = { id: string; label: string; title: string; snippet: string; inTitle: boolean }
@@ -126,3 +126,15 @@ export function pageOf(g: MdGraph, dir: string, asked: string): WikiPage | null
126
126
  }
127
127
  return { id, title: titleOf(md, g.nodes.find((n) => n.id === id)!), md, links, file }
128
128
  }
129
+
130
+ const IMAGE_TYPES: Record<string, string> = { '.svg': 'image/svg+xml', '.png': 'image/png', '.webp': 'image/webp', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.gif': 'image/gif' }
131
+
132
+ /** a picture of the wiki, by its path from the wiki's folder: its file and type; null for a path that leaves the
133
+ * folder, a type that is no picture, or no file (a generated page's icons, /graph/<id>/image) */
134
+ export function imageOf(dir: string, rel: string): { file: string; type: string } | null {
135
+ const file = resolve(dir, rel)
136
+ const inside = relative(resolve(dir), file)
137
+ const type = IMAGE_TYPES[extname(file).toLowerCase()]
138
+ if (rel === '' || inside.startsWith('..') || inside === '' || type === undefined || !existsSync(file) || !statSync(file).isFile()) return null
139
+ return { file, type }
140
+ }
@@ -91,7 +91,7 @@ function scanMdNow(cfg: ScanMdConfig): MdScan {
91
91
  if (st == null) continue // a link to nothing (a deploy stage's gone target)
92
92
  if (st.isDirectory()) {
93
93
  if (!skip.has(e) && !e.startsWith('.') && !vendored.has(join(cfg.root, r))) walk(r)
94
- } else if (e.endsWith('.md')) files.push(r)
94
+ } else if (e.endsWith('.md') && !e.endsWith('.local.md')) files.push(r) // a `*.local.md` holds private rows, never a graph's
95
95
  }
96
96
  }
97
97
  walk('')