rvlib-shipkit 2.12.0 → 2.13.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 (290) hide show
  1. package/CHANGELOG.md +48 -13
  2. package/README.md +1 -1
  3. package/package.json +4 -2
  4. package/src/agent-time/store.ts +2 -2
  5. package/src/check.ts +1 -1
  6. package/src/checks/SK001-package-json-shape.check.ts +4 -0
  7. package/src/checks/SK003-claude-md-shape.check.ts +1 -1
  8. package/src/checks/SK004-gitignore-policy.check.ts +27 -2
  9. package/src/checks/SK005-rvlib-versions.check.ts +1 -1
  10. package/src/checks/SK008-reviewer-agent.check.ts +2 -2
  11. package/src/checks/SK012-config-barrel-import.check.ts +1 -1
  12. package/src/checks/SK015-nested-repo.check.ts +1 -1
  13. package/src/checks/SK035-public-clean.check.ts +46 -0
  14. package/src/checks/SK036-draft-media-size.check.ts +28 -0
  15. package/src/cli/cmd_Backup.ts +152 -0
  16. package/src/cli/cmd_Ci.ts +8 -11
  17. package/src/cli/cmd_Drill.ts +145 -0
  18. package/src/cli/cmd_Home.ts +50 -3
  19. package/src/cli/cmd_Media.ts +7 -5
  20. package/src/cli/cmd_Review.ts +4 -2
  21. package/src/cli/cmd_Shot.ts +5 -2
  22. package/src/cli/cmd_Smoke.ts +4 -1
  23. package/src/cli/cmd_Social.ts +226 -0
  24. package/src/cli/cmd_Start.ts +1 -1
  25. package/src/cli/cmd_Time.ts +1 -1
  26. package/src/cli/cmd_Trailer.ts +5 -2
  27. package/src/cli/cmd_Veille.ts +173 -0
  28. package/src/cli/family-pages.ts +3 -0
  29. package/src/cli/registry.ts +13 -2
  30. package/src/cli.ts +5 -2
  31. package/src/collections/actions.ts +1 -49
  32. package/src/collections/checks.ts +2 -1
  33. package/src/collections/collection-types.ts +11 -2
  34. package/src/collections/providers.ts +4 -4
  35. package/src/collections/review.ts +2 -1
  36. package/src/collections/tests.ts +19 -8
  37. package/src/contracts/apply-contracts.ts +1 -3
  38. package/src/contracts/contract-manifests.ts +2 -3
  39. package/src/contracts/contract-types.ts +0 -1
  40. package/src/contracts/contracts-engine.ts +0 -3
  41. package/src/core/app-icon.ts +9 -3
  42. package/src/core/bun-builtins.ts +2 -2
  43. package/src/core/discover-checks.ts +37 -5
  44. package/src/core/fix-scope.ts +4 -2
  45. package/src/core/floor-resolve.ts +68 -48
  46. package/src/core/floor.ts +9 -0
  47. package/src/core/git-root.ts +24 -0
  48. package/src/core/last-good.ts +3 -1
  49. package/src/core/layout.ts +8 -0
  50. package/src/core/log-stamp.ts +36 -0
  51. package/src/core/loop-watch.ts +93 -0
  52. package/src/core/machine-link.ts +134 -0
  53. package/src/core/memory-watch.ts +41 -0
  54. package/src/core/one-way-in-policy.ts +27 -19
  55. package/src/core/run-ci.ts +6 -8
  56. package/src/core/run-fixers.ts +9 -9
  57. package/src/core/slots.ts +21 -0
  58. package/src/core/tree-rev.ts +60 -0
  59. package/src/core/unit-files.ts +42 -0
  60. package/src/drill/render.ts +140 -0
  61. package/src/drill/run.ts +269 -0
  62. package/src/fleet/scan-fleet.ts +6 -5
  63. package/src/home/daemon-jobs.ts +201 -0
  64. package/src/home/global-context.ts +34 -1
  65. package/src/home/home-routes.ts +22 -15
  66. package/src/home/hubs.ts +10 -3
  67. package/src/home/inbox-shape.ts +53 -4
  68. package/src/home/inbox.ts +16 -1
  69. package/src/home/lib-watch.ts +10 -3
  70. package/src/home/machine-stores.ts +15 -29
  71. package/src/home/run-daemon.ts +15 -18
  72. package/src/home/run-pm.ts +2 -0
  73. package/src/home/serve-daemon.ts +4 -3
  74. package/src/home/serve-web.ts +104 -1
  75. package/src/hooks/commit-message.ts +28 -19
  76. package/src/hooks/leak-guard.ts +10 -3
  77. package/src/hooks/run-hooks.ts +2 -6
  78. package/src/identities/identities.ts +334 -0
  79. package/src/identities/machine-route.ts +126 -0
  80. package/src/identities/machine.ts +62 -0
  81. package/src/init-repo.ts +1 -1
  82. package/src/ledger/check-stats.ts +10 -9
  83. package/src/ledger/gate-checks.ts +32 -1
  84. package/src/ledger/record-kept.ts +112 -0
  85. package/src/ledger/repo-view.ts +10 -0
  86. package/src/ledger/run-log.ts +17 -12
  87. package/src/ledger/run-timeline.ts +8 -4
  88. package/src/ledger/store.ts +7 -0
  89. package/src/ledger/suite-log.ts +17 -13
  90. package/src/media-kinds.ts +2 -1
  91. package/src/media-store/backup/daemon.ts +73 -0
  92. package/src/media-store/backup/keys.ts +25 -0
  93. package/src/media-store/backup/manifest.ts +193 -0
  94. package/src/media-store/backup/restore.ts +192 -0
  95. package/src/media-store/backup/run.ts +278 -0
  96. package/src/media-store/backup/secret.ts +86 -0
  97. package/src/media-store/backup/snapshot.ts +64 -0
  98. package/src/media-store/backup/sources.ts +199 -0
  99. package/src/media-store/daemon.ts +56 -70
  100. package/src/media-store/put.ts +4 -2
  101. package/src/media-store/space.ts +23 -4
  102. package/src/pages/forward.ts +35 -0
  103. package/src/pages/frame-client.ts +118 -0
  104. package/src/pages/routes.ts +29 -0
  105. package/src/pages/unit.ts +92 -0
  106. package/src/plan/planner.ts +12 -0
  107. package/src/plan/repo-source.ts +19 -5
  108. package/src/reflect/transcript.ts +35 -10
  109. package/src/release/public-clean.ts +301 -0
  110. package/src/release/published-here.ts +22 -0
  111. package/src/release/run-bump.ts +2 -1
  112. package/src/release/run-release.ts +4 -1
  113. package/src/repo-config.ts +53 -2
  114. package/src/review/http.ts +16 -2
  115. package/src/review/model.ts +15 -4
  116. package/src/review/notes.ts +77 -0
  117. package/src/review/project.ts +6 -38
  118. package/src/review/routes.ts +4 -12
  119. package/src/review/store.ts +41 -1
  120. package/src/review/trailer-media.ts +7 -4
  121. package/src/review/trailer-shots.ts +21 -4
  122. package/src/review/unit.ts +1 -1
  123. package/src/scaffold/files/agent-handoff.md +3 -0
  124. package/src/scaffold/files/agent-index.md +4 -12
  125. package/src/scaffold/project-scaffold.ts +5 -4
  126. package/src/serve/embed.ts +1 -1
  127. package/src/serve/hub-app/col-card.tsx +3 -17
  128. package/src/serve/hub-app/col-tables-view.tsx +2 -1
  129. package/src/serve/hub-app/cols-svc.ts +0 -13
  130. package/src/serve/hub-app/dock-st.ts +4 -2
  131. package/src/serve/hub-app/dock-view.tsx +2 -0
  132. package/src/serve/hub-app/frames-st.ts +35 -0
  133. package/src/serve/hub-app/hash-route.ts +64 -1
  134. package/src/serve/hub-app/home-st.ts +31 -7
  135. package/src/serve/hub-app/home-strip.css +9 -1
  136. package/src/serve/hub-app/home-strip.tsx +7 -6
  137. package/src/serve/hub-app/home.html +5 -0
  138. package/src/serve/hub-app/hub-app.tsx +49 -5
  139. package/src/serve/hub-app/hub.css +29 -11
  140. package/src/serve/hub-app/icons.tsx +16 -1
  141. package/src/serve/hub-app/identities-st.ts +210 -0
  142. package/src/serve/hub-app/identities-view.tsx +352 -0
  143. package/src/serve/hub-app/identities.css +48 -0
  144. package/src/serve/hub-app/identity-address.ts +52 -0
  145. package/src/serve/hub-app/inbox-st.ts +59 -6
  146. package/src/serve/hub-app/inbox-view.tsx +48 -6
  147. package/src/serve/hub-app/inbox.css +12 -1
  148. package/src/serve/hub-app/index.html +3 -0
  149. package/src/serve/hub-app/keys.ts +10 -2
  150. package/src/serve/hub-app/list-walk.ts +89 -0
  151. package/src/serve/hub-app/machine-st.ts +12 -0
  152. package/src/serve/hub-app/media-view.tsx +2 -1
  153. package/src/serve/hub-app/pages-frames.tsx +134 -0
  154. package/src/serve/hub-app/pages-svc.ts +111 -0
  155. package/src/serve/hub-app/palette-st.ts +18 -3
  156. package/src/serve/hub-app/palette-view.tsx +9 -2
  157. package/src/serve/hub-app/planned-view.tsx +2 -1
  158. package/src/serve/hub-app/project-list.css +18 -14
  159. package/src/serve/hub-app/project-list.tsx +88 -49
  160. package/src/serve/hub-app/projects-svc.ts +33 -3
  161. package/src/serve/hub-app/repo-sections.ts +19 -2
  162. package/src/serve/hub-app/repo-st.ts +75 -19
  163. package/src/serve/hub-app/review/review-cells.tsx +3 -3
  164. package/src/serve/hub-app/review/review-kit.ts +30 -7
  165. package/src/serve/hub-app/review/review-page.tsx +1 -1
  166. package/src/serve/hub-app/review/review-st.ts +19 -8
  167. package/src/serve/hub-app/review/review-thread.tsx +11 -9
  168. package/src/serve/hub-app/review/review-views.tsx +84 -19
  169. package/src/serve/hub-app/review/thread-st.ts +1 -10
  170. package/src/serve/hub-app/review/trailer-page.tsx +2 -1
  171. package/src/serve/hub-app/review.css +17 -8
  172. package/src/serve/hub-app/site/site-part.tsx +173 -0
  173. package/src/serve/hub-app/site/site-st.ts +157 -0
  174. package/src/serve/hub-app/site.css +35 -0
  175. package/src/serve/hub-app/social/calendar.tsx +182 -0
  176. package/src/serve/hub-app/social/comms-page.tsx +306 -0
  177. package/src/serve/hub-app/social/kit.tsx +244 -0
  178. package/src/serve/hub-app/social/post-card.tsx +456 -0
  179. package/src/serve/hub-app/social/problems.tsx +60 -0
  180. package/src/serve/hub-app/social/social-model.ts +154 -0
  181. package/src/serve/hub-app/social/social-page.tsx +674 -0
  182. package/src/serve/hub-app/social/social-st.ts +986 -0
  183. package/src/serve/hub-app/social.css +289 -0
  184. package/src/serve/hub-app/stores/stores-page.tsx +311 -0
  185. package/src/serve/hub-app/stores/stores-st.ts +286 -0
  186. package/src/serve/hub-app/stores.css +54 -0
  187. package/src/serve/hub-app/timeline-geometry.ts +1 -1
  188. package/src/serve/hub-app/timeline-view.tsx +3 -2
  189. package/src/serve/hub-app/tree-build.ts +6 -0
  190. package/src/serve/hub-app/tree-row.tsx +27 -4
  191. package/src/serve/hub-app/tree-svc.ts +18 -49
  192. package/src/serve/hub-app/veille/veille-page.tsx +514 -0
  193. package/src/serve/hub-app/veille/veille-st.ts +443 -0
  194. package/src/serve/hub-app/veille.css +84 -0
  195. package/src/serve/hub-runtime.ts +14 -9
  196. package/src/serve/project-gutter-route.ts +44 -12
  197. package/src/serve/run-lanes.ts +7 -4
  198. package/src/serve/same-origin.ts +1 -1
  199. package/src/serve/serve-hub.ts +20 -12
  200. package/src/serve/tracked-watch.ts +24 -3
  201. package/src/serve/warm-cell.ts +5 -1
  202. package/src/shipkit-files.ts +15 -4
  203. package/src/shipkit.ts +0 -1
  204. package/src/shot/box.ts +162 -0
  205. package/src/shot/browser-slot.ts +62 -0
  206. package/src/shot/client.ts +43 -7
  207. package/src/shot/clip-encoder.ts +93 -12
  208. package/src/shot/film-box.ts +188 -0
  209. package/src/shot/shooter.ts +50 -15
  210. package/src/shot/shot-ask.ts +10 -2
  211. package/src/shot/stepped-clip.ts +5 -4
  212. package/src/site/desk.ts +242 -0
  213. package/src/site/routes.ts +66 -0
  214. package/src/site/unit.ts +62 -0
  215. package/src/social/brands.ts +22 -0
  216. package/src/social/compose.ts +97 -0
  217. package/src/social/desk-index.ts +123 -0
  218. package/src/social/desk-wire.ts +64 -0
  219. package/src/social/drafts.ts +183 -0
  220. package/src/social/house.ts +24 -0
  221. package/src/social/load.ts +319 -0
  222. package/src/social/md.ts +70 -0
  223. package/src/social/media-facts.ts +53 -0
  224. package/src/social/media-kind.ts +189 -0
  225. package/src/social/media-limit.ts +42 -0
  226. package/src/social/media-of.ts +30 -0
  227. package/src/social/migrate.ts +123 -0
  228. package/src/social/open.ts +17 -0
  229. package/src/social/post-url.ts +158 -0
  230. package/src/social/presence.ts +332 -0
  231. package/src/social/public-read.ts +53 -0
  232. package/src/social/publish/bluesky.ts +168 -0
  233. package/src/social/publish/discord.ts +76 -0
  234. package/src/social/publish/index.ts +24 -0
  235. package/src/social/publish/secret.ts +13 -0
  236. package/src/social/push.ts +31 -0
  237. package/src/social/richtext.ts +37 -0
  238. package/src/social/routes.ts +180 -0
  239. package/src/social/stats.ts +134 -0
  240. package/src/social/text.ts +267 -0
  241. package/src/social/tracker-route.ts +39 -0
  242. package/src/social/tracker.ts +255 -0
  243. package/src/social/unit.ts +53 -0
  244. package/src/social/writes.ts +130 -0
  245. package/src/start-repo.ts +14 -9
  246. package/src/stores/collection.ts +27 -0
  247. package/src/stores/desk.ts +336 -0
  248. package/src/stores/model.ts +187 -0
  249. package/src/stores/routes.ts +126 -0
  250. package/src/stores/unit.ts +57 -0
  251. package/src/suite/calibrate.ts +127 -0
  252. package/src/suite/core-counters.ts +91 -0
  253. package/src/suite/judge-suites.ts +94 -34
  254. package/src/suite/suite-cli.ts +44 -10
  255. package/src/suite/suite-cpu-preload.ts +34 -9
  256. package/src/trailer/adapter.ts +4 -0
  257. package/src/trailer/build.ts +42 -11
  258. package/src/trailer/ffmpeg.ts +11 -0
  259. package/src/trailer/footage.ts +30 -13
  260. package/src/trailer/grammar.ts +18 -2
  261. package/src/trailer/graph.ts +28 -6
  262. package/src/trailer/passage.ts +17 -5
  263. package/src/trailer/plan.ts +74 -3
  264. package/src/trailer/stitch.ts +67 -26
  265. package/src/trailer/url.ts +1 -1
  266. package/src/trailer/versions.ts +24 -0
  267. package/src/ts/gate-typecheck.ts +32 -0
  268. package/src/ts/typecheck-cli.ts +9 -11
  269. package/src/tui/tui-app.tsx +0 -1
  270. package/src/veille/asks.ts +155 -0
  271. package/src/veille/auto.ts +31 -0
  272. package/src/veille/batch.ts +27 -0
  273. package/src/veille/chrome.ts +127 -0
  274. package/src/veille/collection.ts +28 -0
  275. package/src/veille/desk.ts +242 -0
  276. package/src/veille/identity.ts +80 -0
  277. package/src/veille/import.ts +68 -0
  278. package/src/veille/log.ts +183 -0
  279. package/src/veille/platforms.ts +118 -0
  280. package/src/veille/reads.ts +66 -0
  281. package/src/veille/replied.ts +110 -0
  282. package/src/veille/routes.ts +185 -0
  283. package/src/veille/service.ts +81 -0
  284. package/src/veille/watch.ts +116 -0
  285. package/src/veille/worth.ts +46 -0
  286. package/src/wiki/scan-md.ts +18 -0
  287. package/src/collections/posts.ts +0 -142
  288. package/src/contracts/manifests/social.contract.ts +0 -20
  289. package/src/scaffold/files/agent-coding.md +0 -35
  290. package/src/ts/typecheck-cache.ts +0 -11
@@ -0,0 +1,157 @@
1
+ // an identity's site desk as state (wiki build/shipkit/site.md, The section): its answer read from the home daemon,
2
+ // the page picked and the width of its preview (kept in the browser), the preview started when down, the deploy he
3
+ // presses with its log as it streams. Read when the section opens, when the window comes back, and after a deploy
4
+ import { makeAutoObservable, observableRef, runInAction } from 'mobx'
5
+ import type { SiteAnswer, SitePage } from '../../../site/desk.ts'
6
+ import type { HomeSt } from '../home-st.ts'
7
+ import { reach } from '../reach.ts'
8
+ import { postJson } from '../review/review-kit.ts'
9
+
10
+ export type { SiteAnswer, SitePage }
11
+
12
+ const KEPT = 'hub:site:'
13
+ const ADDRESS_LEFT = /^https?:\/\/(www\.)?/
14
+
15
+ export class SiteSt {
16
+ answer: SiteAnswer | null = null
17
+ loadError: string | null = null
18
+ /** the page picked, by its path; null the first */
19
+ page: string | null = null
20
+ phone = false
21
+ starting = false
22
+ previewError: string | null = null
23
+ /** the deploy's log as it streams; null before any */
24
+ log: string | null = null
25
+ deploying = false
26
+ private started = 0
27
+
28
+ constructor(readonly id: string) {
29
+ try {
30
+ const k = JSON.parse(localStorage.getItem(KEPT + id) ?? '{}') as { page?: string; phone?: boolean }
31
+ this.page = k.page ?? null
32
+ this.phone = k.phone === true
33
+ } catch {
34
+ // no storage, or a broken entry: the first page at the desktop's width
35
+ }
36
+ makeAutoObservable<this, 'started' | 'onBack'>(this, { id: false, started: false, onBack: false, answer: observableRef })
37
+ }
38
+
39
+ get pages(): SitePage[] {
40
+ return this.answer?.desk?.pages ?? []
41
+ }
42
+
43
+ get current(): SitePage | null {
44
+ return this.pages.find((p) => p.path === this.page) ?? this.pages[0] ?? null
45
+ }
46
+
47
+ /** the frame's address: the preview's url and the page's path; null while the preview does not answer */
48
+ get src(): string | null {
49
+ const p = this.answer?.desk?.preview
50
+ return p?.up && this.current ? `${p.url.replace(/\/$/, '')}${this.current.path}` : null
51
+ }
52
+
53
+ get shortAddress(): string {
54
+ return (this.answer?.address ?? '').replace(ADDRESS_LEFT, '').replace(/\/$/, '')
55
+ }
56
+
57
+ /** a page touched since the deploy: by its own files, or by a file every page reads */
58
+ changed(p: SitePage): boolean {
59
+ return (this.answer?.desk?.changes ?? []).some((c) => c.path === p.path || c.path === '*')
60
+ }
61
+
62
+ private keep(): void {
63
+ try {
64
+ localStorage.setItem(KEPT + this.id, JSON.stringify({ page: this.page, phone: this.phone }))
65
+ } catch {
66
+ // no storage: the pick lasts for this page
67
+ }
68
+ }
69
+
70
+ pick(path: string): void {
71
+ this.page = path
72
+ this.keep()
73
+ }
74
+
75
+ move(delta: number): void {
76
+ const i = Math.max(0, this.pages.findIndex((p) => p.path === this.current?.path))
77
+ const next = this.pages[Math.max(0, Math.min(this.pages.length - 1, i + delta))]
78
+ if (next) this.pick(next.path)
79
+ }
80
+
81
+ setPhone(on: boolean): void {
82
+ this.phone = on
83
+ this.keep()
84
+ }
85
+
86
+ /** the section shows: read it, start the preview when down, and read again when the window comes back */
87
+ start(): void {
88
+ if (this.started++ === 0) window.addEventListener('focus', this.onBack)
89
+ void this.open()
90
+ }
91
+
92
+ stop(): void {
93
+ if (--this.started === 0) window.removeEventListener('focus', this.onBack)
94
+ }
95
+
96
+ private readonly onBack = (): void => void this.load()
97
+
98
+ async load(): Promise<void> {
99
+ try {
100
+ const r = await reach(`/api/home/sites/${encodeURIComponent(this.id)}`, { cache: 'no-store' })
101
+ const body = (await r.json()) as SiteAnswer & { error?: string }
102
+ if (!r.ok) throw new Error(body.error ?? `HTTP ${r.status}`)
103
+ runInAction(() => {
104
+ this.answer = body
105
+ this.loadError = null
106
+ })
107
+ } catch (e) {
108
+ runInAction(() => (this.loadError = (e as Error).message))
109
+ }
110
+ }
111
+
112
+ private async open(): Promise<void> {
113
+ await this.load()
114
+ const p = this.answer?.desk?.preview
115
+ if (p == null || p.up || this.starting) return
116
+ this.starting = true
117
+ try {
118
+ await postJson(`/api/home/sites/${encodeURIComponent(this.id)}/preview`, {})
119
+ runInAction(() => (this.previewError = null))
120
+ await this.load()
121
+ } catch (e) {
122
+ runInAction(() => (this.previewError = (e as Error).message))
123
+ } finally {
124
+ runInAction(() => (this.starting = false))
125
+ }
126
+ }
127
+
128
+ /** the unit's deploy, asked first, its log read as it streams */
129
+ async deploy(): Promise<void> {
130
+ const about = this.answer?.desk?.deploy?.about
131
+ if (this.deploying || !confirm(`Deploy the site online (${this.shortAddress})${about ? `, ${about}` : ''}?`)) return
132
+ this.deploying = true
133
+ this.log = ''
134
+ try {
135
+ const r = await reach(`/api/home/sites/${encodeURIComponent(this.id)}/deploy`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' })
136
+ if (!r.ok || r.body == null) throw new Error(((await r.json().catch(() => ({}))) as { error?: string }).error ?? `HTTP ${r.status}`)
137
+ const dec = new TextDecoder()
138
+ for await (const chunk of r.body) runInAction(() => (this.log += dec.decode(chunk as Uint8Array, { stream: true })))
139
+ } catch (e) {
140
+ runInAction(() => (this.log += `\n${(e as Error).message}\n`))
141
+ } finally {
142
+ runInAction(() => (this.deploying = false))
143
+ void this.load()
144
+ }
145
+ }
146
+ }
147
+
148
+ const kept = new WeakMap<HomeSt, Map<string, SiteSt>>()
149
+
150
+ /** the desk of an identity's site, one per identity for the life of the page */
151
+ export function siteStOf(app: HomeSt, id: string): SiteSt {
152
+ let m = kept.get(app)
153
+ if (m == null) kept.set(app, (m = new Map()))
154
+ let s = m.get(id)
155
+ if (s == null) m.set(id, (s = new SiteSt(id)))
156
+ return s
157
+ }
@@ -0,0 +1,35 @@
1
+ /* an identity's site section (site/site-part.tsx): the facts on top, then three columns, the pages, the preview
2
+ framed at the desktop's width or a phone's, the state with the deploy; the columns fill the panel's height */
3
+ .idpage.site{height:100%;gap:0}
4
+ .site-online{margin-left:var(--s2);font-size:11.5px;color:var(--red)}
5
+ .site-online.up{color:var(--ok)}
6
+ .site-missing{padding:var(--s2) var(--s3);border-radius:6px;background:var(--panel2);font-size:12.5px;color:var(--dim)}
7
+ .site-desk{flex:1;min-height:420px;display:grid;grid-template-columns:minmax(170px,220px) 1fr minmax(200px,260px);border-top:1px solid var(--line)}
8
+ .site-pages{display:flex;flex-direction:column;gap:var(--s0);padding:var(--s2);overflow-y:auto;border-right:1px solid var(--line);outline:none}
9
+ .site-page{display:flex;align-items:center;gap:var(--s2);padding:var(--s1) var(--s2);border:0;border-radius:6px;background:none;color:var(--ink);text-align:left;cursor:pointer;min-width:0}
10
+ .site-page.sub{padding-left:var(--s4)}
11
+ .site-page:hover{background:var(--panel2)}
12
+ .site-page.on{background:var(--sel);box-shadow:inset 3px 0 0 var(--idc,var(--accent))}
13
+ .site-ptext{display:flex;flex-direction:column;min-width:0}
14
+ .site-ptext b{font-size:12.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
15
+ .site-page.sub .site-ptext b{font-weight:500}
16
+ .site-ptext .iddim{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
17
+ .site-dot{flex:none;width:7px;height:7px;border-radius:50%}
18
+ .site-dot.changed{background:var(--warn)}
19
+ .site-preview{display:flex;flex-direction:column;min-width:0;min-height:0;background:var(--panel2)}
20
+ .site-bar{display:flex;align-items:center;gap:var(--s2);padding:var(--s1) var(--s2);border-bottom:1px solid var(--line);font-size:12.5px}
21
+ .site-bar b{flex:1;min-width:0}
22
+ .site-switch{display:flex;gap:2px}
23
+ .site-switch button{font-size:11.5px;padding:var(--s0) var(--s2)}
24
+ .site-switch button.on{background:var(--sel);color:var(--ink)}
25
+ .site-open{font-size:12px;color:var(--accent);text-decoration:none}
26
+ .site-frame{flex:1;min-height:0;display:flex;justify-content:center}
27
+ .site-frame iframe{flex:1;border:0;width:100%;height:100%}
28
+ .site-frame.phone{padding:var(--s2)}
29
+ .site-frame.phone iframe{flex:none;width:390px;border-radius:12px;box-shadow:0 4px 24px var(--shadow)}
30
+ .site-state{display:flex;flex-direction:column;gap:var(--s3);padding:var(--s3);overflow-y:auto;border-left:1px solid var(--line);font-size:12.5px}
31
+ .site-state section{display:flex;flex-direction:column;gap:var(--s1)}
32
+ .site-state a{color:var(--accent);text-decoration:none}
33
+ .site-h{font-size:11px;text-transform:uppercase;letter-spacing:.04em;color:var(--dim)}
34
+ .site-deploy{align-self:flex-start;padding:var(--s1) var(--s3);font-weight:600}
35
+ .site-log{margin:0;max-height:360px;overflow:auto;font-size:11px;white-space:pre-wrap;background:var(--panel2);padding:var(--s2);border-radius:6px}
@@ -0,0 +1,182 @@
1
+ // the calendar over Communications (wiki build/shipkit/social.md, The desks in the hub): four weeks, a row an account,
2
+ // a dot a post coloured by its draft's kind, a hollow dot a slotted draft still to post; the slots, the topics, the
3
+ // week ahead. Drawn from the timeline the desk route sends for the identity the list keeps (social/presence.ts)
4
+ import { observer } from 'mobx-react-lite'
5
+ import type { CSSProperties } from 'react'
6
+ import { Fold, Logo } from './kit.tsx'
7
+ import { FAM_LABEL, kindTone, type Timeline } from './social-model.ts'
8
+ import type { SocialSt } from './social-st.ts'
9
+
10
+ type SlotDay = Timeline['slots'][number]
11
+ type Mark = Timeline['rows'][number]['marks'][number]
12
+
13
+ const utc = (day: string): Date => new Date(`${day}T12:00:00Z`)
14
+ const LETTER = 'SMTWTFS'
15
+ const SHORT = new Intl.DateTimeFormat('en-GB', { timeZone: 'UTC', weekday: 'short', day: 'numeric', month: '2-digit' })
16
+ /** « Wed 28/10 » */
17
+ const dayName = (day: string): string => SHORT.format(utc(day)).replace(',', '')
18
+ const isMonday = (day: string): boolean => utc(day).getUTCDay() === 1
19
+ /** a day column's kind: today, a day to come, a Monday's line */
20
+ const col = (t: Timeline, day: string): string => `${day === t.today ? ' today' : day > t.today ? ' later' : ''}${isMonday(day) ? ' monday' : ''}`
21
+
22
+ function Dot(p: { tone: string; planned?: boolean; on?: boolean }) {
23
+ return <span className={`so-dot${p.planned ? ' planned' : ''}${p.on ? ' on' : ''}`} style={{ '--tone': p.tone } as CSSProperties} />
24
+ }
25
+
26
+ export const SocialCalendar = observer(({ so }: { so: SocialSt }) => {
27
+ const t = so.timeline
28
+ const open = so.calendarOpen
29
+ const rows = t ? t.rows.filter((r) => so.family === null || r.family === so.family) : []
30
+ const kinds = [...new Set(rows.flatMap((r) => r.marks.map((m) => m.kind)))].sort()
31
+ const week = t ? new Set(t.days.slice(14, 21)) : new Set<string>()
32
+ const posted7 = rows.reduce((n, r) => n + r.marks.filter((m) => !m.planned && week.has(m.day)).length, 0)
33
+ const who = so.identityOf(so.timelineIdentity)?.name
34
+ return (
35
+ <div className="so-cal">
36
+ <div className="so-calhead">
37
+ <Fold open={open} flip={() => so.flipCalendar()} />
38
+ <b className="so-click" onClick={() => so.flipCalendar()}>
39
+ Calendar
40
+ </b>
41
+ <span className="rv-dim rv-small">
42
+ {t ? `${posted7} posts these 7 days${who ? ` · ${who}` : ''}${so.fam === null ? '' : ` · ${FAM_LABEL[so.fam]}`}` : so.desk ? 'no timeline: no draft speaks as this identity here' : so.loadError ?? so.waitText}
43
+ </span>
44
+ <span className="sp" />
45
+ <span className="so-legendkinds">
46
+ {kinds.map((k) => (
47
+ <span key={k}>
48
+ <Dot tone={kindTone(k)} /> {k}
49
+ </span>
50
+ ))}
51
+ {kinds.length > 0 ? (
52
+ <span>
53
+ <Dot tone="var(--dim)" planned /> planned
54
+ </span>
55
+ ) : null}
56
+ </span>
57
+ </div>
58
+ {open && t ? (
59
+ <>
60
+ <Grid so={so} t={t} rows={rows} />
61
+ <Topics so={so} t={t} />
62
+ <WeekAhead so={so} t={t} />
63
+ </>
64
+ ) : null}
65
+ </div>
66
+ )
67
+ })
68
+
69
+ const Grid = observer(({ so, t, rows }: { so: SocialSt; t: Timeline; rows: Timeline['rows'] }) => {
70
+ const title = (slug: string): string => so.drafts.find((d) => d.slug === slug)?.title || slug
71
+ const at = (r: Timeline['rows'][number], day: string): Mark[] => r.marks.filter((m) => m.day === day)
72
+ const current = so.currentDraft?.slug
73
+ const identity = so.timelineIdentity
74
+ return (
75
+ <div className="so-calgrid" style={{ gridTemplateColumns: `96px repeat(${t.days.length}, minmax(0, 1fr))` }}>
76
+ <div />
77
+ {t.days.map((day) => (
78
+ <div key={day} className={`so-calday${col(t, day)}`}>
79
+ <div className="so-calnum">{Number(day.slice(8))}</div>
80
+ <div className="so-calletter">{LETTER[utc(day).getUTCDay()]}</div>
81
+ </div>
82
+ ))}
83
+ <div className="so-callabel rv-dim">slots</div>
84
+ {t.days.map((day) => (
85
+ <div key={day} className={`so-calcell${col(t, day)}`}>
86
+ {t.slots
87
+ .filter((s) => s.day === day)
88
+ .map((s) => (
89
+ <SlotMark key={s.slot.tag} so={so} s={s} today={t.today} title={title} />
90
+ ))}
91
+ </div>
92
+ ))}
93
+ {rows.map((r, i) => {
94
+ const edge = rows[i + 1] && rows[i + 1]!.family !== r.family ? ' edge' : ''
95
+ const a = so.accountOf(identity, r.account)
96
+ return [
97
+ <div key={r.account} className={`so-calacct${edge}`}>
98
+ <Logo id={r.account} name={a?.name ?? r.account} size={12} />
99
+ <span className="so-ellip">{a?.name ?? r.account}</span>
100
+ </div>,
101
+ ...t.days.map((day) => (
102
+ <div key={`${r.account}/${day}`} className={`so-calcell${col(t, day)}${edge}`}>
103
+ {at(r, day).map((m, k) => (
104
+ <button
105
+ key={k}
106
+ className="so-dotbtn"
107
+ onClick={() => so.pickDraft(m.slug)}
108
+ title={`${a?.name ?? r.account} · ${dayName(day)} · ${title(m.slug)} · ${m.kind || 'no kind'}${m.planned ? ' · planned' : ''}`}
109
+ >
110
+ <Dot tone={kindTone(m.kind)} planned={m.planned} on={m.slug === current} />
111
+ </button>
112
+ ))}
113
+ </div>
114
+ )),
115
+ ]
116
+ })}
117
+ </div>
118
+ )
119
+ })
120
+
121
+ /** a slot of the rhythm on its day: filled once a draft takes it, hollow while « empty »; grey once its day passed empty */
122
+ const SlotMark = observer(({ so, s, today, title }: { so: SocialSt; s: SlotDay; today: string; title: (slug: string) => string }) => {
123
+ const taken = s.drafts.length > 0
124
+ const first = s.drafts[0]
125
+ return (
126
+ <button
127
+ className={`so-slot${taken ? ' taken' : ''}${!taken && s.day < today ? ' missed' : ''}`}
128
+ onClick={() => first && so.pickDraft(first)}
129
+ title={`${dayName(s.day)} · #${s.slot.tag}${s.slot.time ? ` ${s.slot.time}` : ''} · ${taken ? s.drafts.map(title).join(', ') : 'empty'}\n${s.slot.what}`}
130
+ />
131
+ )
132
+ })
133
+
134
+ /** the topics of the last 14 days, the family's: a chip each, its drafts posted, a topic at 0 dimmed */
135
+ const Topics = observer(({ so, t }: { so: SocialSt; t: Timeline }) => {
136
+ const topics = t.topics[so.family ?? 'all']
137
+ if (topics.length === 0) return null
138
+ return (
139
+ <div className="so-calline">
140
+ <span className="so-callabel rv-dim">topics · 14 days</span>
141
+ {topics.map((x) => (
142
+ <span key={x.topic} className={`so-topic${x.n ? ' on' : ''}`} title={`${x.topic}: ${x.n} draft${x.n === 1 ? '' : 's'} posted these 14 days`}>
143
+ {x.topic} <span className="so-num">{x.n}</span>
144
+ </span>
145
+ ))}
146
+ </div>
147
+ )
148
+ })
149
+
150
+ /** the week ahead, as `sk social plan` says it: each slot and its draft or « empty », then the drafts ready with no slot */
151
+ const WeekAhead = observer(({ so, t }: { so: SocialSt; t: Timeline }) => {
152
+ const plan = t.plan
153
+ const title = (slug: string): string => so.drafts.find((d) => d.slug === slug)?.title || slug
154
+ return (
155
+ <div className="so-calline">
156
+ <span className="so-callabel rv-dim">the week</span>
157
+ {plan.slots.map((s) => (
158
+ <span key={`${s.day}/${s.slot.tag}`} className="so-weekslot" title={s.slot.what}>
159
+ <span className="rv-dim">{s.slot.day === 'week' ? 'week' : `${dayName(s.day)}${s.slot.time ? ` ${s.slot.time}` : ''}`}</span>
160
+ <b className="so-slottag">#{s.slot.tag}</b>
161
+ {s.drafts.length === 0 ? (
162
+ <i className="rv-dim">empty</i>
163
+ ) : (
164
+ s.drafts.map((slug) => (
165
+ <button key={slug} className="so-linkbtn so-ellip" onClick={() => so.pickDraft(slug)}>
166
+ {title(slug)}
167
+ </button>
168
+ ))
169
+ )}
170
+ </span>
171
+ ))}
172
+ {plan.missed.length > 0 ? (
173
+ <span className="so-missed rv-small" title={plan.missed.map(title).join('\n')}>
174
+ {plan.missed.length} slot{plan.missed.length === 1 ? '' : 's'} passed with no post
175
+ </span>
176
+ ) : null}
177
+ <span className="rv-dim rv-small" title={plan.ready.map(title).join('\n')}>
178
+ {plan.ready.length} ready with no slot
179
+ </span>
180
+ </div>
181
+ )
182
+ })