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