rvlib-shipkit 2.26.0 → 2.27.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 +20 -0
- package/package.json +1 -1
- package/src/agent-time/diet.ts +77 -0
- package/src/agent-time/family.ts +72 -0
- package/src/agent-time/hooks.ts +6 -4
- package/src/agent-time/limits.ts +44 -0
- package/src/agent-time/live.ts +1 -3
- package/src/agent-time/mask.ts +96 -18
- package/src/agent-time/refused.ts +45 -0
- package/src/agent-time/render.ts +122 -21
- package/src/agent-time/report-cache.ts +57 -0
- package/src/agent-time/report.ts +314 -40
- package/src/agent-time/shape.ts +50 -3
- package/src/agent-time/store.ts +320 -99
- package/src/agent-time/timeline.ts +140 -21
- package/src/agent-time/turns.ts +18 -8
- package/src/annex/offload.ts +17 -6
- package/src/annex/tidy.ts +70 -10
- package/src/asks/ask-after.ts +40 -0
- package/src/asks/asks-queue.ts +205 -47
- package/src/assets/kit-config.ts +7 -3
- package/src/assets/kits/identity-kit.ts +289 -10
- package/src/check.ts +3 -1
- package/src/checks/SK004-gitignore-policy.check.ts +12 -5
- package/src/checks/SK013-one-way-in-policy.check.ts +8 -3
- package/src/checks/SK026-asks-autoclose.check.ts +5 -5
- package/src/checks/SK028-readme.check.ts +7 -66
- package/src/checks/SK030-cache-audit.check.ts +6 -1
- package/src/checks/SK031-trace-audit.check.ts +2 -0
- package/src/checks/SK033-global-contribution.check.ts +3 -1
- package/src/checks/SK035-public-clean.check.ts +2 -2
- package/src/checks/SK043-scratch-on-the-mac.check.ts +59 -4
- package/src/checks/SK047-login-in-description.check.ts +36 -0
- package/src/checks/SK048-one-local-file.check.ts +36 -0
- package/src/cli/cmd_Asks.ts +71 -5
- package/src/cli/cmd_Backup.ts +2 -2
- package/src/cli/cmd_Capacity.ts +2 -2
- package/src/cli/cmd_CrossRepoActivity.ts +5 -4
- package/src/cli/cmd_Db.ts +253 -0
- package/src/cli/cmd_History.ts +212 -0
- package/src/cli/cmd_Home.ts +31 -3
- package/src/cli/cmd_Hq.ts +516 -0
- package/src/cli/cmd_Machines.ts +36 -0
- package/src/cli/cmd_Media.ts +38 -6
- package/src/cli/cmd_Reflect.ts +23 -2
- package/src/cli/cmd_Review.ts +548 -116
- package/src/cli/cmd_Secret.ts +62 -12
- package/src/cli/cmd_Social.ts +83 -1
- package/src/cli/cmd_Space.ts +324 -0
- package/src/cli/cmd_Time.ts +76 -5
- package/src/cli/cmd_Tmp.ts +28 -4
- package/src/cli/cmd_Trailer.ts +14 -10
- package/src/cli/cmd_Urls.ts +56 -0
- package/src/cli/cmd_Vault.ts +583 -0
- package/src/cli/family-help.ts +4 -2
- package/src/cli/family-pages.ts +1 -1
- package/src/cli/registry.ts +24 -3
- package/src/collections/actions.ts +63 -13
- package/src/collections/collection-types.ts +23 -1
- package/src/collections/providers.ts +117 -23
- package/src/collections/review.ts +4 -4
- package/src/contracts/contract-manifests.ts +6 -5
- package/src/contracts/contract-types.ts +6 -4
- package/src/contracts/contracts-engine.ts +11 -0
- package/src/contracts/manifests/chrome-web-store.contract.ts +31 -0
- package/src/core/budget.ts +12 -17
- package/src/core/capacity.ts +27 -18
- package/src/core/check-runner.ts +7 -4
- package/src/core/layout.ts +3 -0
- package/src/core/machine-busy.ts +127 -0
- package/src/core/machine-commit.ts +6 -1
- package/src/core/machine-db.ts +368 -20
- package/src/core/machine-layout.ts +137 -0
- package/src/core/machine-read.ts +81 -0
- package/src/core/migrate-layout.ts +1 -1
- package/src/core/one-way-in-policy.ts +64 -7
- package/src/core/polling-policy.ts +27 -0
- package/src/core/retention.ts +16 -2
- package/src/core/scope.ts +107 -14
- package/src/core/slots.ts +5 -4
- package/src/drill/clean.ts +25 -1
- package/src/drill/run.ts +1 -1
- package/src/drill/seal.ts +27 -4
- package/src/home/activity-shape.ts +2 -0
- package/src/home/activity.ts +66 -3
- package/src/home/app-sign.ts +15 -4
- package/src/home/daemon-jobs.ts +149 -7
- package/src/home/database-projects.ts +111 -0
- package/src/home/database-words.ts +203 -0
- package/src/home/databases.ts +460 -0
- package/src/home/global-units.ts +6 -0
- package/src/home/gui-app/ShipkitGui.swift +122 -1
- package/src/home/gui-app.ts +6 -3
- package/src/home/home-move.ts +514 -0
- package/src/home/home-paths.ts +12 -3
- package/src/home/home-routes.ts +68 -0
- package/src/home/inbox-shape.ts +24 -14
- package/src/home/machine-fold.ts +820 -0
- package/src/home/machine-host.ts +20 -5
- package/src/home/machine-repair.ts +503 -0
- package/src/home/machine-stores.ts +66 -15
- package/src/home/machine-temp.ts +547 -86
- package/src/home/resume.ts +79 -0
- package/src/home/run-daemon.ts +25 -4
- package/src/home/run-pm.ts +18 -5
- package/src/home/serve-daemon.ts +18 -3
- package/src/home/serve-web.ts +175 -7
- package/src/home/space-job.ts +115 -0
- package/src/home/space-page.ts +257 -0
- package/src/home/space-route.ts +167 -0
- package/src/home/space-words.ts +103 -0
- package/src/home/time-page-shape.ts +202 -0
- package/src/home/time-page.ts +64 -0
- package/src/home/vault-page.ts +482 -0
- package/src/home/vault-words.ts +132 -0
- package/src/hooks/leak-guard.ts +40 -13
- package/src/hooks/one-way-in-guard.ts +17 -4
- package/src/hq/cards.ts +581 -0
- package/src/hq/door-route.ts +43 -0
- package/src/hq/door.ts +163 -0
- package/src/hq/files-send.ts +348 -0
- package/src/hq/forgotten-log.ts +35 -0
- package/src/hq/history-check.ts +255 -0
- package/src/hq/history-place.ts +146 -0
- package/src/hq/history-send.ts +487 -0
- package/src/hq/hq-db.ts +99 -0
- package/src/hq/hq-local.ts +469 -0
- package/src/hq/hq-routes.ts +196 -0
- package/src/hq/hq-store.ts +599 -0
- package/src/hq/kinds/ask.ts +147 -0
- package/src/hq/kinds/card-gone.ts +83 -0
- package/src/hq/kinds/card-msg.ts +66 -0
- package/src/hq/kinds/card.ts +99 -0
- package/src/hq/kinds/index.ts +21 -0
- package/src/hq/kinds/kind.ts +126 -0
- package/src/hq/kinds/media.ts +125 -0
- package/src/hq/kinds/prompt.ts +219 -0
- package/src/hq/kinds/reflection.ts +128 -0
- package/src/hq/kinds/report.ts +55 -0
- package/src/hq/kinds/time-day.ts +236 -0
- package/src/hq/ledger.ts +473 -0
- package/src/hq/machine-key.ts +44 -0
- package/src/hq/machine-notes.ts +131 -0
- package/src/hq/outbox.ts +372 -0
- package/src/hq/replica.ts +168 -0
- package/src/hq/repo-id.ts +4 -0
- package/src/hq/report-facts.ts +117 -0
- package/src/hq/report.ts +274 -0
- package/src/hq/switch.ts +151 -0
- package/src/hq/vault-grant.ts +92 -0
- package/src/identities/identities.ts +15 -3
- package/src/identities/steps.ts +31 -0
- package/src/ledger/db.ts +73 -26
- package/src/ledger/gate-checks.ts +6 -2
- package/src/ledger/run-log.ts +11 -3
- package/src/ledger/store.ts +26 -4
- package/src/media-store/backup/daemon.ts +25 -17
- package/src/media-store/backup/kept.ts +241 -0
- package/src/media-store/backup/restore.ts +14 -4
- package/src/media-store/backup/run.ts +11 -11
- package/src/media-store/backup/secret.ts +6 -4
- package/src/media-store/backup/snapshot.ts +4 -2
- package/src/media-store/backup/sources.ts +67 -16
- package/src/media-store/copy/config.ts +77 -0
- package/src/media-store/copy/copy.ts +194 -0
- package/src/media-store/copy/lifecycle.ts +43 -0
- package/src/media-store/copy/night.ts +90 -0
- package/src/media-store/copy/proof.ts +151 -0
- package/src/media-store/copy/snapshot.ts +152 -0
- package/src/media-store/copy/store.ts +62 -0
- package/src/media-store/copy/stream.ts +176 -0
- package/src/media-store/daemon.ts +66 -16
- package/src/media-store/db.ts +22 -11
- package/src/media-store/forget.ts +23 -3
- package/src/media-store/hand.ts +4 -3
- package/src/media-store/hq-find.ts +75 -0
- package/src/media-store/hq-send.ts +277 -0
- package/src/media-store/kind.ts +2 -0
- package/src/media-store/purge.ts +18 -15
- package/src/media-store/put.ts +24 -8
- package/src/media-store/remote.ts +16 -7
- package/src/media-store/space-listing.ts +240 -0
- package/src/media-store/space.ts +40 -21
- package/src/media-store/sync.ts +5 -5
- package/src/media-store/tidy.ts +98 -0
- package/src/media-store/upload.ts +3 -3
- package/src/media-store/webp.ts +66 -0
- package/src/messages/model.ts +16 -7
- package/src/messages/routes.ts +14 -4
- package/src/messages/score.ts +2 -2
- package/src/messages/suggest.ts +96 -0
- package/src/pages/frame-client.ts +10 -0
- package/src/plan/planner.ts +28 -17
- package/src/recordings/media-kind.ts +1 -0
- package/src/recordings/model.ts +1 -1
- package/src/recordings/recorder-app/Capture.swift +9 -7
- package/src/reflect/hq-corpus.ts +56 -0
- package/src/reflect/prompt-corpus.ts +3 -1
- package/src/reflect/transcript.ts +129 -37
- package/src/release/machine-words.ts +67 -0
- package/src/release/public-clean.ts +8 -3
- package/src/releases/from-card.ts +1 -1
- package/src/releases/routes.ts +10 -5
- package/src/releases/store.ts +10 -1
- package/src/repo-config.ts +32 -2
- package/src/review/anim.ts +2 -2
- package/src/review/auto.ts +2 -2
- package/src/review/card-db.ts +244 -0
- package/src/review/card-rows.ts +266 -0
- package/src/review/cells.ts +76 -5
- package/src/review/draft-card.ts +41 -0
- package/src/review/draft-model.ts +78 -0
- package/src/review/format.ts +29 -10
- package/src/review/gone.ts +98 -0
- package/src/review/inbox-hook.ts +4 -4
- package/src/review/marks.ts +1 -1
- package/src/review/media-kind.ts +7 -5
- package/src/review/media-read.ts +9 -7
- package/src/review/media.ts +32 -5
- package/src/review/model.ts +202 -39
- package/src/review/move.ts +491 -0
- package/src/review/notes.ts +12 -20
- package/src/review/previews.ts +15 -19
- package/src/review/project.ts +1 -1
- package/src/review/rev.ts +8 -0
- package/src/review/role.ts +1 -1
- package/src/review/routes.ts +64 -13
- package/src/review/stage-card.ts +8 -4
- package/src/review/stage-routes.ts +1 -1
- package/src/review/store.ts +529 -83
- package/src/review/thread-fold.ts +51 -0
- package/src/review/threads.ts +147 -9
- package/src/review/trailer-auto-mock.ts +63 -0
- package/src/review/trailer-card.ts +4 -4
- package/src/review/trailer-desk.ts +41 -7
- package/src/review/trailer-media.ts +1 -0
- package/src/review/trailer-model.ts +8 -0
- package/src/review/trailer-notes.ts +1 -1
- package/src/review/trailer-routes.ts +9 -1
- package/src/review/unit.ts +6 -6
- package/src/review/watchers.ts +1 -1
- package/src/rules/untrack-generated.ts +92 -8
- package/src/secrets/held.ts +16 -0
- package/src/secrets/keychain.ts +113 -0
- package/src/secrets/list.ts +16 -6
- package/src/secrets/manager.ts +24 -10
- package/src/secrets/read.ts +257 -0
- package/src/secrets/who-reads.ts +49 -0
- package/src/serve/door-forward.ts +268 -0
- package/src/serve/door-names.ts +47 -0
- package/src/serve/embed.ts +1 -1
- package/src/serve/hub-app/activity-view.tsx +56 -32
- package/src/serve/hub-app/activity.css +7 -1
- package/src/serve/hub-app/asks-page.tsx +48 -0
- package/src/serve/hub-app/asks-st.ts +25 -0
- package/src/serve/hub-app/clock-svc.ts +1 -2
- package/src/serve/hub-app/col-card.tsx +64 -13
- package/src/serve/hub-app/col-list-page.tsx +122 -0
- package/src/serve/hub-app/col-list-st.ts +103 -0
- package/src/serve/hub-app/col-tables-view.tsx +10 -41
- package/src/serve/hub-app/col-tables.ts +76 -8
- package/src/serve/hub-app/cols-svc.ts +70 -16
- package/src/serve/hub-app/database-st.ts +260 -0
- package/src/serve/hub-app/database-view.tsx +289 -0
- package/src/serve/hub-app/database.css +32 -0
- package/src/serve/hub-app/entry-bar.css +14 -0
- package/src/serve/hub-app/entry-bar.tsx +33 -0
- package/src/serve/hub-app/entry-pick.ts +31 -0
- package/src/serve/hub-app/floating.tsx +1 -0
- package/src/serve/hub-app/hash-route.ts +11 -1
- package/src/serve/hub-app/header-bar.tsx +14 -18
- package/src/serve/hub-app/home-st.ts +89 -9
- package/src/serve/hub-app/home-strip.css +5 -19
- package/src/serve/hub-app/home-strip.tsx +58 -92
- package/src/serve/hub-app/home.html +7 -0
- package/src/serve/hub-app/hub-app.tsx +31 -142
- package/src/serve/hub-app/hub-types.ts +3 -1
- package/src/serve/hub-app/hub.css +109 -23
- package/src/serve/hub-app/icons.tsx +18 -1
- package/src/serve/hub-app/identities-st.ts +56 -6
- package/src/serve/hub-app/identities-view.tsx +100 -58
- package/src/serve/hub-app/identities.css +17 -15
- package/src/serve/hub-app/identity-address.ts +5 -0
- package/src/serve/hub-app/inbox-st.ts +41 -24
- package/src/serve/hub-app/inbox-view.tsx +37 -41
- package/src/serve/hub-app/inbox.css +2 -5
- package/src/serve/hub-app/index.html +7 -0
- package/src/serve/hub-app/kept-cols.tsx +7 -0
- package/src/serve/hub-app/keys.ts +28 -15
- package/src/serve/hub-app/later.tsx +26 -0
- package/src/serve/hub-app/list-filter.tsx +14 -0
- package/src/serve/hub-app/list-walk.ts +72 -3
- package/src/serve/hub-app/machines-st.ts +251 -0
- package/src/serve/hub-app/machines-view.tsx +224 -0
- package/src/serve/hub-app/machines.css +76 -0
- package/src/serve/hub-app/md-copy.tsx +79 -0
- package/src/serve/hub-app/media-view.tsx +2 -0
- package/src/serve/hub-app/messages/messages-page.tsx +79 -7
- package/src/serve/hub-app/messages/messages-st.ts +99 -3
- package/src/serve/hub-app/messages.css +14 -0
- package/src/serve/hub-app/page-keys.ts +175 -0
- package/src/serve/hub-app/pages-frames.tsx +11 -3
- package/src/serve/hub-app/palette-st.ts +58 -11
- package/src/serve/hub-app/palette-view.tsx +3 -1
- package/src/serve/hub-app/project-list.css +54 -8
- package/src/serve/hub-app/project-list.tsx +128 -59
- package/src/serve/hub-app/projects-svc.ts +78 -7
- package/src/serve/hub-app/reader-chips.tsx +13 -0
- package/src/serve/hub-app/readme-view.tsx +2 -3
- package/src/serve/hub-app/readme.css +27 -5
- package/src/serve/hub-app/reflections-page.tsx +42 -0
- package/src/serve/hub-app/reflections-st.ts +17 -0
- package/src/serve/hub-app/releases/releases-page.tsx +25 -2
- package/src/serve/hub-app/releases/releases-st.ts +1 -1
- package/src/serve/hub-app/repo-sections.ts +9 -5
- package/src/serve/hub-app/repo-st.ts +35 -8
- package/src/serve/hub-app/review/draft-card.tsx +163 -0
- package/src/serve/hub-app/review/kit.tsx +50 -7
- package/src/serve/hub-app/review/note-place.ts +1 -1
- package/src/serve/hub-app/review/review-board.tsx +2 -2
- package/src/serve/hub-app/review/review-cells.tsx +145 -65
- package/src/serve/hub-app/review/review-kit.ts +27 -1
- package/src/serve/hub-app/review/review-list.tsx +68 -30
- package/src/serve/hub-app/review/review-page.tsx +7 -8
- package/src/serve/hub-app/review/review-st.ts +111 -24
- package/src/serve/hub-app/review/review-thread.tsx +49 -19
- package/src/serve/hub-app/review/review-views.tsx +475 -144
- package/src/serve/hub-app/review/thread-control-st.ts +115 -0
- package/src/serve/hub-app/review/thread-control.tsx +74 -0
- package/src/serve/hub-app/review/thread-st.ts +73 -26
- package/src/serve/hub-app/review/trailer-card.tsx +1 -1
- package/src/serve/hub-app/review/trailer-page.tsx +37 -16
- package/src/serve/hub-app/review/trailer-st.ts +41 -7
- package/src/serve/hub-app/review.css +267 -61
- package/src/serve/hub-app/side-lists.ts +72 -0
- package/src/serve/hub-app/sidebar.tsx +6 -3
- package/src/serve/hub-app/site/site-part.tsx +2 -8
- package/src/serve/hub-app/site/site-st.ts +4 -4
- package/src/serve/hub-app/social/comms-page.tsx +20 -5
- package/src/serve/hub-app/social/kit.tsx +30 -4
- package/src/serve/hub-app/social/post-card.tsx +139 -49
- package/src/serve/hub-app/social/serial-writes.ts +13 -0
- package/src/serve/hub-app/social/social-model.ts +11 -0
- package/src/serve/hub-app/social/social-page.tsx +94 -35
- package/src/serve/hub-app/social/social-st.ts +120 -36
- package/src/serve/hub-app/social/stage-popup.tsx +1 -1
- package/src/serve/hub-app/social/stage-st.ts +1 -1
- package/src/serve/hub-app/social/step-layout.ts +1 -1
- package/src/serve/hub-app/social.css +3 -0
- package/src/serve/hub-app/space-st.ts +209 -0
- package/src/serve/hub-app/space-view.tsx +196 -0
- package/src/serve/hub-app/space.css +27 -0
- package/src/serve/hub-app/stores/stores-page.tsx +91 -23
- package/src/serve/hub-app/stores/stores-st.ts +44 -19
- package/src/serve/hub-app/stores.css +6 -1
- package/src/serve/hub-app/theme-st.ts +22 -9
- package/src/serve/hub-app/time-charts.tsx +291 -0
- package/src/serve/hub-app/time-pages.tsx +749 -0
- package/src/serve/hub-app/time-st.ts +162 -0
- package/src/serve/hub-app/time-view.tsx +76 -0
- package/src/serve/hub-app/time.css +138 -0
- package/src/serve/hub-app/tree-build.ts +52 -42
- package/src/serve/hub-app/tree-row.tsx +4 -4
- package/src/serve/hub-app/tree-svc.ts +18 -9
- package/src/serve/hub-app/urls-svc.ts +154 -0
- package/src/serve/hub-app/urls-view.tsx +117 -0
- package/src/serve/hub-app/urls.css +30 -0
- package/src/serve/hub-app/vault-st.ts +127 -0
- package/src/serve/hub-app/vault-view.tsx +154 -0
- package/src/serve/hub-app/vault.css +38 -0
- package/src/serve/hub-app/veille/veille-st.ts +12 -10
- package/src/serve/hub-app/waiting-svc.ts +29 -0
- package/src/serve/hub-app/wikis-view.tsx +2 -2
- package/src/serve/hub-runtime.ts +15 -2
- package/src/serve/project-gutter-route.ts +27 -14
- package/src/serve/project-gutter.ts +25 -12
- package/src/serve/same-origin.ts +10 -0
- package/src/serve/serve-hub.ts +13 -4
- package/src/shipkit-files.ts +16 -2
- package/src/shipkit.ts +1 -1
- package/src/shot/shooter.ts +616 -420
- package/src/shot/shot-ask.ts +246 -155
- package/src/site/desk.ts +2 -2
- package/src/smoke/run-smoke.ts +3 -2
- package/src/social/cover.ts +202 -0
- package/src/social/discord-layout.ts +37 -13
- package/src/social/drafts.ts +3 -0
- package/src/social/load.ts +23 -2
- package/src/social/media-kind.ts +2 -1
- package/src/social/publish/discord.ts +5 -2
- package/src/social/publish/secret.ts +2 -2
- package/src/social/release-stage.ts +28 -13
- package/src/social/routes.ts +26 -1
- package/src/social/stage.ts +1 -1
- package/src/social/stats.ts +12 -9
- package/src/social/strip.ts +4 -1
- package/src/social/thumbnail.ts +255 -0
- package/src/stores/collection.ts +15 -11
- package/src/stores/desk.ts +236 -42
- package/src/stores/model.ts +72 -6
- package/src/stores/routes.ts +37 -12
- package/src/stores/unit.ts +14 -8
- package/src/suite/judge-suites.ts +41 -11
- package/src/suite/select.ts +45 -3
- package/src/suite/suite-cli.ts +16 -10
- package/src/trailer/bed.ts +1 -1
- package/src/trailer/build.ts +134 -21
- package/src/trailer/ffmpeg.ts +7 -0
- package/src/trailer/fonts.ts +3 -2
- package/src/trailer/grammar.ts +201 -2
- package/src/trailer/graph.ts +42 -5
- package/src/trailer/look.ts +21 -0
- package/src/trailer/mock.ts +154 -0
- package/src/trailer/passage.ts +65 -26
- package/src/trailer/score/heard.ts +89 -0
- package/src/trailer/score/sound.ts +14 -8
- package/src/trailer/sound/run.ts +16 -6
- package/src/trailer/stitch.ts +26 -5
- package/src/trailer/titles.ts +82 -19
- package/src/trailer/versions.ts +1 -3
- package/src/trailer/vertical.ts +3 -1
- package/src/urls/frame.ts +195 -0
- package/src/urls/routes.ts +43 -0
- package/src/urls/rows.ts +171 -0
- package/src/urls/unit.ts +73 -0
- package/src/vault/house-keys.ts +42 -0
- package/src/vault/layout.ts +50 -0
- package/src/vault/policy.ts +165 -0
- package/src/vault/vault-audit.ts +276 -0
- package/src/vault/vault-client.ts +40 -0
- package/src/vault/vault-config.ts +159 -0
- package/src/vault/vault-destroy.ts +78 -0
- package/src/vault/vault-handover.ts +305 -0
- package/src/vault/vault-http.ts +352 -0
- package/src/vault/vault-import.ts +208 -0
- package/src/vault/vault-init.ts +328 -0
- package/src/vault/vault-minter.ts +271 -0
- package/src/vault/vault-restore.ts +333 -0
- package/src/vault/vault-serve.ts +342 -0
- package/src/vault/vault-snapshot.ts +281 -0
- package/src/veille/asks.ts +1 -1
- package/src/veille/desk.ts +2 -2
package/src/cli/cmd_Secret.ts
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
// Logic in secrets/list.ts and secrets/manager.ts. A value only ever goes to stdout of `get`/`account`,
|
|
4
4
|
// and only for a repo in the name's scope.
|
|
5
5
|
import { Command, Option } from 'clipanion'
|
|
6
|
-
import { homedir } from 'os'
|
|
6
|
+
import { homedir, userInfo } from 'os'
|
|
7
|
+
import { createInterface } from 'readline'
|
|
7
8
|
import { relative } from 'path'
|
|
8
9
|
import { houseRootOf } from '../home/home-start.ts'
|
|
9
10
|
import { presence, secretsFor } from '../secrets/list.ts'
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
11
|
+
import { scopeHouse } from '../secrets/who-reads.ts'
|
|
12
|
+
import { houseScopeOf, managerTemplate as template, NoManager, readRefusal, redact, REFUSED_EXIT, secretsWhere as where, storeArgv } from '../secrets/manager.ts'
|
|
13
|
+
import { readSecretHere, vaultHere, writeSecretHere } from '../secrets/read.ts'
|
|
12
14
|
|
|
13
15
|
/** runs a verb, printing a refusal as its one line */
|
|
14
16
|
async function refusing(stderr: NodeJS.WritableStream, run: () => Promise<number>): Promise<number> {
|
|
@@ -45,7 +47,8 @@ export class SecretListCommand extends Command {
|
|
|
45
47
|
const w = await where(process.cwd())
|
|
46
48
|
// in the house repo its own creds ARE the registry, each row with the scope it declares
|
|
47
49
|
const inHouse = w.house != null && w.house === w.own
|
|
48
|
-
const
|
|
50
|
+
const scopes = this.json ? undefined : await scopeHouse(process.cwd(), { keys: (w.house?.creds ?? []).some((c) => (c.for?.repos ?? []).some((r) => r.includes('/'))) }).catch(() => undefined)
|
|
51
|
+
const rows = secretsFor({ asker: w, own: inHouse ? [] : (w.own?.creds ?? []), house: w.house?.creds ?? [], all: this.all, scopes })
|
|
49
52
|
if (this.json) {
|
|
50
53
|
this.context.stdout.write(`${JSON.stringify(rows)}\n`)
|
|
51
54
|
return 0
|
|
@@ -54,14 +57,18 @@ export class SecretListCommand extends Command {
|
|
|
54
57
|
const say = (l: string): void => void this.context.stdout.write(`${l}\n`)
|
|
55
58
|
const mine = rows.filter((r) => r.mine).length
|
|
56
59
|
say(`${w.repos[0]} speaks as ${w.identity ?? 'no identity'}: ${rows.filter((r) => r.inScope).length} secrets, ${mine} for this repo or identity`)
|
|
57
|
-
const pad = (k: 'name' | '
|
|
60
|
+
const pad = (k: 'name' | 'service'): number => Math.max(k.length, ...rows.map((r) => (r[k] ?? '').slice(0, 40).length))
|
|
58
61
|
if ([...has.values()].includes('locked')) say(`LOCK: there, in a keychain locked to this session (an ssh session sees it so): \`security unlock-keychain\` in it to read them`)
|
|
62
|
+
const line = (mark: string, name: string, level: string, service: string, who: string): string =>
|
|
63
|
+
`${mark} ${name.padEnd(pad('name'))} ${level.padEnd(5)} ${service.slice(0, 40).padEnd(pad('service'))} ${who}`
|
|
64
|
+
if (rows.length > 0) say(line(' ', 'name', 'level', 'service', 'who can read it'))
|
|
59
65
|
for (const r of rows) {
|
|
60
66
|
const p = has.get(r.name)
|
|
61
67
|
const mark = !r.inScope ? 'out ' : p === 'ok' ? 'ok ' : p === 'locked' ? 'LOCK' : 'MISS'
|
|
62
68
|
const fix = p === 'missing' ? ` → sk secret set ${r.name}` : ''
|
|
63
|
-
say(`${mark
|
|
69
|
+
say(`${line(mark, r.name, r.level, r.service ?? '', r.who)}${fix}`)
|
|
64
70
|
}
|
|
71
|
+
if (rows.some((r) => /\?(,|$)/.test(r.who))) say('a repo with ? is one this machine does not have; --json gives each scope in a sentence')
|
|
65
72
|
return 0
|
|
66
73
|
}
|
|
67
74
|
}
|
|
@@ -87,18 +94,40 @@ export class SecretReadCommand extends Command {
|
|
|
87
94
|
this.context.stderr.write(`${refused}\n`)
|
|
88
95
|
return REFUSED_EXIT
|
|
89
96
|
}
|
|
90
|
-
const
|
|
91
|
-
|
|
97
|
+
const r = await readSecretHere({ name: this.name, field, cwd: process.cwd(), w, say: (l) => void this.context.stderr.write(`${l}\n`) })
|
|
98
|
+
if ('value' in r) {
|
|
99
|
+
this.context.stdout.write(`${r.value}\n`)
|
|
100
|
+
return 0
|
|
101
|
+
}
|
|
102
|
+
this.context.stderr.write(`${'refused' in r ? r.refused : `FAIL ${r.missing}`}\n`)
|
|
103
|
+
return 'refused' in r ? REFUSED_EXIT : 1
|
|
92
104
|
})
|
|
93
105
|
}
|
|
94
106
|
}
|
|
95
107
|
|
|
108
|
+
/** the value, typed with no echo at a terminal, else stdin whole, its last line breaks dropped */
|
|
109
|
+
async function readValue(name: string): Promise<string> {
|
|
110
|
+
if (process.stdin.isTTY !== true) return (await Bun.stdin.text()).replace(/\n+$/, '')
|
|
111
|
+
process.stderr.write(`value for ${name}: `)
|
|
112
|
+
Bun.spawnSync(['stty', '-echo'], { stdin: 'inherit' })
|
|
113
|
+
try {
|
|
114
|
+
const rl = createInterface({ input: process.stdin, terminal: false })
|
|
115
|
+
const line = await new Promise<string>((ok) => rl.once('line', ok))
|
|
116
|
+
rl.close()
|
|
117
|
+
return line
|
|
118
|
+
} finally {
|
|
119
|
+
Bun.spawnSync(['stty', 'echo'], { stdin: 'inherit' })
|
|
120
|
+
process.stderr.write('\n')
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
96
124
|
export class SecretSetCommand extends Command {
|
|
97
125
|
static override paths = [['secret', 'set']]
|
|
98
126
|
|
|
99
127
|
static override usage = Command.Usage({
|
|
100
128
|
category: 'Secrets',
|
|
101
|
-
description: 'store a secret and its account
|
|
129
|
+
description: 'store a secret and its account, in the vault where this machine runs one; prompts, or reads stdin',
|
|
130
|
+
details: 'On the machine that runs the vault, the value goes into the vault and is read back; the keychain is never written, and a vault that is down or sealed fails the command. On any other machine it goes through the house secret manager. The value is asked at a prompt, or read from stdin.',
|
|
102
131
|
examples: [['store a token', 'sk secret set rv/npm/token'], ['with its login', 'sk secret set rv/pockethost/account me@example.com']],
|
|
103
132
|
})
|
|
104
133
|
|
|
@@ -107,8 +136,29 @@ export class SecretSetCommand extends Command {
|
|
|
107
136
|
|
|
108
137
|
async execute(): Promise<number> {
|
|
109
138
|
return refusing(this.context.stderr, async () => {
|
|
110
|
-
const
|
|
111
|
-
|
|
139
|
+
const w = await where(process.cwd())
|
|
140
|
+
if (!vaultHere()) {
|
|
141
|
+
const argv = storeArgv(template(w, 'credsCommand'), this.name, this.account)
|
|
142
|
+
return Bun.spawnSync(argv, { stdin: 'inherit', stdout: 'inherit', stderr: 'inherit' }).exitCode ?? 1
|
|
143
|
+
}
|
|
144
|
+
const value = await readValue(this.name)
|
|
145
|
+
if (value === '') {
|
|
146
|
+
this.context.stderr.write('refusing to store empty value\n')
|
|
147
|
+
return 1
|
|
148
|
+
}
|
|
149
|
+
const account = this.account ?? userInfo().username
|
|
150
|
+
try {
|
|
151
|
+
const r = await writeSecretHere({ name: this.name, account, value, cwd: process.cwd() })
|
|
152
|
+
if (r == null || 'refused' in r) {
|
|
153
|
+
this.context.stderr.write(`FAIL: nothing was stored: ${r == null ? 'no vault on this machine' : r.refused}\n`)
|
|
154
|
+
return 1
|
|
155
|
+
}
|
|
156
|
+
this.context.stderr.write(`stored ${this.name} in the vault (v${r.version}, read back, account: ${account}); the keychain is not written\n`)
|
|
157
|
+
return 0
|
|
158
|
+
} catch (e) {
|
|
159
|
+
this.context.stderr.write(`${redact(`FAIL: the vault did not take ${this.name}: ${(e as Error).message}: nothing was stored`, value)}\n`)
|
|
160
|
+
return 1
|
|
161
|
+
}
|
|
112
162
|
})
|
|
113
163
|
}
|
|
114
164
|
}
|
|
@@ -120,7 +170,7 @@ export class SecretCopyCommand extends Command {
|
|
|
120
170
|
category: 'Secrets',
|
|
121
171
|
description: "this Mac's secrets into another Mac's keychain over ssh, each on ssh's stdin; what it holds stays",
|
|
122
172
|
details: "With no name: every secret of this repo's list that this Mac holds. The other Mac runs its own `sk secret set` from the house checkout at the same place under its home. A secret it already answers is left as it is. A keychain locked to ssh stops the copy and says how to unlock it.",
|
|
123
|
-
examples: [['every secret
|
|
173
|
+
examples: [['every secret the other Mac lacks', 'sk secret copy --to other-mac'], ['one secret', 'sk secret copy rv/shipkit/spaces --to other-mac'], ['a Mac whose keychain ssh sees locked, from your terminal', 'sk secret copy --to other-mac --unlock']],
|
|
124
174
|
})
|
|
125
175
|
|
|
126
176
|
names = Option.Rest()
|
package/src/cli/cmd_Social.ts
CHANGED
|
@@ -243,6 +243,87 @@ class SocialReleaseCardCommand extends Command {
|
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
+
class SocialThumbnailCommand extends Command {
|
|
247
|
+
static override paths = [['social', 'thumbnail']]
|
|
248
|
+
static override usage = Command.Usage({
|
|
249
|
+
category: 'Social',
|
|
250
|
+
description: "a video's thumbnail: 1280x720 jpg, a frame of it beside the brand's name, line and chip",
|
|
251
|
+
details:
|
|
252
|
+
"The identity kit draws it from .shipkit/identity/brand.ts (its ground, accent, ink, mark and the trailer's face, else Inter 800): the mark, the name huge, one line in the accent, an optional mono chip on the left; the frame as a tilted card on the right; an optional ribbon. A jpg under YouTube's 2 MB, written beside the video as <video>-thumbnail.jpg unless --out. The frame: --at seconds into the video (default its first lit frame past 1 s), or --frame <still>; --crop x,y,w,h keeps the product's interesting part, in pixels or as shares of the frame. --title is the brand's name, --line its tagline unless given; a text too long to read at YouTube's small size is refused, never cut. With --draft <draft>, the video defaults to the draft's own, the jpg lands in its media as <its video>-thumbnail.jpg after that video, its recipe is kept as the draft's thumbnail: line, and the files are committed; --draft alone makes it again from that line after a re-cut. The cover: Reddit and X take no uploaded picture, only a frame of the video, frame 0 first; so with --draft each of the draft's videos opens on the thumbnail, held 3 frames (0.1 s at 30 fps) with the sound delayed as long, encoded again at its own bitrates in place; a video that already opens on it is left as it is, an older cover is replaced. --no-cover leaves the videos as they are, kept in the recipe; --cover without --draft writes <video>-covered.mp4 beside the video. --plain writes the frame as it is, nothing drawn and no brand read, a jpg or a png by --out: an upright trailer's start image, a trailer's end image (wiki tools/trailer/index.md). Page: wiki tools/shipkit/social.md, A video's thumbnail",
|
|
253
|
+
examples: [
|
|
254
|
+
['a frame and the words', 'sk social thumbnail trailer/app/versions/v3/app-v3.mp4 --at 12.5 --crop 515,272,705,432 --line "Your app, typed." --chip "bun add app"'],
|
|
255
|
+
["a trailer post's, its recipe kept in the draft", 'sk social thumbnail --draft 20261119-174922-trailer --at 70 --crop 0.4,0.38,0.55,0.6'],
|
|
256
|
+
['made again from the draft after a re-cut', 'sk social thumbnail --draft 20261119-174922-trailer'],
|
|
257
|
+
['a covered copy of a video, frame 0 the thumbnail', 'sk social thumbnail trailer/app/versions/v3/app-v3.mp4 --at 12.5 --cover'],
|
|
258
|
+
['a still, with a ribbon', 'sk social thumbnail --frame shots/town.png --badge pre-alpha --out media/town-thumbnail.jpg'],
|
|
259
|
+
["a trailer's end image, the frame as it is", 'sk social thumbnail trailer/app/out/app.mp4 --at 61.9 --plain --out trailer/app/endcard.png'],
|
|
260
|
+
],
|
|
261
|
+
})
|
|
262
|
+
video = Option.String({ required: false })
|
|
263
|
+
at = Option.String('--at', { description: 'seconds into the video (default: its first lit frame past 1 s)' })
|
|
264
|
+
frame = Option.String('--frame', { description: 'a still instead of a frame of the video' })
|
|
265
|
+
crop = Option.String('--crop', { description: 'x,y,w,h of the frame to show, in pixels or shares of it (default: the whole frame)' })
|
|
266
|
+
title = Option.String('--title', { description: "the name, huge (default: the brand's name)" })
|
|
267
|
+
line = Option.String('--line', { description: "one short line in the accent (default: the brand's tagline)" })
|
|
268
|
+
chip = Option.String('--chip', { description: 'a short command in a mono chip, an install line (default: none)' })
|
|
269
|
+
badge = Option.String('--badge', { description: 'a ribbon word across the top right corner, like pre-alpha (default: none)' })
|
|
270
|
+
out = Option.String('--out', { description: 'the jpg (default: <video>-thumbnail.jpg beside the video); with --plain a .png gives a png' })
|
|
271
|
+
plain = Option.Boolean('--plain', false, { description: 'the frame as it is, nothing drawn on it (a trailer start image of an upright cut, an end image)' })
|
|
272
|
+
draft = Option.String('--draft', { description: "a draft: its video, its media, its thumbnail: recipe kept" })
|
|
273
|
+
cover = Option.Boolean('--cover', { description: 'the video opens on the thumbnail, its first 3 frames (default: on with --draft, its videos in place; off without, else <video>-covered.mp4)' })
|
|
274
|
+
override async execute(): Promise<number> {
|
|
275
|
+
return guarded(this.context, async () => {
|
|
276
|
+
const { relative, resolve } = await import('node:path')
|
|
277
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
278
|
+
const { loadSocialUnit } = await import('../social/unit.ts')
|
|
279
|
+
const t = await import('../social/thumbnail.ts')
|
|
280
|
+
const cwd = process.cwd()
|
|
281
|
+
const root = findRepoRoot(cwd)
|
|
282
|
+
const unit = await loadSocialUnit(root)
|
|
283
|
+
const at = this.at === undefined ? undefined : Number(this.at)
|
|
284
|
+
if (at !== undefined && !(at >= 0)) throw new Error(`--at ${this.at}: seconds into the video`)
|
|
285
|
+
const words = { ...(this.plain ? { plain: true } : {}), ...(this.crop ? { crop: this.crop } : {}), ...(this.title ? { title: this.title } : {}), ...(this.line ? { line: this.line } : {}), ...(this.chip ? { chip: this.chip } : {}), ...(this.badge ? { badge: this.badge } : {}) }
|
|
286
|
+
const kb = (n: number): string => `${Math.round(n / 1000)} KB`
|
|
287
|
+
if (this.draft) {
|
|
288
|
+
if (this.out) throw new Error('--out and --draft: a draft names its thumbnail after its video')
|
|
289
|
+
const { desk } = await model(undefined)
|
|
290
|
+
const { findDraft } = await import('../social/load.ts')
|
|
291
|
+
const d = findDraft(desk, this.draft, cwd)
|
|
292
|
+
// a path the agent typed is kept from the repo's root, so the recipe reads the same from any folder
|
|
293
|
+
const rooted = (p: string | undefined): string | undefined => (p === undefined ? undefined : relative(root, resolve(cwd, p)))
|
|
294
|
+
const r = await t.thumbnailDraft(root, d.slug, { ...words, ...(this.video ? { video: rooted(this.video) } : {}), ...(this.frame ? { frame: rooted(this.frame) } : {}), ...(at !== undefined ? { at } : {}), ...(this.cover !== undefined ? { cover: this.cover } : {}) }, { unit })
|
|
295
|
+
say(this.context)(`ok: ${d.slug} ${r.media} (${kb(r.bytes)}${r.at != null ? `, the frame at ${r.at} s` : ''}), its recipe kept as thumbnail: ${t.recipeLine(r.recipe)}`)
|
|
296
|
+
for (const c of r.covers)
|
|
297
|
+
say(this.context)(
|
|
298
|
+
c.did === 'skipped'
|
|
299
|
+
? `note: ${c.media} not covered: ${c.why}`
|
|
300
|
+
: `ok: ${c.media} ${c.did === 'kept' ? 'already opens on it, left as it is' : `${c.did === 'replaced' ? 'its older cover replaced' : 'covered'}: its first 3 frames the thumbnail, the sound as much later (${c.seconds.toFixed(1)} s)`}`,
|
|
301
|
+
)
|
|
302
|
+
for (const n of r.notes) say(this.context)(`note: ${n}`)
|
|
303
|
+
return 0
|
|
304
|
+
}
|
|
305
|
+
const r = await t.makeThumbnail(root, { ...words, ...(this.video ? { video: this.video } : {}), ...(this.frame ? { frame: this.frame } : {}), ...(at !== undefined ? { at } : {}), ...(this.out ? { out: this.out } : {}) }, cwd, unit)
|
|
306
|
+
say(this.context)(`ok: ${relative(cwd, r.file)} (${kb(r.bytes)}${r.at != null ? `, the frame at ${r.at} s` : ''})`)
|
|
307
|
+
say(this.context)(`its recipe: sk social thumbnail ${t.recipeLine(r.recipe)}`)
|
|
308
|
+
if (this.cover) {
|
|
309
|
+
if (!this.video) throw new Error('--cover covers a video: name it')
|
|
310
|
+
const c = await import('../social/cover.ts')
|
|
311
|
+
const { join } = await import('node:path')
|
|
312
|
+
const { LAYOUT } = await import('../core/layout.ts')
|
|
313
|
+
const video = resolve(cwd, this.video)
|
|
314
|
+
const out = c.coveredOfVideo(video)
|
|
315
|
+
if (c.coverCount(video, r.file) > 0) say(this.context)(`note: ${this.video} already opens on it: no covered copy`)
|
|
316
|
+
else {
|
|
317
|
+
await c.writeCover(video, r.file, out, join(root, LAYOUT.tmp, 'thumbnails'))
|
|
318
|
+
say(this.context)(`ok: ${relative(cwd, out)}, its first 3 frames the thumbnail, the sound as much later`)
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
for (const n of r.notes) say(this.context)(`note: ${n}`)
|
|
322
|
+
return 0
|
|
323
|
+
})
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
246
327
|
class SocialPlanCommand extends Command {
|
|
247
328
|
static override paths = [['social', 'plan']]
|
|
248
329
|
static override usage = Command.Usage({
|
|
@@ -351,6 +432,7 @@ class SocialDiscordApplyCommand extends Command {
|
|
|
351
432
|
for (const l of r.changes) say(this.context)(l)
|
|
352
433
|
if (r.changes.length === 0) say(this.context)(`ok: the server of ${id} matches its layout and its pictures`)
|
|
353
434
|
for (const l of r.left) say(this.context)(`left alone: ${l}`)
|
|
435
|
+
for (const l of r.hidden) say(this.context)(`HIDDEN: ${l}`)
|
|
354
436
|
return 0
|
|
355
437
|
})
|
|
356
438
|
}
|
|
@@ -458,4 +540,4 @@ class IdentitiesPushCommand extends Command {
|
|
|
458
540
|
}
|
|
459
541
|
}
|
|
460
542
|
|
|
461
|
-
export const SOCIAL_COMMANDS = [SocialCommand, SocialTimelineCommand, SocialCoverageCommand, SocialPostCommand, SocialReleaseCommand, SocialReleaseCardCommand, SocialPlanCommand, SocialStateCommand, SocialMigrateCommand, SocialDiscordApplyCommand, IdentitiesCommand, IdentitiesPushCommand]
|
|
543
|
+
export const SOCIAL_COMMANDS = [SocialCommand, SocialTimelineCommand, SocialCoverageCommand, SocialPostCommand, SocialReleaseCommand, SocialReleaseCardCommand, SocialThumbnailCommand, SocialPlanCommand, SocialStateCommand, SocialMigrateCommand, SocialDiscordApplyCommand, IdentitiesCommand, IdentitiesPushCommand]
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
// sk space: the second copy of the private Space (media-store/copy/, wiki tools/shipkit/media-store.md, The second
|
|
2
|
+
// copy): every object streamed to a bucket at another provider, the hq's nightly snapshot beside them, the proof.
|
|
3
|
+
// Every module loads inside execute: the cli registers this file on every `sk` call
|
|
4
|
+
import { Command, Option } from 'clipanion'
|
|
5
|
+
|
|
6
|
+
const DETAILS = `the house config's serve.spaceCopy names a bucket at another provider. Each night (the daemon's job, once the switch is on) the Space is listed once, page by page, and each object the copy lacks is streamed over, a few at a time, within a budget of bytes and time: never whole in memory, never on the disk, its sha256 checked against its key before the upload completes. A key the copy holds with other bytes is never overwritten. The hq's file goes there too, as a gzipped snapshot under _snapshots/hq/, kept 30 days by the bucket's lifecycle rule (sk space setup). Then the proof: the counts a kind on both sides, a sample read back and hashed, the snapshot restored. Nothing deletes, at either end. Page: wiki tools/shipkit/media-store.md`
|
|
7
|
+
|
|
8
|
+
type Ctx = { stdout: NodeJS.WritableStream; stderr: NodeJS.WritableStream }
|
|
9
|
+
const io = (c: Ctx): { out: (l: string) => void; err: (l: string) => void } => ({ out: (l) => void c.stdout.write(`${l}\n`), err: (l) => void c.stderr.write(`${l}\n`) })
|
|
10
|
+
|
|
11
|
+
async function ends(err: (l: string) => void): Promise<import('../media-store/copy/config.ts').CopyEnds | null> {
|
|
12
|
+
const { houseCopy } = await import('../media-store/copy/config.ts')
|
|
13
|
+
const e = await houseCopy()
|
|
14
|
+
if ('why' in e) {
|
|
15
|
+
err(`FAIL: space copy: ${e.why}`)
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
return e
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** stopped by ^C or a kill: the object in flight is not completed, what was done is kept */
|
|
22
|
+
const stopper = (): AbortController => {
|
|
23
|
+
const stop = new AbortController()
|
|
24
|
+
for (const s of ['SIGINT', 'SIGTERM'] as const) process.once(s, () => stop.abort())
|
|
25
|
+
return stop
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class SpaceCopyCommand extends Command {
|
|
29
|
+
static override paths = [['space', 'copy']]
|
|
30
|
+
static override usage = Command.Usage({
|
|
31
|
+
category: 'Media',
|
|
32
|
+
description: 'copy the private Space to its second place now, then prove it: by stream, resumable, within a budget',
|
|
33
|
+
details: `${DETAILS}\n\nThe first copy of a large Space takes several nights at the daemon's budget (20 GB or 45 min); run it here with a larger one. ^C stops between two parts: nothing half sent completes, the next run goes on.`,
|
|
34
|
+
examples: [
|
|
35
|
+
['what a run would send, nothing sent', 'sk space copy --dry'],
|
|
36
|
+
['a first copy of up to 60 GB in up to 8 hours', 'sk space copy --gb 60 --hours 8'],
|
|
37
|
+
['what the copy holds that the Space no longer does, nothing deleted', 'sk space copy --prune --dry'],
|
|
38
|
+
['the daemon copies each night from now on', 'sk space copy --auto on'],
|
|
39
|
+
],
|
|
40
|
+
})
|
|
41
|
+
gb = Option.String('--gb', '20', { description: 'the most bytes this run sends, in GB' })
|
|
42
|
+
hours = Option.String('--hours', '0.75', { description: 'the longest this run sends, in hours' })
|
|
43
|
+
jobs = Option.String('--jobs', '3', { description: 'objects in flight at once (one part of 16 MB each at most)' })
|
|
44
|
+
dry = Option.Boolean('--dry', false, { description: 'list the Space and say what would go, send nothing' })
|
|
45
|
+
prune = Option.Boolean('--prune', false, { description: 'with --dry: list what the copy holds that the Space no longer lists (a forget, a purge of versions); the copy never deletes' })
|
|
46
|
+
auto = Option.String('--auto', { description: 'on: the daemon copies each night (01:00 to 06:00), off: it does not (off until the owner turns it on)' })
|
|
47
|
+
|
|
48
|
+
async execute(): Promise<number> {
|
|
49
|
+
const { out, err } = io(this.context)
|
|
50
|
+
const night = await import('../media-store/copy/night.ts')
|
|
51
|
+
if (this.auto !== undefined) {
|
|
52
|
+
if (this.auto !== 'on' && this.auto !== 'off') {
|
|
53
|
+
err(`FAIL: --auto takes on or off, not ${this.auto}`)
|
|
54
|
+
return 1
|
|
55
|
+
}
|
|
56
|
+
if (!night.setCopyOn(this.auto === 'on')) {
|
|
57
|
+
err('FAIL: the machine db does not open: the switch is not set')
|
|
58
|
+
return 1
|
|
59
|
+
}
|
|
60
|
+
out(`the daemon's space copy ${this.auto === 'on' ? `on: each night from ${night.NIGHT_FROM_H}:00 to ${night.NIGHT_TO_H}:00` : 'off'}`)
|
|
61
|
+
return 0
|
|
62
|
+
}
|
|
63
|
+
const { copyDbPath, openCopyDb } = await import('../media-store/copy/store.ts')
|
|
64
|
+
const { onlyAtCopy } = await import('../media-store/copy/copy.ts')
|
|
65
|
+
if (this.prune) {
|
|
66
|
+
if (!this.dry) {
|
|
67
|
+
err('FAIL: --prune lists only, with --dry: the copy never deletes by itself')
|
|
68
|
+
return 1
|
|
69
|
+
}
|
|
70
|
+
const db = openCopyDb(copyDbPath())
|
|
71
|
+
try {
|
|
72
|
+
const gone = onlyAtCopy(db)
|
|
73
|
+
for (const g of gone) out(`only at the copy ${g.size} B ${g.key}`)
|
|
74
|
+
out(`${gone.length} objects at the copy the Space's last listing lacks, ${(gone.reduce((n, g) => n + g.size, 0) / 1e9).toFixed(2)} GB; nothing deleted`)
|
|
75
|
+
return 0
|
|
76
|
+
} finally {
|
|
77
|
+
db.close()
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const gb = Number(this.gb)
|
|
81
|
+
const hours = Number(this.hours)
|
|
82
|
+
const jobs = Number(this.jobs)
|
|
83
|
+
if (!(gb > 0) || !(hours > 0) || !Number.isInteger(jobs) || jobs < 1 || jobs > 16) {
|
|
84
|
+
err('FAIL: --gb and --hours take a number above 0, --jobs a whole number from 1 to 16')
|
|
85
|
+
return 1
|
|
86
|
+
}
|
|
87
|
+
const e = await ends(err)
|
|
88
|
+
if (e == null) return 1
|
|
89
|
+
const budget = { bytes: gb * 1e9, ms: hours * 3_600_000 }
|
|
90
|
+
if (this.dry) {
|
|
91
|
+
const { copyRun } = await import('../media-store/copy/copy.ts')
|
|
92
|
+
const db = openCopyDb(copyDbPath())
|
|
93
|
+
try {
|
|
94
|
+
const r = await copyRun({ ...e, db, dry: true, print: out })
|
|
95
|
+
if ('refused' in r) {
|
|
96
|
+
err(`FAIL: ${r.refused}`)
|
|
97
|
+
return 1
|
|
98
|
+
}
|
|
99
|
+
out(`the Space lists ${r.listed} objects (${r.skipped} never mirrored), the copy holds ${r.held}: ${r.left} would go, ${(r.leftBytes / 1e9).toFixed(2)} GB; nothing sent`)
|
|
100
|
+
for (const c of db.query('select key, conflict from objects where listed = ? and conflict is not null order by key').all(r.at) as { key: string; conflict: string }[]) out(`conflict ${c.key}: ${c.conflict}`)
|
|
101
|
+
return 0
|
|
102
|
+
} finally {
|
|
103
|
+
db.close()
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const { carriesHq } = await import('../hq/hq-local.ts')
|
|
107
|
+
const stop = stopper()
|
|
108
|
+
const r = await night.copyNight({ ends: e, budget, jobs, hq: carriesHq(), signal: stop.signal, print: out, printErr: err })
|
|
109
|
+
if (r.refused != null) return 1
|
|
110
|
+
return r.proof?.ok === true ? 0 : 1
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export class SpaceProofCommand extends Command {
|
|
115
|
+
static override paths = [['space', 'proof']]
|
|
116
|
+
static override usage = Command.Usage({
|
|
117
|
+
category: 'Media',
|
|
118
|
+
description: 'prove the second copy now: counts a kind on both sides, a sample hashed, the hq snapshot restored',
|
|
119
|
+
details: DETAILS,
|
|
120
|
+
examples: [
|
|
121
|
+
['prove the copy now', 'sk space proof'],
|
|
122
|
+
['the last proof, nothing asked of either bucket', 'sk space proof --last'],
|
|
123
|
+
],
|
|
124
|
+
})
|
|
125
|
+
last = Option.Boolean('--last', false, { description: 'print the last proof this machine kept, read nothing' })
|
|
126
|
+
json = Option.Boolean('--json', false, { description: 'the proof as one json line' })
|
|
127
|
+
|
|
128
|
+
async execute(): Promise<number> {
|
|
129
|
+
const { out, err } = io(this.context)
|
|
130
|
+
const { lastCopyProof, proveCopy } = await import('../media-store/copy/proof.ts')
|
|
131
|
+
const { proofLine } = await import('../media-store/copy/night.ts')
|
|
132
|
+
let p = lastCopyProof()
|
|
133
|
+
if (!this.last) {
|
|
134
|
+
const e = await ends(err)
|
|
135
|
+
if (e == null) return 1
|
|
136
|
+
const { copyDbPath, openCopyDb } = await import('../media-store/copy/store.ts')
|
|
137
|
+
const { carriesHq } = await import('../hq/hq-local.ts')
|
|
138
|
+
const db = openCopyDb(copyDbPath())
|
|
139
|
+
try {
|
|
140
|
+
p = await proveCopy({ ...e, db, hq: carriesHq() })
|
|
141
|
+
} finally {
|
|
142
|
+
db.close()
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (p == null) {
|
|
146
|
+
err('FAIL: no proof kept on this machine yet: sk space proof')
|
|
147
|
+
return 1
|
|
148
|
+
}
|
|
149
|
+
if (this.json) {
|
|
150
|
+
out(JSON.stringify(p))
|
|
151
|
+
return p.ok ? 0 : 1
|
|
152
|
+
}
|
|
153
|
+
out(`${new Date(p.at).toISOString().slice(0, 16)}Z ${proofLine(p)}`)
|
|
154
|
+
for (const k of p.kinds) out(` ${k.kind.padEnd(20)} Space ${String(k.space.n).padStart(7)} ${(k.space.bytes / 1e9).toFixed(2).padStart(7)} GB copy ${String(k.copy.n).padStart(7)} ${(k.copy.bytes / 1e9).toFixed(2).padStart(7)} GB`)
|
|
155
|
+
for (const w of p.why) err(`WARN ${w}`)
|
|
156
|
+
return p.ok ? 0 : 1
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export class SpaceSnapshotCommand extends Command {
|
|
161
|
+
static override paths = [['space', 'snapshot']]
|
|
162
|
+
static override usage = Command.Usage({
|
|
163
|
+
category: 'Media',
|
|
164
|
+
description: 'put the hq\'s snapshot at the second copy now, or a sealed file given by path (the vault\'s)',
|
|
165
|
+
details: `${DETAILS}\n\nWith --file the bytes go as they are, under _snapshots/<label>/: a file is sealed before it is handed here, and never read for what it holds.`,
|
|
166
|
+
examples: [
|
|
167
|
+
['the hq\'s snapshot now', 'sk space snapshot'],
|
|
168
|
+
['the vault\'s sealed snapshot', 'sk space snapshot --file ~/.shipkit/vault/snapshot.sealed --label vault'],
|
|
169
|
+
],
|
|
170
|
+
})
|
|
171
|
+
file = Option.String('--file', { description: 'a sealed file to put as it is' })
|
|
172
|
+
label = Option.String('--label', { description: 'with --file: the folder under _snapshots/ (letters, digits, dashes)' })
|
|
173
|
+
|
|
174
|
+
async execute(): Promise<number> {
|
|
175
|
+
const { out, err } = io(this.context)
|
|
176
|
+
const e = await ends(err)
|
|
177
|
+
if (e == null) return 1
|
|
178
|
+
const s = await import('../media-store/copy/snapshot.ts')
|
|
179
|
+
try {
|
|
180
|
+
if (this.file !== undefined) {
|
|
181
|
+
if (this.label === undefined) {
|
|
182
|
+
err('FAIL: --file wants its --label')
|
|
183
|
+
return 1
|
|
184
|
+
}
|
|
185
|
+
const r = await s.snapshotFile({ to: e.to, file: this.file, label: this.label })
|
|
186
|
+
out(`ok: ${r.key} (${r.size} B, sha256 ${r.sha})`)
|
|
187
|
+
return 0
|
|
188
|
+
}
|
|
189
|
+
const { carriesHq } = await import('../hq/hq-local.ts')
|
|
190
|
+
if (!carriesHq()) {
|
|
191
|
+
err('FAIL: this machine carries no hq: its snapshot is taken where the hq runs')
|
|
192
|
+
return 1
|
|
193
|
+
}
|
|
194
|
+
const r = await s.snapshotHq({ to: e.to })
|
|
195
|
+
out(`ok: ${r.key} (${(r.size / 1e6).toFixed(1)} MB gzipped of ${((r.raw ?? 0) / 1e6).toFixed(1)} MB, every row of the live file held)`)
|
|
196
|
+
return 0
|
|
197
|
+
} catch (x) {
|
|
198
|
+
err(`FAIL: ${(x as Error).message}`)
|
|
199
|
+
return 1
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export class SpaceSetupCommand extends Command {
|
|
205
|
+
static override paths = [['space', 'setup']]
|
|
206
|
+
static override usage = Command.Usage({
|
|
207
|
+
category: 'Media',
|
|
208
|
+
description: 'set the second copy\'s lifecycle rule: snapshots kept 30 days, unfinished uploads aborted after a day',
|
|
209
|
+
details: `${DETAILS}\n\nThe rules are added beside the bucket's own and read back. A key that may only read and write objects cannot set them: the command then says what to set in the provider's page.`,
|
|
210
|
+
examples: [['set the rule once', 'sk space setup']],
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
async execute(): Promise<number> {
|
|
214
|
+
const { out, err } = io(this.context)
|
|
215
|
+
const e = await ends(err)
|
|
216
|
+
if (e == null) return 1
|
|
217
|
+
const { LIFECYCLE_BY_HAND, setLifecycle } = await import('../media-store/copy/lifecycle.ts')
|
|
218
|
+
try {
|
|
219
|
+
const r = await setLifecycle(e.to)
|
|
220
|
+
if (!r.ok) {
|
|
221
|
+
err(`FAIL: ${r.why}`)
|
|
222
|
+
return 1
|
|
223
|
+
}
|
|
224
|
+
out(`ok: the copy keeps snapshots 30 days and aborts unfinished uploads after a day${r.kept.length > 0 ? `; its own rules kept: ${r.kept.join(', ')}` : ''}`)
|
|
225
|
+
return 0
|
|
226
|
+
} catch (x) {
|
|
227
|
+
const m = (x as Error).message
|
|
228
|
+
if (/: 403\b/.test(m)) {
|
|
229
|
+
for (const l of LIFECYCLE_BY_HAND) err(l)
|
|
230
|
+
return 1
|
|
231
|
+
}
|
|
232
|
+
err(`FAIL: ${m}`)
|
|
233
|
+
return 1
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const PAGE = `The same read as the Space page of the home (/space): what the daemon's job space listing kept of each Space the house names (the bucket's own listing, about one call per 1,000 objects, once a day or when the page's refresh asks), joined with this machine's media index for each file's name and who put it. A machine with no key to the Space shows what its index says is up. Nothing here writes to a bucket. Page: wiki tools/shipkit/media-store.md, The Space page`
|
|
239
|
+
|
|
240
|
+
/** the page's reads, from the house this command runs in */
|
|
241
|
+
async function pageDeps(): Promise<import('../home/space-page.ts').SpacePageDeps> {
|
|
242
|
+
const [{ houseRootOf }, { houseRepos }, { spaceDeps }, { homedir }] = await Promise.all([import('../home/home-start.ts'), import('../serve/project-gutter.ts'), import('../home/space-route.ts'), import('node:os')])
|
|
243
|
+
const root = houseRootOf(process.cwd())
|
|
244
|
+
return spaceDeps(root, root == null ? [] : houseRepos(root, homedir()).repos.map((r) => ({ name: r.name, path: r.path })))
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export class SpaceShowCommand extends Command {
|
|
248
|
+
static override paths = [['space']]
|
|
249
|
+
static override usage = Command.Usage({
|
|
250
|
+
category: 'Media',
|
|
251
|
+
description: 'what each Space holds: its size, its top folders with their sizes and counts, the age of its listing',
|
|
252
|
+
details: PAGE,
|
|
253
|
+
examples: [
|
|
254
|
+
['the totals and the top folders', 'sk space'],
|
|
255
|
+
['with what it is and how it stands', 'sk space --facts'],
|
|
256
|
+
['list each Space now, here, then print', 'sk space --list'],
|
|
257
|
+
],
|
|
258
|
+
})
|
|
259
|
+
facts = Option.Boolean('--facts', false, { description: 'its about and health lines too' })
|
|
260
|
+
list = Option.Boolean('--list', false, { description: 'list each Space now in this process and keep it (GETs only), then print' })
|
|
261
|
+
json = Option.Boolean('--json', false, { description: 'the page\'s data as one json line' })
|
|
262
|
+
|
|
263
|
+
async execute(): Promise<number> {
|
|
264
|
+
const { out, err } = io(this.context)
|
|
265
|
+
if (this.list) {
|
|
266
|
+
const [{ houseRootOf }, { houseEnds }, { spaceListingTick }, { mediaDb }] = await Promise.all([import('../home/home-start.ts'), import('../home/space-route.ts'), import('../home/space-job.ts'), import('../media-store/db.ts')])
|
|
267
|
+
const e = await houseEnds(houseRootOf(process.cwd()))
|
|
268
|
+
if (e.why != null) {
|
|
269
|
+
err(`FAIL: ${e.why}`)
|
|
270
|
+
return 1
|
|
271
|
+
}
|
|
272
|
+
const why = await spaceListingTick({ ends: e.ends, media: mediaDb(), print: out, printErr: err })
|
|
273
|
+
for (const [id, w] of Object.entries(why)) if (w !== '') err(`WARN ${id}: ${w}`)
|
|
274
|
+
}
|
|
275
|
+
const { spacePage } = await import('../home/space-page.ts')
|
|
276
|
+
const d = await pageDeps()
|
|
277
|
+
if (d.noEnds != null) {
|
|
278
|
+
err(`FAIL: ${d.noEnds}`)
|
|
279
|
+
return 1
|
|
280
|
+
}
|
|
281
|
+
const p = spacePage(d)
|
|
282
|
+
if (this.json) {
|
|
283
|
+
out(JSON.stringify(p))
|
|
284
|
+
return 0
|
|
285
|
+
}
|
|
286
|
+
const { spaceLines } = await import('../home/space-words.ts')
|
|
287
|
+
for (const l of spaceLines(p, { facts: this.facts })) out(l)
|
|
288
|
+
return 0
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export class SpaceLsCommand extends Command {
|
|
293
|
+
static override paths = [['space', 'ls']]
|
|
294
|
+
static override usage = Command.Usage({
|
|
295
|
+
category: 'Media',
|
|
296
|
+
description: 'a folder of the Space: its sub folders and files, the biggest first, who put each',
|
|
297
|
+
details: PAGE,
|
|
298
|
+
examples: [
|
|
299
|
+
['the review folder', 'sk space ls review/'],
|
|
300
|
+
['every object whose key or file name holds a word', 'sk space ls --find hero'],
|
|
301
|
+
['a folder of the second copy', 'sk space ls _snapshots/ --copy'],
|
|
302
|
+
],
|
|
303
|
+
})
|
|
304
|
+
prefix = Option.String({ required: false })
|
|
305
|
+
find = Option.String('--find', { description: 'the objects whose key or file name holds every word of it, anywhere' })
|
|
306
|
+
copy = Option.Boolean('--copy', false, { description: 'the second copy instead of the Space' })
|
|
307
|
+
|
|
308
|
+
async execute(): Promise<number> {
|
|
309
|
+
const { out, err } = io(this.context)
|
|
310
|
+
const { folderPage } = await import('../home/space-page.ts')
|
|
311
|
+
const { folderLines } = await import('../home/space-words.ts')
|
|
312
|
+
const d = await pageDeps()
|
|
313
|
+
const prefix = this.prefix == null || this.prefix === '' ? '' : this.prefix.endsWith('/') ? this.prefix : `${this.prefix}/`
|
|
314
|
+
const f = folderPage(d, this.copy ? 'copy' : 'space', prefix, this.find ?? '')
|
|
315
|
+
if (f.at == null) {
|
|
316
|
+
err('FAIL: no listing kept on this machine yet: sk space --list, or the page\'s refresh')
|
|
317
|
+
return 1
|
|
318
|
+
}
|
|
319
|
+
for (const l of folderLines(f)) out(l)
|
|
320
|
+
return 0
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export const SPACE_COMMANDS = [SpaceShowCommand, SpaceLsCommand, SpaceCopyCommand, SpaceProofCommand, SpaceSnapshotCommand, SpaceSetupCommand]
|