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.
- package/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/src/agent-time/hooks.ts +10 -3
- package/src/agent-time/live.ts +11 -5
- package/src/agent-time/registry.ts +289 -0
- package/src/agent-time/store.ts +2 -2
- package/src/annex/born.ts +2 -2
- package/src/annex/offload.ts +12 -11
- package/src/asks/ask-after.ts +6 -2
- package/src/asks/ask-bar-fold.ts +57 -0
- package/src/asks/ask-migrate.ts +280 -0
- package/src/asks/ask-steps-fold.ts +166 -0
- package/src/asks/ask-store.ts +586 -0
- package/src/assets/kits/identity-kit.ts +106 -38
- package/src/assets/kits/poster-thumbnail.ts +282 -0
- package/src/checks/SK003-claude-md-shape.check.ts +92 -25
- package/src/checks/SK004-gitignore-policy.check.ts +8 -4
- package/src/checks/SK013-one-way-in-policy.check.ts +10 -0
- package/src/checks/SK026-asks-autoclose.check.ts +9 -23
- package/src/checks/SK038-speaks-as.check.ts +3 -3
- package/src/checks/SK042-post-kinds.check.ts +26 -24
- package/src/checks/SK049-thread-answers-hook.check.ts +81 -0
- package/src/checks/SK050-retired-commands.check.ts +127 -0
- package/src/cli/cmd_Asks.ts +204 -53
- package/src/cli/cmd_Backup.ts +151 -8
- package/src/cli/cmd_Calls.ts +1 -0
- package/src/cli/cmd_Commands.ts +140 -34
- package/src/cli/cmd_Contracts.ts +1 -0
- package/src/cli/cmd_Keys.ts +1 -0
- package/src/cli/cmd_Lanes.ts +15 -4
- package/src/cli/cmd_Messages.ts +152 -1
- package/src/cli/cmd_Needs.ts +1 -0
- package/src/cli/cmd_Review.ts +931 -229
- package/src/cli/cmd_Secret.ts +255 -34
- package/src/cli/cmd_Social.ts +36 -33
- package/src/cli/cmd_SocialDrafts.ts +235 -0
- package/src/cli/cmd_Sound.ts +22 -1
- package/src/cli/cmd_Start.ts +3 -2
- package/src/cli/cmd_ThreadHolds.ts +34 -0
- package/src/cli/cmd_ThreadKinds.ts +146 -0
- package/src/cli/cmd_ThreadReflect.ts +83 -0
- package/src/cli/cmd_ThreadSyncNeeds.ts +62 -0
- package/src/cli/cmd_Vault.ts +1 -1
- package/src/cli/cmd_When.ts +1 -0
- package/src/cli/family-help.ts +2 -2
- package/src/cli/family-pages.ts +1 -1
- package/src/cli/kit/builtins.ts +1 -0
- package/src/cli/kit/verb.ts +6 -2
- package/src/cli/registry.ts +21 -2
- package/src/cli.ts +5 -2
- package/src/collections/actions.ts +25 -74
- package/src/collections/collection-types.ts +9 -5
- package/src/collections/md-body.ts +5 -3
- package/src/collections/pings.ts +13 -6
- package/src/collections/providers.ts +53 -61
- package/src/collections/reflections.ts +9 -4
- package/src/core/discover-checks.ts +18 -3
- package/src/core/git.ts +31 -0
- package/src/core/house-layout.ts +17 -0
- package/src/core/layout.ts +10 -5
- package/src/core/locked-write.ts +4 -1
- package/src/core/machine-db.ts +5 -3
- package/src/core/migrate-layout.ts +8 -10
- package/src/home/activity.ts +8 -15
- package/src/home/daemon-jobs.ts +13 -1
- package/src/home/home-paths.ts +6 -3
- package/src/home/home-routes.ts +8 -0
- package/src/home/inbox-shape.ts +233 -100
- package/src/home/inbox.ts +26 -71
- package/src/home/machine-fold.ts +10 -15
- package/src/home/machine-host.ts +19 -1
- package/src/home/other-macs.ts +2 -2
- package/src/home/serve-web.ts +6 -5
- package/src/home/space-page.ts +1 -1
- package/src/home/vault-page.ts +51 -17
- package/src/home/vault-words.ts +2 -2
- package/src/hooks/one-way-in-guard.ts +24 -2
- package/src/hq/files-send.ts +27 -28
- package/src/hq/hq-db.ts +4 -1
- package/src/hq/hq-local.ts +37 -4
- package/src/hq/hq-routes.ts +10 -2
- package/src/hq/hq-store.ts +6 -2
- package/src/hq/kinds/ask.ts +6 -6
- package/src/hq/outbox.ts +5 -3
- package/src/hq/replica.ts +1 -2
- package/src/hq/vault-route.ts +112 -0
- package/src/identities/collection.ts +2 -2
- package/src/identities/identities.ts +9 -8
- package/src/identities/machine-route.ts +8 -3
- package/src/ledger/db.ts +8 -1
- package/src/media-store/backup/daemon.ts +48 -8
- package/src/media-store/backup/keys.ts +1 -1
- package/src/media-store/backup/manifest.ts +20 -2
- package/src/media-store/backup/prune.ts +365 -0
- package/src/media-store/backup/retention.ts +122 -0
- package/src/media-store/backup/run.ts +14 -8
- package/src/media-store/backup/sources.ts +18 -17
- package/src/media-store/backup/thread-copy.ts +340 -0
- package/src/media-store/copy/config.ts +3 -4
- package/src/media-store/copy/store.ts +2 -2
- package/src/media-store/db.ts +2 -2
- package/src/media-store/forget.ts +118 -0
- package/src/media-store/purge.ts +3 -2
- package/src/media-store/space-listing.ts +20 -4
- package/src/media-store/space.ts +6 -5
- package/src/messages/guard.ts +49 -0
- package/src/messages/model.ts +1 -1
- package/src/messages/objects.ts +201 -0
- package/src/messages/routes.ts +2 -2
- package/src/messages/score.ts +1 -1
- package/src/messages/write.ts +285 -0
- package/src/pages/frame-client.ts +181 -4
- package/src/reflections/reflections-queue.ts +1 -1
- package/src/release/gate-checkout.ts +2 -1
- package/src/release/git-facts.ts +3 -2
- package/src/release/public-clean.ts +3 -2
- package/src/repo-config.ts +40 -18
- package/src/review/anim.ts +1 -1
- package/src/review/answer-kinds.ts +131 -0
- package/src/review/band.ts +53 -0
- package/src/review/branch-hold.ts +84 -0
- package/src/review/card-db.ts +16 -6
- package/src/review/card-rows.ts +4 -3
- package/src/review/cells.ts +297 -65
- package/src/review/close.ts +92 -0
- package/src/review/draft-card.ts +8 -16
- package/src/review/draft-model.ts +2 -2
- package/src/review/events.ts +171 -0
- package/src/review/format.ts +128 -14
- package/src/review/glyphs.ts +63 -0
- package/src/review/gone.ts +1 -1
- package/src/review/holds-sync.ts +62 -0
- package/src/review/holds.ts +85 -0
- package/src/review/house-kind-defs.ts +41 -0
- package/src/review/inbox-hook.ts +22 -9
- package/src/review/inbox-read.ts +201 -0
- package/src/review/instructions.ts +199 -0
- package/src/review/kind-apply.ts +61 -0
- package/src/review/kind-catalog.ts +96 -0
- package/src/review/kinds.ts +278 -0
- package/src/review/lane-ask.ts +109 -0
- package/src/review/model.ts +396 -86
- package/src/review/move.ts +3 -3
- package/src/review/need-address.ts +15 -0
- package/src/review/need-threads.ts +93 -0
- package/src/review/object-card.ts +48 -0
- package/src/review/object-read.ts +31 -0
- package/src/review/owner-verdict.ts +36 -0
- package/src/review/parties.ts +182 -0
- package/src/review/previews.ts +3 -1
- package/src/review/projections.ts +235 -0
- package/src/review/referring.ts +54 -0
- package/src/review/reflection-object.ts +195 -0
- package/src/review/routes.ts +137 -32
- package/src/review/secret-route.ts +80 -0
- package/src/review/snooze.ts +38 -0
- package/src/review/stage-card.ts +4 -4
- package/src/review/store.ts +366 -85
- package/src/review/supersede.ts +116 -0
- package/src/review/take-back.ts +52 -0
- package/src/review/thread-fold.ts +20 -7
- package/src/review/threads.ts +236 -39
- package/src/review/traces.ts +218 -0
- package/src/review/trailer-card.ts +2 -2
- package/src/review/unit.ts +71 -5
- package/src/review/verdict-items.ts +73 -0
- package/src/review/verdict-write.ts +15 -0
- package/src/review/wait.ts +85 -0
- package/src/review/watchers.ts +22 -9
- package/src/scaffold/files/claude-settings-local.json +2 -0
- package/src/secrets/archive-mark.ts +52 -0
- package/src/secrets/archive.ts +83 -0
- package/src/secrets/copy.ts +14 -14
- package/src/secrets/keychain-write.ts +48 -0
- package/src/secrets/keychain.ts +8 -5
- package/src/secrets/lapse-mark.ts +33 -0
- package/src/secrets/lapse.ts +60 -0
- package/src/secrets/list.ts +16 -22
- package/src/secrets/manager.ts +31 -16
- package/src/secrets/read.ts +161 -33
- package/src/secrets/tail.ts +31 -0
- package/src/serve/hub-app/asks-page.tsx +2 -1
- package/src/serve/hub-app/auto-text.tsx +14 -6
- package/src/serve/hub-app/benign-errors.ts +15 -1
- package/src/serve/hub-app/card-head.tsx +49 -0
- package/src/serve/hub-app/check-view.tsx +3 -2
- package/src/serve/hub-app/code-copy.ts +35 -0
- package/src/serve/hub-app/col-card.tsx +31 -40
- package/src/serve/hub-app/col-list-page.tsx +5 -2
- package/src/serve/hub-app/col-tables-view.tsx +7 -4
- package/src/serve/hub-app/col-tables.ts +5 -5
- package/src/serve/hub-app/cols-svc.ts +4 -79
- package/src/serve/hub-app/commands/commands-page.tsx +2 -1
- package/src/serve/hub-app/controls.css +83 -0
- package/src/serve/hub-app/frames-st.ts +17 -1
- package/src/serve/hub-app/git-view.tsx +3 -2
- package/src/serve/hub-app/home-st.ts +57 -6
- package/src/serve/hub-app/home-strip.css +1 -6
- package/src/serve/hub-app/home-strip.tsx +2 -1
- package/src/serve/hub-app/home.html +3 -0
- package/src/serve/hub-app/house-wiki-view.tsx +20 -0
- package/src/serve/hub-app/hub-app.tsx +48 -32
- package/src/serve/hub-app/hub-types.ts +2 -0
- package/src/serve/hub-app/hub.css +50 -61
- package/src/serve/hub-app/icons.tsx +14 -4
- package/src/serve/hub-app/identities-view.tsx +4 -3
- package/src/serve/hub-app/inbox-st.ts +203 -42
- package/src/serve/hub-app/inbox-view.tsx +189 -101
- package/src/serve/hub-app/inbox.css +47 -44
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/instructions.css +30 -0
- package/src/serve/hub-app/keys.ts +5 -3
- package/src/serve/hub-app/machine-st.ts +2 -2
- package/src/serve/hub-app/machines-view.tsx +4 -11
- package/src/serve/hub-app/machines.css +0 -9
- package/src/serve/hub-app/markdown.css +51 -0
- package/src/serve/hub-app/md-copy.tsx +18 -40
- package/src/serve/hub-app/md.ts +25 -9
- package/src/serve/hub-app/media-view.tsx +2 -2
- package/src/serve/hub-app/messages/messages-page.tsx +2 -1
- package/src/serve/hub-app/messages/messages-st.ts +1 -1
- package/src/serve/hub-app/messages.css +0 -1
- package/src/serve/hub-app/objects.css +51 -0
- package/src/serve/hub-app/page-keys.ts +1 -1
- package/src/serve/hub-app/pages-frames.tsx +11 -1
- package/src/serve/hub-app/palette-st.ts +4 -4
- package/src/serve/hub-app/pane-boundary.tsx +72 -0
- package/src/serve/hub-app/pane-errors.ts +54 -0
- package/src/serve/hub-app/plan-view.tsx +3 -2
- package/src/serve/hub-app/planned-view.tsx +3 -3
- package/src/serve/hub-app/planned.css +0 -4
- package/src/serve/hub-app/processes-view.tsx +3 -2
- package/src/serve/hub-app/project-list.css +5 -13
- package/src/serve/hub-app/project-list.tsx +3 -6
- package/src/serve/hub-app/projects-svc.ts +6 -2
- package/src/serve/hub-app/readme.css +9 -15
- package/src/serve/hub-app/reflections-page.tsx +54 -1
- package/src/serve/hub-app/releases/releases-page.tsx +3 -2
- package/src/serve/hub-app/releases.css +0 -1
- package/src/serve/hub-app/review/code-colors.ts +30 -0
- package/src/serve/hub-app/review/diff-view.tsx +75 -0
- package/src/serve/hub-app/review/dock.tsx +104 -0
- package/src/serve/hub-app/review/draft-card.tsx +2 -2
- package/src/serve/hub-app/review/group-block.tsx +209 -0
- package/src/serve/hub-app/review/instructions-view.tsx +116 -0
- package/src/serve/hub-app/review/item-verdict.tsx +38 -0
- package/src/serve/hub-app/review/kind-states.tsx +193 -0
- package/src/serve/hub-app/review/kind-view.tsx +1 -37
- package/src/serve/hub-app/review/kit.tsx +57 -54
- package/src/serve/hub-app/review/lane-bar.tsx +64 -0
- package/src/serve/hub-app/review/object-card.tsx +62 -0
- package/src/serve/hub-app/review/object-panel.tsx +179 -0
- package/src/serve/hub-app/review/question-views.tsx +385 -0
- package/src/serve/hub-app/review/review-cells.tsx +86 -105
- package/src/serve/hub-app/review/review-list.tsx +104 -47
- package/src/serve/hub-app/review/review-page.tsx +5 -4
- package/src/serve/hub-app/review/review-st.ts +68 -28
- package/src/serve/hub-app/review/review-thread.tsx +171 -40
- package/src/serve/hub-app/review/review-views.tsx +35 -31
- package/src/serve/hub-app/review/thread-close.tsx +124 -0
- package/src/serve/hub-app/review/thread-control.tsx +4 -4
- package/src/serve/hub-app/review/thread-st.ts +222 -22
- package/src/serve/hub-app/review/trailer-card.tsx +1 -1
- package/src/serve/hub-app/review/trailer-timeline.tsx +2 -2
- package/src/serve/hub-app/review.css +216 -57
- package/src/serve/hub-app/section-head.tsx +51 -0
- package/src/serve/hub-app/social/calendar.tsx +5 -11
- package/src/serve/hub-app/social/comms-page.tsx +23 -10
- package/src/serve/hub-app/social/kit.tsx +8 -15
- package/src/serve/hub-app/social/next-release.tsx +3 -5
- package/src/serve/hub-app/social/post-card.tsx +3 -0
- package/src/serve/hub-app/social/post-page.tsx +80 -0
- package/src/serve/hub-app/social/problems.tsx +5 -9
- package/src/serve/hub-app/social/social-model.ts +13 -5
- package/src/serve/hub-app/social/social-page.tsx +1 -1
- package/src/serve/hub-app/social/social-st.ts +42 -5
- package/src/serve/hub-app/social.css +7 -17
- package/src/serve/hub-app/space.css +1 -1
- package/src/serve/hub-app/stores/stores-page.tsx +6 -2
- package/src/serve/hub-app/thread-row.tsx +101 -0
- package/src/serve/hub-app/time-ago.tsx +3 -2
- package/src/serve/hub-app/time-view.tsx +2 -1
- package/src/serve/hub-app/time.css +2 -5
- package/src/serve/hub-app/tree-row.tsx +1 -9
- package/src/serve/hub-app/vault-view.tsx +4 -4
- package/src/serve/hub-app/veille/veille-page.tsx +2 -11
- package/src/serve/hub-app/veille.css +0 -1
- package/src/serve/hub-app/waiting-svc.ts +4 -4
- package/src/serve/hub-app/when-view.tsx +6 -3
- package/src/serve/hub-app/wiki-st.ts +30 -4
- package/src/serve/hub-app/wikis-view.tsx +4 -3
- package/src/serve/hub-runtime.ts +20 -6
- package/src/serve/project-gutter-route.ts +16 -6
- package/src/serve/project-gutter.ts +6 -53
- package/src/serve/same-origin.ts +3 -0
- package/src/serve/secret-gate.ts +21 -0
- package/src/serve/serve-hub.ts +29 -20
- package/src/serve/tailnet-caller.ts +117 -0
- package/src/shipkit.ts +2 -2
- package/src/site/desk.ts +2 -2
- package/src/smoke/run-smoke.ts +3 -4
- package/src/social/brands.ts +4 -0
- package/src/social/card-drafts.ts +11 -19
- package/src/social/desk-index.ts +34 -13
- package/src/social/drafts.ts +4 -4
- package/src/social/import-drafts.ts +244 -0
- package/src/social/kind-pages.ts +3 -3
- package/src/social/kinds.ts +1 -1
- package/src/social/load.ts +89 -64
- package/src/social/media-kind.ts +68 -161
- package/src/social/media-of.ts +5 -4
- package/src/social/open.ts +3 -2
- package/src/social/post-object.ts +120 -0
- package/src/social/post-sources.ts +136 -0
- package/src/social/post-text.ts +103 -0
- package/src/social/posts.ts +378 -0
- package/src/social/presence.ts +7 -5
- package/src/social/publish/index.ts +17 -5
- package/src/social/publish/secret.ts +2 -2
- package/src/social/release-stage.ts +58 -57
- package/src/social/routes.ts +64 -24
- package/src/social/stage.ts +42 -57
- package/src/social/text.ts +4 -3
- package/src/social/thumbnail.ts +135 -43
- package/src/social/tracker.ts +1 -1
- package/src/social/writes.ts +12 -29
- package/src/stores/desk.ts +16 -11
- package/src/stores/unit.ts +2 -2
- package/src/trailer/sound/eleven.ts +33 -3
- package/src/urls/rows.ts +1 -1
- package/src/vault/vault-http.ts +11 -3
- package/src/vault/vault-import.ts +6 -1
- package/src/veille/identity.ts +2 -2
- package/src/wiki/graph-pages.ts +13 -1
- package/src/wiki/scan-md.ts +1 -1
- package/src/asks/asks-queue.ts +0 -424
- package/src/messages/suggest.ts +0 -96
- package/src/social/migrate.ts +0 -123
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// who calls the home over the tailnet (wiki tools/shipkit/threads-asks.md, The secret field). tailscaled's https serve
|
|
2
|
+
// overwrites x-forwarded-for with the caller's tailnet address, x-forwarded-proto, and every tailscale-user-* a client
|
|
3
|
+
// sends; x-forwarded-host becomes the Host the client sent, so it proves nothing (wiki services/tailscale/index.md).
|
|
4
|
+
// The device is tailscale's whois of the forwarded address, never a header.
|
|
5
|
+
// The one constraint a reader breaks first: these headers are tailscaled's word only on a request tailscaled's https
|
|
6
|
+
// handler brought to the web. A relay that keeps a caller's headers, in front of the web or of the daemon, makes them
|
|
7
|
+
// anyone's: the web's Host tag refuses a relay that fetches the web, nothing here refuses one that copies Host too
|
|
8
|
+
import { homePort } from '../home/home-paths.ts'
|
|
9
|
+
import { tailscaleJson } from '../home/machine-host.ts'
|
|
10
|
+
import { HOST_HEADER } from './same-origin.ts'
|
|
11
|
+
|
|
12
|
+
/** a device of the tailnet, as tailscale's whois of its address says */
|
|
13
|
+
export type TailnetPeer = { node: string; id: string; os: string; tags: string[]; login: string }
|
|
14
|
+
/** this Mac on the tailnet: its node id, its MagicDNS name without the final dot, its owner's login */
|
|
15
|
+
export type TailnetSelf = { id: string; dns: string; login: string }
|
|
16
|
+
export type TailnetWho = { self(): Promise<TailnetSelf | null>; whois(ip: string): Promise<TailnetPeer | null> }
|
|
17
|
+
|
|
18
|
+
/** the operating systems of a phone, as tailscale names them */
|
|
19
|
+
const PHONE_OS = new Set(['android', 'ios'])
|
|
20
|
+
|
|
21
|
+
/** an address tailscale hands out: 100.64.0.0/10, or its IPv6 range fd7a:115c:a1e0::/48 */
|
|
22
|
+
export function tailnetAddress(ip: string): boolean {
|
|
23
|
+
const v4 = /^100\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(ip)
|
|
24
|
+
if (v4 != null) return [v4[1], v4[2], v4[3]].every((n) => Number(n) <= 255) && Number(v4[1]) >= 64 && Number(v4[1]) <= 127
|
|
25
|
+
return /^fd7a:115c:a1e0:[0-9a-f:]*$/i.test(ip)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type WhoisJson = { Node?: { Name?: string; StableID?: string; Tags?: string[]; Hostinfo?: { OS?: string } }; UserProfile?: { LoginName?: string } }
|
|
29
|
+
type StatusJson = { Self?: { ID?: string; DNSName?: string; TailscaleIPs?: string[] } }
|
|
30
|
+
|
|
31
|
+
/** a device from `tailscale whois --json`; null when a part is missing. This Mac's own whois names no OS */
|
|
32
|
+
export function peerOfWhois(json: unknown): TailnetPeer | null {
|
|
33
|
+
const j = json as WhoisJson | null
|
|
34
|
+
const n = j?.Node
|
|
35
|
+
const login = j?.UserProfile?.LoginName
|
|
36
|
+
return n?.Name && n.StableID && login ? { node: n.Name.replace(/\.$/, ''), id: n.StableID, os: n.Hostinfo?.OS ?? '', tags: n.Tags ?? [], login } : null
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** this Mac's first tailnet address, from `tailscale status --json --peers=false` */
|
|
40
|
+
export const ownAddress = (json: unknown): string | null => (json as StatusJson | null)?.Self?.TailscaleIPs?.[0] ?? null
|
|
41
|
+
|
|
42
|
+
/** this Mac from its status and the whois of its own address: status names the owner by a UserID past 2^53, which
|
|
43
|
+
* JSON.parse rounds, so the login comes from the whois */
|
|
44
|
+
export function selfOf(status: unknown, own: TailnetPeer | null): TailnetSelf | null {
|
|
45
|
+
const s = (status as StatusJson | null)?.Self
|
|
46
|
+
return s?.ID && s.DNSName && own != null ? { id: s.ID, dns: s.DNSName.replace(/\.$/, '').toLowerCase(), login: own.login } : null
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const KEEP_MS = 30_000
|
|
50
|
+
const kept = new Map<string, { at: number; v: unknown }>()
|
|
51
|
+
async function keptFor<T>(key: string, read: () => Promise<T | null>): Promise<T | null> {
|
|
52
|
+
const k = kept.get(key)
|
|
53
|
+
if (k != null && Date.now() - k.at < KEEP_MS) return k.v as T
|
|
54
|
+
const v = await read()
|
|
55
|
+
if (v != null) kept.set(key, { at: Date.now(), v })
|
|
56
|
+
return v
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const whoisOf = (ip: string): Promise<TailnetPeer | null> => keptFor(`whois ${ip}`, async () => peerOfWhois(await tailscaleJson(['whois', '--json', ip])))
|
|
60
|
+
|
|
61
|
+
/** the tailscale of this Mac, asked through its cli; each answer kept 30 s, a silence never */
|
|
62
|
+
export const houseTailnet: TailnetWho = {
|
|
63
|
+
self: () =>
|
|
64
|
+
keptFor('self', async () => {
|
|
65
|
+
const status = await tailscaleJson(['status', '--json', '--peers=false'])
|
|
66
|
+
const ip = ownAddress(status)
|
|
67
|
+
return selfOf(status, ip == null ? null : await whoisOf(ip))
|
|
68
|
+
}),
|
|
69
|
+
whois: whoisOf,
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** what only a hop other than tailscaled writes: tailscaled itself writes none of them */
|
|
73
|
+
const OTHER_HOP = ['via', 'forwarded', 'x-real-ip', 'x-forwarded-port']
|
|
74
|
+
|
|
75
|
+
export const isPhone = (peer: TailnetPeer): boolean => PHONE_OS.has(peer.os.toLowerCase())
|
|
76
|
+
|
|
77
|
+
/** the caller tailscaled's https serve brought, from its headers alone: one tailnet address, the person tailscale
|
|
78
|
+
* named, no other hop; or why not */
|
|
79
|
+
export function servedCaller(h: Headers): { ip: string; login: string } | { refused: string } {
|
|
80
|
+
if (!h.has('x-forwarded-for')) return { refused: 'it came through a proxy' }
|
|
81
|
+
if (h.get('x-forwarded-proto') !== 'https') return { refused: 'it came over plain http, not the tailnet https of the hub' }
|
|
82
|
+
const hop = OTHER_HOP.find((k) => h.has(k))
|
|
83
|
+
if (hop != null) return { refused: `it came through a proxy other than tailscale (${hop})` }
|
|
84
|
+
const ip = (h.get('x-forwarded-for') ?? '').trim()
|
|
85
|
+
if (!tailnetAddress(ip)) return { refused: 'it names no single tailnet address as its caller' }
|
|
86
|
+
const login = h.get('tailscale-user-login') ?? ''
|
|
87
|
+
if (login === '') return { refused: 'tailscale named no person for it (a tagged device, or no tailscale serve)' }
|
|
88
|
+
return { ip, login }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** the device at a served caller's address, by tailscale's whois: an untagged device of this Mac's owner, whose
|
|
92
|
+
* login is the one tailscale named; or why not */
|
|
93
|
+
export async function ownersDevice(who: TailnetWho, self: TailnetSelf, caller: { ip: string; login: string }): Promise<TailnetPeer | { refused: string }> {
|
|
94
|
+
const peer = await who.whois(caller.ip)
|
|
95
|
+
if (peer == null) return { refused: `tailscale did not say who ${caller.ip} is` }
|
|
96
|
+
if (peer.tags.length > 0) return { refused: `${peer.node} is a tagged device, no person's` }
|
|
97
|
+
if (peer.login !== caller.login || peer.login !== self.login) return { refused: `${peer.node} is not a device of the owner of this Mac` }
|
|
98
|
+
return peer
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** why a request tailscaled brought is not your phone's (or this Mac's own, by its tailnet name), null when it is: over
|
|
102
|
+
* https, to the web by the hub's tailnet name and port, no other hop, and the whois of its address an untagged device
|
|
103
|
+
* of this Mac's owner that is a phone or this Mac */
|
|
104
|
+
export async function tailnetRefusal(req: Request, o: { who?: TailnetWho } = {}): Promise<string | null> {
|
|
105
|
+
const h = req.headers
|
|
106
|
+
const caller = servedCaller(h)
|
|
107
|
+
if ('refused' in caller) return caller.refused
|
|
108
|
+
const who = o.who ?? houseTailnet
|
|
109
|
+
const self = await who.self()
|
|
110
|
+
if (self == null) return 'tailscale does not answer on this Mac'
|
|
111
|
+
if ((h.get(HOST_HEADER) ?? '').toLowerCase() !== `${self.dns}:${homePort()}`) return 'it did not reach the hub by its tailnet name'
|
|
112
|
+
const peer = await ownersDevice(who, self, caller)
|
|
113
|
+
if ('refused' in peer) return peer.refused
|
|
114
|
+
if (peer.id === self.id) return null
|
|
115
|
+
if (!isPhone(peer)) return `${peer.node} (${peer.os || 'unknown'}) is no phone`
|
|
116
|
+
return null
|
|
117
|
+
}
|
package/src/shipkit.ts
CHANGED
|
@@ -53,8 +53,8 @@ export type { ContractsConfig, ContractsResult, ContractOutcome } from './contra
|
|
|
53
53
|
export { defineContract, validateManifest, file, png, glob, md, dir, custom, script, fileContains, dirExists } from './contracts/contract-types.ts'
|
|
54
54
|
export type { ContractManifest, ArtifactRule, Detector, ContractEnv } from './contracts/contract-types.ts'
|
|
55
55
|
export { allContracts } from './contracts/contract-manifests.ts'
|
|
56
|
-
export { listAsks, openAsks, checkAsks, createAsk, renderAsksTable } from './asks/
|
|
57
|
-
export type { Ask, CreateOpts } from './asks/
|
|
56
|
+
export { listAsks, openAsks, checkAsks, createAsk, declineAsk, findAsk, renderAsksTable } from './asks/ask-store.ts'
|
|
57
|
+
export type { Ask, CreateOpts } from './asks/ask-store.ts'
|
|
58
58
|
// assets surface (folded in from the standalone atelier lib; that npm
|
|
59
59
|
// package is frozen). A repo's .shipkit/assets/kit.ts imports defineKit and
|
|
60
60
|
// declares its kinds; `shipkit assets …` derives the rest.
|
package/src/site/desk.ts
CHANGED
|
@@ -96,7 +96,7 @@ const cloudflare = new Map<string, { at: number; value: Deployed | null }>()
|
|
|
96
96
|
/** a deploy ended: what Cloudflare says is asked again */
|
|
97
97
|
export const forgetDeployed = (): void => cloudflare.clear()
|
|
98
98
|
|
|
99
|
-
/** the Cloudflare token the house config names (`serve.cloudflareToken`), read through
|
|
99
|
+
/** the Cloudflare token the house config names (`serve.cloudflareToken`), read through the house store; null when it names none or the store holds none */
|
|
100
100
|
async function cloudflareToken(cwd: string): Promise<string | null> {
|
|
101
101
|
const { houseRootOf } = await import('../home/home-start.ts')
|
|
102
102
|
const { loadRepoConfig } = await import('../repo-config.ts')
|
|
@@ -105,7 +105,7 @@ async function cloudflareToken(cwd: string): Promise<string | null> {
|
|
|
105
105
|
if (!house) return null
|
|
106
106
|
const c = await loadRepoConfig(house)
|
|
107
107
|
const name = c.serve?.cloudflareToken
|
|
108
|
-
if (!name
|
|
108
|
+
if (!name) return null
|
|
109
109
|
try {
|
|
110
110
|
return await readThrough(c.credsReadCommand, name)
|
|
111
111
|
} catch {
|
package/src/smoke/run-smoke.ts
CHANGED
|
@@ -38,9 +38,9 @@ export type SmokeLogin = {
|
|
|
38
38
|
path?: string
|
|
39
39
|
/** the identity typed into the login form. One of `email` / `emailSecret`. */
|
|
40
40
|
email?: string
|
|
41
|
-
/** the secret whose ACCOUNT field is the identity (read through the repo's `credsReadCommand`) */
|
|
41
|
+
/** the secret whose ACCOUNT field is the identity (read through the house store, or the repo's `credsReadCommand`) */
|
|
42
42
|
emailSecret?: string
|
|
43
|
-
/** the secret whose value is the password, a NAME the repo's `credsReadCommand` resolves. Never argv, never env. */
|
|
43
|
+
/** the secret whose value is the password, a NAME the house store (or the repo's `credsReadCommand`) resolves. Never argv, never env. */
|
|
44
44
|
passwordSecret: string
|
|
45
45
|
/** how to find the three controls: a CSS selector (starts with `#`, `.`,
|
|
46
46
|
* `[` or a tag) or a LABEL. A label finds the field by its `<label>` text
|
|
@@ -311,8 +311,7 @@ export async function runSmoke(root: string, config: SmokeConfig, opts: SmokeRun
|
|
|
311
311
|
|
|
312
312
|
// secrets are read BEFORE the browser starts, so a missing one costs no launch
|
|
313
313
|
const login = config.login
|
|
314
|
-
const reader = opts.credsReadCommand
|
|
315
|
-
if (login != null && reader === '') throw new Error('FAIL smoke.login needs credsReadCommand in repo.config.ts (defineRepo refuses the pair, so this config bypassed it)')
|
|
314
|
+
const reader = opts.credsReadCommand
|
|
316
315
|
const { readThrough } = await import('../secrets/read.ts')
|
|
317
316
|
const identity = login == null ? null : (login.email ?? (await readThrough(reader, login.emailSecret!, 'account', root)))
|
|
318
317
|
const password = login == null ? null : await readThrough(reader, login.passwordSecret, 'get', root)
|
package/src/social/brands.ts
CHANGED
|
@@ -5,9 +5,13 @@
|
|
|
5
5
|
export const BRANDS: Readonly<Record<string, { hex: string; d: string }>> = {
|
|
6
6
|
bluesky: { hex: '#0285FF', d: 'M12 10.8c-1.087-2.114-4.046-6.053-6.798-7.995C2.566.944 1.561 1.266.902 1.565.139 1.908 0 3.08 0 3.768c0 .69.378 5.65.624 6.479.815 2.736 3.713 3.66 6.383 3.364.136-.02.275-.039.415-.056-.138.022-.276.04-.415.056-3.912.58-7.387 2.005-2.83 7.078 5.013 5.19 6.87-1.113 7.823-4.308.953 3.195 2.05 9.271 7.733 4.308 4.267-4.308 1.172-6.498-2.74-7.078a8.741 8.741 0 0 1-.415-.056c.14.017.279.036.415.056 2.67.297 5.568-.628 6.383-3.364.246-.828.624-5.79.624-6.478 0-.69-.139-1.861-.902-2.206-.659-.298-1.664-.62-4.3 1.24C16.046 4.748 13.087 8.687 12 10.8Z' },
|
|
7
7
|
discord: { hex: '#5865F2', d: 'M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z' },
|
|
8
|
+
github: { hex: '#181717', d: 'M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12' },
|
|
8
9
|
instagram: { hex: '#E4405F', d: 'M7.0301.084c-1.2768.0602-2.1487.264-2.911.5634-.7888.3075-1.4575.72-2.1228 1.3877-.6652.6677-1.075 1.3368-1.3802 2.127-.2954.7638-.4956 1.6365-.552 2.914-.0564 1.2775-.0689 1.6882-.0626 4.947.0062 3.2586.0206 3.6671.0825 4.9473.061 1.2765.264 2.1482.5635 2.9107.308.7889.72 1.4573 1.388 2.1228.6679.6655 1.3365 1.0743 2.1285 1.38.7632.295 1.6361.4961 2.9134.552 1.2773.056 1.6884.069 4.9462.0627 3.2578-.0062 3.668-.0207 4.9478-.0814 1.28-.0607 2.147-.2652 2.9098-.5633.7889-.3086 1.4578-.72 2.1228-1.3881.665-.6682 1.0745-1.3378 1.3795-2.1284.2957-.7632.4966-1.636.552-2.9124.056-1.2809.0692-1.6898.063-4.948-.0063-3.2583-.021-3.6668-.0817-4.9465-.0607-1.2797-.264-2.1487-.5633-2.9117-.3084-.7889-.72-1.4568-1.3876-2.1228C21.2982 1.33 20.628.9208 19.8378.6165 19.074.321 18.2017.1197 16.9244.0645 15.6471.0093 15.236-.005 11.977.0014 8.718.0076 8.31.0215 7.0301.0839m.1402 21.6932c-1.17-.0509-1.8053-.2453-2.2287-.408-.5606-.216-.96-.4771-1.3819-.895-.422-.4178-.6811-.8186-.9-1.378-.1644-.4234-.3624-1.058-.4171-2.228-.0595-1.2645-.072-1.6442-.079-4.848-.007-3.2037.0053-3.583.0607-4.848.05-1.169.2456-1.805.408-2.2282.216-.5613.4762-.96.895-1.3816.4188-.4217.8184-.6814 1.3783-.9003.423-.1651 1.0575-.3614 2.227-.4171 1.2655-.06 1.6447-.072 4.848-.079 3.2033-.007 3.5835.005 4.8495.0608 1.169.0508 1.8053.2445 2.228.408.5608.216.96.4754 1.3816.895.4217.4194.6816.8176.9005 1.3787.1653.4217.3617 1.056.4169 2.2263.0602 1.2655.0739 1.645.0796 4.848.0058 3.203-.0055 3.5834-.061 4.848-.051 1.17-.245 1.8055-.408 2.2294-.216.5604-.4763.96-.8954 1.3814-.419.4215-.8181.6811-1.3783.9-.4224.1649-1.0577.3617-2.2262.4174-1.2656.0595-1.6448.072-4.8493.079-3.2045.007-3.5825-.006-4.848-.0608M16.953 5.5864A1.44 1.44 0 1 0 18.39 4.144a1.44 1.44 0 0 0-1.437 1.4424M5.8385 12.012c.0067 3.4032 2.7706 6.1557 6.173 6.1493 3.4026-.0065 6.157-2.7701 6.1506-6.1733-.0065-3.4032-2.771-6.1565-6.174-6.1498-3.403.0067-6.156 2.771-6.1496 6.1738M8 12.0077a4 4 0 1 1 4.008 3.9921A3.9996 3.9996 0 0 1 8 12.0077' },
|
|
9
10
|
itch: { hex: '#FA5C5C', d: 'M3.13 1.338C2.08 1.96.02 4.328 0 4.95v1.03c0 1.303 1.22 2.45 2.325 2.45 1.33 0 2.436-1.102 2.436-2.41 0 1.308 1.07 2.41 2.4 2.41 1.328 0 2.362-1.102 2.362-2.41 0 1.308 1.137 2.41 2.466 2.41h.024c1.33 0 2.466-1.102 2.466-2.41 0 1.308 1.034 2.41 2.363 2.41 1.33 0 2.4-1.102 2.4-2.41 0 1.308 1.106 2.41 2.435 2.41C22.78 8.43 24 7.282 24 5.98V4.95c-.02-.62-2.082-2.99-3.13-3.612-3.253-.114-5.508-.134-8.87-.133-3.362 0-7.945.053-8.87.133zm6.376 6.477a2.74 2.74 0 0 1-.468.602c-.5.49-1.19.795-1.947.795a2.786 2.786 0 0 1-1.95-.795c-.182-.178-.32-.37-.446-.59-.127.222-.303.412-.486.59a2.788 2.788 0 0 1-1.95.795c-.092 0-.187-.025-.264-.052-.107 1.113-.152 2.176-.168 2.95v.005l-.006 1.167c.02 2.334-.23 7.564 1.03 8.85 1.952.454 5.545.662 9.15.663 3.605 0 7.198-.21 9.15-.664 1.26-1.284 1.01-6.514 1.03-8.848l-.006-1.167v-.004c-.016-.775-.06-1.838-.168-2.95-.077.026-.172.052-.263.052a2.788 2.788 0 0 1-1.95-.795c-.184-.178-.36-.368-.486-.59-.127.22-.265.412-.447.59a2.786 2.786 0 0 1-1.95.794c-.76 0-1.446-.303-1.948-.793a2.74 2.74 0 0 1-.468-.602 2.738 2.738 0 0 1-.463.602 2.787 2.787 0 0 1-1.95.794h-.16a2.787 2.787 0 0 1-1.95-.793 2.738 2.738 0 0 1-.464-.602zm-2.004 2.59v.002c.795.002 1.5 0 2.373.953.687-.072 1.406-.108 2.125-.107.72 0 1.438.035 2.125.107.873-.953 1.578-.95 2.372-.953.376 0 1.876 0 2.92 2.934l1.123 4.028c.832 2.995-.266 3.068-1.636 3.07-2.03-.075-3.156-1.55-3.156-3.025-1.124.184-2.436.276-3.748.277-1.312 0-2.624-.093-3.748-.277 0 1.475-1.125 2.95-3.156 3.026-1.37-.004-2.468-.077-1.636-3.072l1.122-4.027c1.045-2.934 2.545-2.934 2.92-2.934zM12 12.714c-.002.002-2.14 1.964-2.523 2.662l1.4-.056v1.22c0 .056.56.033 1.123.007.562.026 1.124.05 1.124-.008v-1.22l1.4.055C14.138 14.677 12 12.713 12 12.713z' },
|
|
11
|
+
kickstarter: { hex: '#05CE78', d: 'M7.168 0c-3.2 0-5.797 2.579-5.797 5.758v12.484C1.371 21.42 3.968 24 7.168 24c1.981 0 3.716-.978 4.768-2.479l.794.79c2.26 2.245 5.943 2.245 8.203 0a5.724 5.724 0 001.696-4.075 5.724 5.724 0 00-1.696-4.074l-2.182-2.168 2.182-2.156a5.724 5.724 0 001.696-4.074 5.724 5.724 0 00-1.696-4.074c-2.26-2.246-5.942-2.246-8.203 0l-.794.789A5.797 5.797 0 007.168 0Z' },
|
|
12
|
+
linkedin: { hex: '#0A66C2', d: 'M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z' },
|
|
10
13
|
mastodon: { hex: '#6364FF', d: 'M23.268 5.313c-.35-2.578-2.617-4.61-5.304-5.004C17.51.242 15.792 0 11.813 0h-.03c-3.98 0-4.835.242-5.288.309C3.882.692 1.496 2.518.917 5.127.64 6.412.61 7.837.661 9.143c.074 1.874.088 3.745.26 5.611.118 1.24.325 2.47.62 3.68.55 2.237 2.777 4.098 4.96 4.857 2.336.792 4.849.923 7.256.38.265-.061.527-.132.786-.213.585-.184 1.27-.39 1.774-.753a.057.057 0 0 0 .023-.043v-1.809a.052.052 0 0 0-.02-.041.053.053 0 0 0-.046-.01 20.282 20.282 0 0 1-4.709.545c-2.73 0-3.463-1.284-3.674-1.818a5.593 5.593 0 0 1-.319-1.433.053.053 0 0 1 .066-.054c1.517.363 3.072.546 4.632.546.376 0 .75 0 1.125-.01 1.57-.044 3.224-.124 4.768-.422.038-.008.077-.015.11-.024 2.435-.464 4.753-1.92 4.989-5.604.008-.145.03-1.52.03-1.67.002-.512.167-3.63-.024-5.545zm-3.748 9.195h-2.561V8.29c0-1.309-.55-1.976-1.67-1.976-1.23 0-1.846.79-1.846 2.35v3.403h-2.546V8.663c0-1.56-.617-2.35-1.848-2.35-1.112 0-1.668.668-1.67 1.977v6.218H4.822V8.102c0-1.31.337-2.35 1.011-3.12.696-.77 1.608-1.164 2.74-1.164 1.311 0 2.302.5 2.962 1.498l.638 1.06.638-1.06c.66-.999 1.65-1.498 2.96-1.498 1.13 0 2.043.395 2.74 1.164.675.77 1.012 1.81 1.012 3.12z' },
|
|
14
|
+
npm: { hex: '#CB3837', d: 'M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z' },
|
|
11
15
|
patreon: { hex: '#FF424D', d: 'M22.957 7.21c-.004-3.064-2.391-5.576-5.191-6.482-3.478-1.125-8.064-.962-11.384.604C2.357 3.231 1.093 7.391 1.046 11.54c-.039 3.411.302 12.396 5.369 12.46 3.765.047 4.326-4.804 6.068-7.141 1.24-1.662 2.836-2.132 4.801-2.618 3.376-.836 5.678-3.501 5.673-7.031Z' },
|
|
12
16
|
reddit: { hex: '#FF4500', d: 'M12 0C5.373 0 0 5.373 0 12c0 3.314 1.343 6.314 3.515 8.485l-2.286 2.286C.775 23.225 1.097 24 1.738 24H12c6.627 0 12-5.373 12-12S18.627 0 12 0Zm4.388 3.199c1.104 0 1.999.895 1.999 1.999 0 1.105-.895 2-1.999 2-.946 0-1.739-.657-1.947-1.539v.002c-1.147.162-2.032 1.15-2.032 2.341v.007c1.776.067 3.4.567 4.686 1.363.473-.363 1.064-.58 1.707-.58 1.547 0 2.802 1.254 2.802 2.802 0 1.117-.655 2.081-1.601 2.531-.088 3.256-3.637 5.876-7.997 5.876-4.361 0-7.905-2.617-7.998-5.87-.954-.447-1.614-1.415-1.614-2.538 0-1.548 1.255-2.802 2.803-2.802.645 0 1.239.218 1.712.585 1.275-.79 2.881-1.291 4.64-1.365v-.01c0-1.663 1.263-3.034 2.88-3.207.188-.911.993-1.595 1.959-1.595Zm-8.085 8.376c-.784 0-1.459.78-1.506 1.797-.047 1.016.64 1.429 1.426 1.429.786 0 1.371-.369 1.418-1.385.047-1.017-.553-1.841-1.338-1.841Zm7.406 0c-.786 0-1.385.824-1.338 1.841.047 1.017.634 1.385 1.418 1.385.785 0 1.473-.413 1.426-1.429-.046-1.017-.721-1.797-1.506-1.797Zm-3.703 4.013c-.974 0-1.907.048-2.77.135-.147.015-.241.168-.183.305.483 1.154 1.622 1.964 2.953 1.964 1.33 0 2.47-.81 2.953-1.964.057-.137-.037-.29-.184-.305-.863-.087-1.795-.135-2.769-.135Z' },
|
|
13
17
|
site: { hex: '#E9739A', d: 'M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z' },
|
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
// the drafts a review card was turned into: each
|
|
2
|
-
//
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
// the drafts a review card was turned into: each group whose `review` names one of the card's ids, read from the
|
|
2
|
+
// groups projection and their newest events (wiki tools/shipkit/social.md, Posts and their groups)
|
|
3
|
+
import { eventsRepo } from '../review/events.ts'
|
|
4
|
+
import { storeDir } from '../review/store.ts'
|
|
5
|
+
import { groupsNow } from './post-sources.ts'
|
|
6
6
|
|
|
7
7
|
export type CardDraft = { slug: string; title: string }
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/** the drafts whose `review:` is one of `ids`, oldest first */
|
|
9
|
+
/** the drafts whose `review` is one of `ids`, oldest first */
|
|
12
10
|
export function draftsOfCard(root: string, ids: ReadonlySet<string>): CardDraft[] {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const f = join(dir, slug, 'draft.md')
|
|
19
|
-
if (!existsSync(f)) continue
|
|
20
|
-
const head = /^---\n([\s\S]*?)\n---/.exec(readFileSync(f, 'utf8'))?.[1] ?? ''
|
|
21
|
-
if (ids.has(field(head, 'review'))) out.push({ slug, title: field(head, 'title') || slug })
|
|
22
|
-
}
|
|
23
|
-
return out
|
|
11
|
+
if (ids.size === 0) return []
|
|
12
|
+
return groupsNow(eventsRepo(storeDir(root)))
|
|
13
|
+
.filter((g) => ids.has(g.group.meta['review'] ?? ''))
|
|
14
|
+
.map((g) => ({ slug: g.group.slug, title: g.event.content.title || g.group.slug }))
|
|
15
|
+
.sort((a, b) => a.slug.localeCompare(b.slug))
|
|
24
16
|
}
|
package/src/social/desk-index.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
// the desk.json answer kept while nothing it is built from moved (wiki tools/shipkit/social.md, Routes). A stamp
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// and a page that holds the answer gets a 304.
|
|
5
|
-
//
|
|
1
|
+
// the desk.json answer kept while nothing it is built from moved (wiki tools/shipkit/social.md, Routes). A stamp says
|
|
2
|
+
// it: the newest write of the repo's posts and groups, the files of their copy, the social folder (its rhythm), the
|
|
3
|
+
// identities, the repo's config and social unit, and the day; HEAD moves the calendar alone. The desk is built, put on
|
|
4
|
+
// the wire and zipped once a stamp, and a page that holds the answer gets a 304. next-release.json is kept the same way,
|
|
5
|
+
// on next.md beside the parts
|
|
6
6
|
import { type Dirent, readdirSync, statSync } from 'node:fs'
|
|
7
|
-
import { join
|
|
7
|
+
import { join } from 'node:path'
|
|
8
|
+
import { cardsDb } from '../review/card-db.ts'
|
|
9
|
+
import { eventsRepo } from '../review/events.ts'
|
|
10
|
+
import { storeDir } from '../review/store.ts'
|
|
11
|
+
import { postMediaDir } from './post-sources.ts'
|
|
8
12
|
import { LAYOUT } from '../core/layout.ts'
|
|
9
13
|
import { headCommit } from '../core/git-root.ts'
|
|
10
14
|
import { unitFilesDeclaring } from '../core/unit-files.ts'
|
|
@@ -76,7 +80,7 @@ type Held = {
|
|
|
76
80
|
config?: Part<{ speaksAs: string | undefined; releases: boolean }>
|
|
77
81
|
ids?: Part<Identities>
|
|
78
82
|
unit?: Part<SocialUnit | null>
|
|
79
|
-
desk?: Part<Desk>
|
|
83
|
+
desk?: Part<Desk>
|
|
80
84
|
answer?: Answer
|
|
81
85
|
next?: Answer
|
|
82
86
|
}
|
|
@@ -104,22 +108,39 @@ async function partsOf(root: string) {
|
|
|
104
108
|
return { h, config: h.config, ids, unit, stamps: [configStamp, idsStamp, unitStamp] }
|
|
105
109
|
}
|
|
106
110
|
|
|
107
|
-
/** the
|
|
108
|
-
|
|
111
|
+
/** the newest write of the repo's posts and groups, and the files its copy holds: the database's part of the stamp */
|
|
112
|
+
function postsStamp(root: string): string {
|
|
113
|
+
const repo = eventsRepo(storeDir(root))
|
|
114
|
+
const db = cardsDb()
|
|
115
|
+
const g = db.query('select max(last_seq) as s from thread_post_groups where repo = ?').get(repo) as { s: number | null } | null
|
|
116
|
+
const p = db.query('select max(last_seq) as s from thread_posts where repo = ?').get(repo) as { s: number | null } | null
|
|
117
|
+
let shas: string[] = []
|
|
118
|
+
try {
|
|
119
|
+
shas = readdirSync(postMediaDir(root))
|
|
120
|
+
} catch {}
|
|
121
|
+
return `${g?.s ?? 0}.${p?.s ?? 0}.${shas.length}`
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** the desk of `root` as it stands, loaded again only when its posts, its rhythm or its parts moved */
|
|
125
|
+
async function heldDesk(root: string) {
|
|
109
126
|
const { h, config, ids, unit, stamps } = await partsOf(root)
|
|
110
127
|
const today = dayOf(Date.now())
|
|
111
128
|
const social = join(root, LAYOUT.social)
|
|
112
|
-
const folder: string[] = [today, ...stamps]
|
|
129
|
+
const folder: string[] = [today, ...stamps, postsStamp(root)]
|
|
113
130
|
tree(social, folder)
|
|
114
131
|
folder.push(stat(pushLog(root)))
|
|
115
|
-
for (const p of h.desk?.outside ?? []) folder.push(stat(p))
|
|
116
132
|
const deskStamp = stampOf(folder)
|
|
117
133
|
let desk = h.desk
|
|
118
134
|
if (desk?.stamp !== deskStamp) {
|
|
119
135
|
const value = loadDesk(root, ids.value, { speaksAs: config.value.speaksAs, unit: unit.value })
|
|
120
|
-
|
|
121
|
-
desk = h.desk = { stamp: deskStamp, value, outside }
|
|
136
|
+
desk = h.desk = { stamp: deskStamp, value }
|
|
122
137
|
}
|
|
138
|
+
return { h, unit, today, desk, deskStamp }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** the answer of `root` as it stands: rebuilt only for the parts whose stamp moved */
|
|
142
|
+
export async function deskWire(root: string): Promise<Answer> {
|
|
143
|
+
const { h, unit, today, desk, deskStamp } = await heldDesk(root)
|
|
123
144
|
|
|
124
145
|
const stamp = `${deskStamp}.${headCommit(root) ?? 'no head'}`
|
|
125
146
|
if (h.answer?.stamp === stamp) return h.answer
|
package/src/social/drafts.ts
CHANGED
|
@@ -8,8 +8,8 @@ import { parseFrontmatter } from './md.ts'
|
|
|
8
8
|
|
|
9
9
|
/** the headings a draft holds besides its platforms */
|
|
10
10
|
const OWN = ['Angle', 'Posted'] as const
|
|
11
|
-
const OPTIONS = ['name', 'place', 'title', 'media', 'rating', 'pin', 'embeds', 'outro', 'mark', 'tags', 'tier'] as const
|
|
12
|
-
type Option = (typeof OPTIONS)[number]
|
|
11
|
+
export const OPTIONS = ['name', 'place', 'title', 'media', 'rating', 'pin', 'embeds', 'outro', 'mark', 'tags', 'tier'] as const
|
|
12
|
+
export type Option = (typeof OPTIONS)[number]
|
|
13
13
|
/** the options whose value is one of a few words: a vertical's end and its watermark's corner, words a project reads;
|
|
14
14
|
* `embeds: none`, no preview card under its links */
|
|
15
15
|
const WORDS: Partial<Record<Option, readonly string[]>> = { outro: ['montage', 'short', 'none'], mark: ['left', 'right'], embeds: ['none'] }
|
|
@@ -19,9 +19,9 @@ const PLATFORM = /^([a-z0-9-]+)(?:\s*\((.*)\))?$/
|
|
|
19
19
|
const POSTED_LINE = /^- ([a-z0-9-]+(?:\/[a-z0-9-]+)?): (\S+)$/
|
|
20
20
|
|
|
21
21
|
/** `key` is the platform, or `<platform>/<name>` when the platform holds several messages */
|
|
22
|
-
type DraftSection = { platform: string; key: string; options: Partial<Record<Option, string>>; text: string }
|
|
22
|
+
export type DraftSection = { platform: string; key: string; options: Partial<Record<Option, string>>; text: string; /** the group heading a post was written under (`vertical`): its footer and its 9:16 check */ format?: string }
|
|
23
23
|
|
|
24
|
-
type ParsedDraft = {
|
|
24
|
+
export type ParsedDraft = {
|
|
25
25
|
meta: Record<string, string>
|
|
26
26
|
angle: string
|
|
27
27
|
sections: DraftSection[]
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
// the drafts folders imported as post groups and posts (wiki tools/shipkit/social.md, The verbs, the thread's block, the
|
|
2
|
+
// import): each folder read as a text by the desk's own builder, every file of it kept by its key (a file the Space holds
|
|
3
|
+
// already, purged from the disk, named by its key and never sent again), the group and its posts written as events with
|
|
4
|
+
// each posted link's moment as the timeline gave it, a thread made to refer to each new group; then the desk loaded from
|
|
5
|
+
// the database compared with the desk loaded from the folders, every draft and post field by field. Re-runnable: what
|
|
6
|
+
// did not move writes nothing. The one constraint a reader breaks first: it never writes in the folders
|
|
7
|
+
import { existsSync, readdirSync, readFileSync, statSync, type Dirent } from 'node:fs'
|
|
8
|
+
import { join } from 'node:path'
|
|
9
|
+
import type { Identities } from '../identities/identities.ts'
|
|
10
|
+
import type { Attachment } from '../review/events.ts'
|
|
11
|
+
import type { PostedFrom } from '../review/projections.ts'
|
|
12
|
+
import { typeOf } from '../media-store/content.ts'
|
|
13
|
+
import { confirmedUp } from '../media-store/remote.ts'
|
|
14
|
+
import { deskOf, DRAFT_NAME, draftsDir, loadDesk, type Desk, type Draft, type DraftSource, type Media } from './load.ts'
|
|
15
|
+
import { readFacts, socialKey } from './media-facts.ts'
|
|
16
|
+
import { groupNow, mediaOf } from './post-sources.ts'
|
|
17
|
+
import { postTime } from './post-url.ts'
|
|
18
|
+
import { groupThread, keepPostFile, linkGroup, versionThreadOf, writeText } from './posts.ts'
|
|
19
|
+
import { commitMoments } from './presence.ts'
|
|
20
|
+
import { textSource } from './post-text.ts'
|
|
21
|
+
import type { SocialUnit } from './unit.ts'
|
|
22
|
+
import type { ParsedDraft } from './drafts.ts'
|
|
23
|
+
|
|
24
|
+
/** the files of a draft folder an import keeps: every one but its texts and the dot files, by its path in the folder */
|
|
25
|
+
function folderFiles(dir: string, at = ''): string[] {
|
|
26
|
+
let list: Dirent[] = []
|
|
27
|
+
try {
|
|
28
|
+
list = readdirSync(join(dir, at), { withFileTypes: true })
|
|
29
|
+
} catch {
|
|
30
|
+
return []
|
|
31
|
+
}
|
|
32
|
+
return list.flatMap((e) => {
|
|
33
|
+
if (e.name.startsWith('.')) return []
|
|
34
|
+
const rel = at === '' ? e.name : `${at}/${e.name}`
|
|
35
|
+
if (e.isDirectory()) return folderFiles(dir, rel)
|
|
36
|
+
return e.isFile() && rel !== 'draft.md' && rel !== 'post.md' ? [rel] : []
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface FolderFile {
|
|
41
|
+
name: string
|
|
42
|
+
/** on the disk, else only in the Space under `key` */
|
|
43
|
+
local: boolean
|
|
44
|
+
path: string
|
|
45
|
+
key: string | null
|
|
46
|
+
sha: string | null
|
|
47
|
+
size: number
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** a folder as the import reads it: its text, its article, every file (the disk's, then the purged ones the old record
|
|
51
|
+
* keys), and the names its text gives that no file holds */
|
|
52
|
+
export interface Folder {
|
|
53
|
+
slug: string
|
|
54
|
+
raw: string
|
|
55
|
+
article: string | null
|
|
56
|
+
files: FolderFile[]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function readFolders(root: string): Folder[] {
|
|
60
|
+
const dir = draftsDir(root)
|
|
61
|
+
if (!existsSync(dir)) return []
|
|
62
|
+
const facts = readFacts(root)
|
|
63
|
+
const out: Folder[] = []
|
|
64
|
+
for (const slug of readdirSync(dir).sort().reverse()) {
|
|
65
|
+
const at = join(dir, slug)
|
|
66
|
+
if (!DRAFT_NAME.test(slug) || !existsSync(join(at, 'draft.md'))) continue
|
|
67
|
+
const files: FolderFile[] = folderFiles(at).map((name) => ({ name, local: true, path: join(at, name), key: null, sha: null, size: statSync(join(at, name)).size }))
|
|
68
|
+
for (const [id, f] of Object.entries(facts.files)) {
|
|
69
|
+
if (!id.startsWith(`${slug}/`)) continue
|
|
70
|
+
const name = id.slice(slug.length + 1)
|
|
71
|
+
if (files.some((x) => x.name === name)) continue
|
|
72
|
+
files.push({ name, local: false, path: join(at, name), key: socialKey(f, name), sha: f.sha, size: f.size })
|
|
73
|
+
}
|
|
74
|
+
out.push({ slug, raw: readFileSync(join(at, 'draft.md'), 'utf8'), article: existsSync(join(at, 'post.md')) ? readFileSync(join(at, 'post.md'), 'utf8') : null, files })
|
|
75
|
+
}
|
|
76
|
+
return out
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** the folders as the desk's builder reads them: the desk before the import */
|
|
80
|
+
export function folderDesk(root: string, ids: Identities, folders: readonly Folder[], o: { speaksAs?: string; unit?: SocialUnit | null }): { desk: Desk; parsed: Map<string, ParsedDraft> } {
|
|
81
|
+
const parsed = new Map<string, ParsedDraft>()
|
|
82
|
+
const sources: DraftSource[] = folders.map((f) => {
|
|
83
|
+
const seen: { parsed?: ParsedDraft } = {}
|
|
84
|
+
const media = new Map<string, Media>(f.files.map((x) => [x.name, { name: x.name, path: x.path }]))
|
|
85
|
+
const src = textSource(root, f.slug, f.raw, media, f.article, seen)
|
|
86
|
+
return { ...src, parse: (g) => (parsed.set(f.slug, src.parse(g)), parsed.get(f.slug)!) }
|
|
87
|
+
})
|
|
88
|
+
return { desk: deskOf(root, ids, sources, o), parsed }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface Imported {
|
|
92
|
+
root: string
|
|
93
|
+
groups: number
|
|
94
|
+
posts: Record<string, number>
|
|
95
|
+
files: { local: number; space: number; missing: number }
|
|
96
|
+
created: string[]
|
|
97
|
+
wrote: { groups: number; posts: number }
|
|
98
|
+
threads: number
|
|
99
|
+
differs: { slug: string; field: string; folder: unknown; db: unknown }[]
|
|
100
|
+
missing: string[]
|
|
101
|
+
/** the old media facts record: its entries, those of a folder imported, and the slugs of those of no folder (kept
|
|
102
|
+
* in the record and its backup, never imported: no group names them) */
|
|
103
|
+
facts: { entries: number; used: number; orphans: string[] }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** the import of one repo; `go` false writes nothing and says what it would */
|
|
107
|
+
export async function importRepo(root: string, ids: Identities, o: { speaksAs?: string; unit?: SocialUnit | null; go: boolean; sender?: string }): Promise<Imported> {
|
|
108
|
+
const folders = readFolders(root)
|
|
109
|
+
const { desk, parsed } = folderDesk(root, ids, folders, o)
|
|
110
|
+
const facts = Object.keys(readFacts(root).files)
|
|
111
|
+
const slugs = new Set(folders.map((f) => f.slug))
|
|
112
|
+
const factSlug = (id: string): string => id.slice(0, id.indexOf('/'))
|
|
113
|
+
const out: Imported = {
|
|
114
|
+
root,
|
|
115
|
+
groups: desk.drafts.length,
|
|
116
|
+
posts: { draft: 0, posted: 0, dropped: 0 },
|
|
117
|
+
files: { local: 0, space: 0, missing: 0 },
|
|
118
|
+
created: [],
|
|
119
|
+
wrote: { groups: 0, posts: 0 },
|
|
120
|
+
threads: 0,
|
|
121
|
+
differs: [],
|
|
122
|
+
missing: [],
|
|
123
|
+
facts: { entries: facts.length, used: facts.filter((id) => slugs.has(factSlug(id))).length, orphans: [...new Set(facts.map(factSlug).filter((s) => !slugs.has(s)))].sort() },
|
|
124
|
+
}
|
|
125
|
+
for (const d of desk.drafts) for (const p of d.posts) out.posts[p.posted !== '' ? 'posted' : p.dropped || d.status === 'rejected' ? 'dropped' : 'draft']!++
|
|
126
|
+
for (const f of folders) for (const x of f.files) out.files[x.local ? 'local' : 'space']++
|
|
127
|
+
const moments = commitMoments(desk, root)
|
|
128
|
+
for (const f of folders) {
|
|
129
|
+
const d = desk.drafts.find((x) => x.slug === f.slug)
|
|
130
|
+
const p = parsed.get(f.slug)
|
|
131
|
+
if (d == null || p == null) {
|
|
132
|
+
out.missing.push(f.slug)
|
|
133
|
+
continue
|
|
134
|
+
}
|
|
135
|
+
// a name the text gives that no file holds stays a name with no file: the load says so until one is given
|
|
136
|
+
const named = new Set([...(p.meta.media ?? '').split(','), ...p.sections.flatMap((s) => (s.options.media ?? '').split(','))].map((x) => x.trim()).filter((x) => x !== '' && x !== 'none'))
|
|
137
|
+
for (const n of named) if (!f.files.some((x) => x.name === n)) out.files.missing++
|
|
138
|
+
if (!o.go) continue
|
|
139
|
+
const attachments: Attachment[] = []
|
|
140
|
+
for (const x of f.files) {
|
|
141
|
+
if (x.local) attachments.push(await keepPostFile(root, x.path, x.name))
|
|
142
|
+
else {
|
|
143
|
+
if (!(await confirmedUp(x.key!, x.size))) throw new Error(`${f.slug}/${x.name}: neither on the disk nor in the Space (${x.key}): nothing of ${f.slug} written`)
|
|
144
|
+
attachments.push({ name: x.name, sha: x.sha!, size: x.size, type: typeOf(x.name), key: x.key! })
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const at = new Map<string, { at: number | null; from: PostedFrom }>()
|
|
148
|
+
for (const m of d.posts) {
|
|
149
|
+
if (m.posted === '') continue
|
|
150
|
+
const id = postTime(m.platform, m.posted)
|
|
151
|
+
const c = moments.get(m.posted)
|
|
152
|
+
at.set(m.key, id != null ? { at: id, from: 'id' } : c != null ? { at: c, from: 'commit' } : { at: null, from: 'unknown' })
|
|
153
|
+
}
|
|
154
|
+
// rule 5: the version it was staged from refers to it, else a thread made for it, linked in the write itself
|
|
155
|
+
const from = d.review ? versionThreadOf(root, d.review) : null
|
|
156
|
+
const fresh = groupNow(root, f.slug) == null
|
|
157
|
+
const attach = fresh ? [from ?? (await groupThread(root, f.slug, d.title))] : []
|
|
158
|
+
const w = writeText(root, { draft: d, parsed: p, attachments, article: f.article }, { why: 'import', sender: o.sender ?? 'machine', states: true, moments: at, attach })
|
|
159
|
+
if (w.group) out.wrote.groups++
|
|
160
|
+
out.wrote.posts += w.posts.length
|
|
161
|
+
if (w.created) out.created.push(f.slug)
|
|
162
|
+
out.threads += attach.length
|
|
163
|
+
if (!fresh && from != null && linkGroup(root, from, f.slug, d.title, 'machine')) out.threads++
|
|
164
|
+
}
|
|
165
|
+
if (o.go) out.differs = compareDesks(desk, loadDesk(root, ids, o))
|
|
166
|
+
return out
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** a draft's fields the desk shows, and each post's, as one comparable record */
|
|
170
|
+
function shapeOf(d: Draft): Record<string, unknown> {
|
|
171
|
+
return {
|
|
172
|
+
title: d.title,
|
|
173
|
+
identity: d.identity,
|
|
174
|
+
kind: d.kind,
|
|
175
|
+
kindWhy: d.kindWhy,
|
|
176
|
+
topics: d.topics,
|
|
177
|
+
slot: d.slot,
|
|
178
|
+
status: d.status,
|
|
179
|
+
angle: d.angle,
|
|
180
|
+
alt: d.alt,
|
|
181
|
+
rating: d.rating,
|
|
182
|
+
review: d.review,
|
|
183
|
+
release: d.release,
|
|
184
|
+
article: d.article == null ? null : { ...d.article, file: '' },
|
|
185
|
+
media: d.media.map((m) => m.name),
|
|
186
|
+
guard: d.guard,
|
|
187
|
+
dropped: [...(d.dropped ?? [])].sort(),
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function postShape(p: Draft['posts'][number]): Record<string, unknown> {
|
|
192
|
+
return {
|
|
193
|
+
platform: p.platform,
|
|
194
|
+
name: p.name,
|
|
195
|
+
posted: p.posted,
|
|
196
|
+
title: p.title,
|
|
197
|
+
text: p.text,
|
|
198
|
+
body: p.body,
|
|
199
|
+
tags: p.tags,
|
|
200
|
+
tier: p.tier,
|
|
201
|
+
reply: p.reply,
|
|
202
|
+
length: p.length,
|
|
203
|
+
media: p.media?.name ?? null,
|
|
204
|
+
alt: p.alt,
|
|
205
|
+
place: p.place,
|
|
206
|
+
href: p.href,
|
|
207
|
+
pin: p.pin,
|
|
208
|
+
embeds: p.embeds,
|
|
209
|
+
footer: p.footer,
|
|
210
|
+
rating: p.rating,
|
|
211
|
+
refused: p.refused.replace(/draft:\S+/g, ''),
|
|
212
|
+
dropped: p.dropped ?? false,
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** every draft and post the folders show against the database's, field by field; a file's bytes by its sha */
|
|
217
|
+
export function compareDesks(folder: Desk, db: Desk): Imported['differs'] {
|
|
218
|
+
const out: Imported['differs'] = []
|
|
219
|
+
for (const f of folder.drafts) {
|
|
220
|
+
const d = db.drafts.find((x) => x.slug === f.slug)
|
|
221
|
+
if (d == null) {
|
|
222
|
+
out.push({ slug: f.slug, field: 'draft', folder: 'a draft', db: null })
|
|
223
|
+
continue
|
|
224
|
+
}
|
|
225
|
+
const a = shapeOf(f)
|
|
226
|
+
const b = shapeOf(d)
|
|
227
|
+
for (const k of Object.keys(a)) if (JSON.stringify(a[k]) !== JSON.stringify(b[k])) out.push({ slug: f.slug, field: k, folder: a[k], db: b[k] })
|
|
228
|
+
const keys = [...new Set([...f.posts.map((p) => p.key), ...d.posts.map((p) => p.key)])]
|
|
229
|
+
for (const k of keys) {
|
|
230
|
+
const x = f.posts.find((p) => p.key === k)
|
|
231
|
+
const y = d.posts.find((p) => p.key === k)
|
|
232
|
+
if (x == null || y == null) {
|
|
233
|
+
out.push({ slug: f.slug, field: `post ${k}`, folder: x == null ? null : 'a post', db: y == null ? null : 'a post' })
|
|
234
|
+
continue
|
|
235
|
+
}
|
|
236
|
+
const px = postShape(x)
|
|
237
|
+
const py = postShape(y)
|
|
238
|
+
for (const field of Object.keys(px)) if (JSON.stringify(px[field]) !== JSON.stringify(py[field])) out.push({ slug: f.slug, field: `${k}.${field}`, folder: px[field], db: py[field] })
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return out
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export { mediaOf }
|
package/src/social/kind-pages.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// ones' pages in the house wiki beside the house's identities folder, the project's in the repo. The desk links each
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs'
|
|
4
4
|
import { join } from 'node:path'
|
|
5
|
-
import {
|
|
5
|
+
import { HOUSE_LAYOUT } from '../core/house-layout.ts'
|
|
6
6
|
import { KIND_FOR, kindPage, POST_KINDS, type OwnKind } from './kinds.ts'
|
|
7
7
|
|
|
8
8
|
/** a kind as the desk lists it: `page` its rules page, absolute, and `title` what that page's heading says it is for;
|
|
@@ -11,8 +11,8 @@ export type DeskKind = { id: string; for: string; own: boolean; page: string | n
|
|
|
11
11
|
|
|
12
12
|
/** the house wiki, from the identities folder the desk read: `<house>/wiki`; null outside a house */
|
|
13
13
|
function houseWiki(identitiesDir: string | null): string | null {
|
|
14
|
-
if (identitiesDir == null || !identitiesDir.endsWith(
|
|
15
|
-
const wiki = join(identitiesDir.slice(0, -
|
|
14
|
+
if (identitiesDir == null || !identitiesDir.endsWith(HOUSE_LAYOUT.identities)) return null
|
|
15
|
+
const wiki = join(identitiesDir.slice(0, -HOUSE_LAYOUT.identities.length), HOUSE_LAYOUT.wiki)
|
|
16
16
|
return existsSync(wiki) ? wiki : null
|
|
17
17
|
}
|
|
18
18
|
|
package/src/social/kinds.ts
CHANGED
|
@@ -70,7 +70,7 @@ export function kindProblem(kind: string, why: string, own: readonly Pick<OwnKin
|
|
|
70
70
|
const to = OLD_KINDS[k]
|
|
71
71
|
return to == null
|
|
72
72
|
? { text: `kind "${k}" is an old word and no post kind: a text that stays on a venue is a profile row of the identity (wiki tools/shipkit/social-identities.md)`, old: true }
|
|
73
|
-
: { text: `kind "${k}" is an old word: ${to} by default, or the kind its intent reads as (
|
|
73
|
+
: { text: `kind "${k}" is an old word: ${to} by default, or the kind its intent reads as (wiki guides/post-kinds/old-words.md)`, old: true }
|
|
74
74
|
}
|
|
75
75
|
return { text: `kind "${k}" is not one of ${set}: a project's own kind is declared in its social unit's kinds (${INDEX})`, old: false }
|
|
76
76
|
}
|