rvlib-shipkit 2.26.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 +36 -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 +16 -7
- package/src/agent-time/limits.ts +44 -0
- package/src/agent-time/live.ts +12 -8
- package/src/agent-time/mask.ts +96 -18
- package/src/agent-time/refused.ts +45 -0
- package/src/agent-time/registry.ts +289 -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 +322 -101
- package/src/agent-time/timeline.ts +140 -21
- package/src/agent-time/turns.ts +18 -8
- package/src/annex/born.ts +2 -2
- package/src/annex/offload.ts +29 -17
- package/src/annex/tidy.ts +70 -10
- package/src/asks/ask-after.ts +44 -0
- 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/kit-config.ts +7 -3
- package/src/assets/kits/identity-kit.ts +361 -14
- package/src/assets/kits/poster-thumbnail.ts +282 -0
- package/src/check.ts +3 -1
- package/src/checks/SK003-claude-md-shape.check.ts +92 -25
- package/src/checks/SK004-gitignore-policy.check.ts +20 -9
- package/src/checks/SK013-one-way-in-policy.check.ts +18 -3
- package/src/checks/SK026-asks-autoclose.check.ts +9 -23
- 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/SK038-speaks-as.check.ts +3 -3
- package/src/checks/SK042-post-kinds.check.ts +26 -24
- 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/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 +244 -27
- package/src/cli/cmd_Backup.ts +153 -10
- package/src/cli/cmd_Calls.ts +1 -0
- package/src/cli/cmd_Capacity.ts +2 -2
- package/src/cli/cmd_Commands.ts +140 -34
- package/src/cli/cmd_Contracts.ts +1 -0
- 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_Keys.ts +1 -0
- package/src/cli/cmd_Lanes.ts +15 -4
- package/src/cli/cmd_Machines.ts +36 -0
- package/src/cli/cmd_Media.ts +38 -6
- package/src/cli/cmd_Messages.ts +152 -1
- package/src/cli/cmd_Needs.ts +1 -0
- package/src/cli/cmd_Reflect.ts +23 -2
- package/src/cli/cmd_Review.ts +1357 -223
- package/src/cli/cmd_Secret.ts +295 -24
- package/src/cli/cmd_Social.ts +113 -28
- package/src/cli/cmd_SocialDrafts.ts +235 -0
- package/src/cli/cmd_Sound.ts +22 -1
- package/src/cli/cmd_Space.ts +324 -0
- 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_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/cmd_When.ts +1 -0
- package/src/cli/family-help.ts +5 -3
- 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 +44 -4
- package/src/cli.ts +5 -2
- package/src/collections/actions.ts +42 -41
- package/src/collections/collection-types.ts +30 -4
- package/src/collections/md-body.ts +5 -3
- package/src/collections/pings.ts +13 -6
- package/src/collections/providers.ts +147 -61
- package/src/collections/reflections.ts +9 -4
- 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/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 +13 -5
- package/src/core/locked-write.ts +4 -1
- package/src/core/machine-busy.ts +127 -0
- package/src/core/machine-commit.ts +6 -1
- package/src/core/machine-db.ts +370 -20
- package/src/core/machine-layout.ts +137 -0
- package/src/core/machine-read.ts +81 -0
- package/src/core/migrate-layout.ts +9 -11
- 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 +59 -3
- package/src/home/app-sign.ts +15 -4
- package/src/home/daemon-jobs.ts +161 -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 +18 -6
- package/src/home/home-routes.ts +76 -0
- package/src/home/inbox-shape.ts +234 -91
- package/src/home/inbox.ts +26 -71
- package/src/home/machine-fold.ts +815 -0
- package/src/home/machine-host.ts +38 -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/other-macs.ts +2 -2
- 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 +179 -10
- 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 +516 -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 +41 -6
- 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 +347 -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 +102 -0
- package/src/hq/hq-local.ts +502 -0
- package/src/hq/hq-routes.ts +204 -0
- package/src/hq/hq-store.ts +603 -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 +374 -0
- package/src/hq/replica.ts +167 -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/hq/vault-route.ts +112 -0
- package/src/identities/collection.ts +2 -2
- package/src/identities/identities.ts +24 -11
- package/src/identities/machine-route.ts +8 -3
- package/src/identities/steps.ts +31 -0
- package/src/ledger/db.ts +81 -27
- 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 +73 -25
- package/src/media-store/backup/kept.ts +241 -0
- 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/restore.ts +14 -4
- package/src/media-store/backup/retention.ts +122 -0
- package/src/media-store/backup/run.ts +25 -19
- 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 +83 -31
- package/src/media-store/backup/thread-copy.ts +340 -0
- package/src/media-store/copy/config.ts +76 -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 +24 -13
- package/src/media-store/forget.ts +141 -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 +21 -17
- package/src/media-store/put.ts +24 -8
- package/src/media-store/remote.ts +16 -7
- package/src/media-store/space-listing.ts +256 -0
- package/src/media-store/space.ts +46 -26
- 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/guard.ts +49 -0
- package/src/messages/model.ts +16 -7
- package/src/messages/objects.ts +201 -0
- package/src/messages/routes.ts +14 -4
- package/src/messages/score.ts +3 -3
- package/src/messages/write.ts +285 -0
- package/src/pages/frame-client.ts +191 -4
- 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/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/machine-words.ts +67 -0
- package/src/release/public-clean.ts +11 -5
- 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 +71 -19
- package/src/review/anim.ts +3 -3
- package/src/review/answer-kinds.ts +131 -0
- package/src/review/auto.ts +2 -2
- package/src/review/band.ts +53 -0
- package/src/review/branch-hold.ts +84 -0
- package/src/review/card-db.ts +254 -0
- package/src/review/card-rows.ts +267 -0
- package/src/review/cells.ts +360 -57
- package/src/review/close.ts +92 -0
- package/src/review/draft-card.ts +33 -0
- package/src/review/draft-model.ts +78 -0
- package/src/review/events.ts +171 -0
- package/src/review/format.ts +152 -19
- package/src/review/glyphs.ts +63 -0
- package/src/review/gone.ts +98 -0
- 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 +23 -10
- 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/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 +582 -109
- package/src/review/move.ts +491 -0
- package/src/review/need-address.ts +15 -0
- package/src/review/need-threads.ts +93 -0
- package/src/review/notes.ts +12 -20
- 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 +18 -20
- package/src/review/project.ts +1 -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/rev.ts +8 -0
- package/src/review/role.ts +1 -1
- package/src/review/routes.ts +194 -38
- package/src/review/secret-route.ts +80 -0
- package/src/review/snooze.ts +38 -0
- package/src/review/stage-card.ts +12 -8
- package/src/review/stage-routes.ts +1 -1
- package/src/review/store.ts +851 -124
- package/src/review/supersede.ts +116 -0
- package/src/review/take-back.ts +52 -0
- package/src/review/thread-fold.ts +64 -0
- package/src/review/threads.ts +349 -14
- package/src/review/traces.ts +218 -0
- package/src/review/trailer-auto-mock.ts +63 -0
- package/src/review/trailer-card.ts +6 -6
- 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 +77 -11
- 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 +23 -10
- package/src/rules/untrack-generated.ts +92 -8
- 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/held.ts +16 -0
- package/src/secrets/keychain-write.ts +48 -0
- package/src/secrets/keychain.ts +116 -0
- package/src/secrets/lapse-mark.ts +33 -0
- package/src/secrets/lapse.ts +60 -0
- package/src/secrets/list.ts +21 -17
- package/src/secrets/manager.ts +55 -26
- package/src/secrets/read.ts +385 -0
- package/src/secrets/tail.ts +31 -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 +49 -0
- package/src/serve/hub-app/asks-st.ts +25 -0
- 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/clock-svc.ts +1 -2
- package/src/serve/hub-app/code-copy.ts +35 -0
- package/src/serve/hub-app/col-card.tsx +72 -30
- package/src/serve/hub-app/col-list-page.tsx +125 -0
- package/src/serve/hub-app/col-list-st.ts +103 -0
- package/src/serve/hub-app/col-tables-view.tsx +17 -45
- package/src/serve/hub-app/col-tables.ts +76 -8
- package/src/serve/hub-app/cols-svc.ts +18 -39
- 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/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/frames-st.ts +17 -1
- package/src/serve/hub-app/git-view.tsx +3 -2
- 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 +142 -11
- package/src/serve/hub-app/home-strip.css +6 -25
- package/src/serve/hub-app/home-strip.tsx +60 -93
- package/src/serve/hub-app/home.html +10 -0
- package/src/serve/hub-app/house-wiki-view.tsx +20 -0
- package/src/serve/hub-app/hub-app.tsx +71 -166
- package/src/serve/hub-app/hub-types.ts +5 -1
- package/src/serve/hub-app/hub.css +146 -71
- package/src/serve/hub-app/icons.tsx +32 -5
- package/src/serve/hub-app/identities-st.ts +56 -6
- package/src/serve/hub-app/identities-view.tsx +104 -61
- 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 +227 -49
- package/src/serve/hub-app/inbox-view.tsx +204 -120
- package/src/serve/hub-app/inbox.css +47 -47
- package/src/serve/hub-app/index.html +10 -0
- package/src/serve/hub-app/instructions.css +30 -0
- package/src/serve/hub-app/kept-cols.tsx +7 -0
- package/src/serve/hub-app/keys.ts +32 -17
- 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/machine-st.ts +2 -2
- package/src/serve/hub-app/machines-st.ts +251 -0
- package/src/serve/hub-app/machines-view.tsx +217 -0
- package/src/serve/hub-app/machines.css +67 -0
- package/src/serve/hub-app/markdown.css +51 -0
- package/src/serve/hub-app/md-copy.tsx +57 -0
- package/src/serve/hub-app/md.ts +25 -9
- package/src/serve/hub-app/media-view.tsx +4 -2
- package/src/serve/hub-app/messages/messages-page.tsx +81 -8
- package/src/serve/hub-app/messages/messages-st.ts +99 -3
- package/src/serve/hub-app/messages.css +14 -1
- package/src/serve/hub-app/objects.css +51 -0
- package/src/serve/hub-app/page-keys.ts +175 -0
- package/src/serve/hub-app/pages-frames.tsx +21 -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/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 +46 -8
- package/src/serve/hub-app/project-list.tsx +125 -59
- package/src/serve/hub-app/projects-svc.ts +83 -8
- 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 +22 -6
- package/src/serve/hub-app/reflections-page.tsx +95 -0
- package/src/serve/hub-app/reflections-st.ts +17 -0
- package/src/serve/hub-app/releases/releases-page.tsx +28 -4
- package/src/serve/hub-app/releases/releases-st.ts +1 -1
- package/src/serve/hub-app/releases.css +0 -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/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 +163 -0
- 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 +75 -29
- package/src/serve/hub-app/review/lane-bar.tsx +64 -0
- package/src/serve/hub-app/review/note-place.ts +1 -1
- 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-board.tsx +2 -2
- package/src/serve/hub-app/review/review-cells.tsx +148 -87
- package/src/serve/hub-app/review/review-kit.ts +27 -1
- package/src/serve/hub-app/review/review-list.tsx +160 -65
- package/src/serve/hub-app/review/review-page.tsx +12 -12
- package/src/serve/hub-app/review/review-st.ts +174 -47
- package/src/serve/hub-app/review/review-thread.tsx +214 -53
- package/src/serve/hub-app/review/review-views.tsx +494 -159
- package/src/serve/hub-app/review/thread-close.tsx +124 -0
- 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 +288 -41
- package/src/serve/hub-app/review/trailer-card.tsx +2 -2
- 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/trailer-timeline.tsx +2 -2
- package/src/serve/hub-app/review.css +462 -97
- package/src/serve/hub-app/section-head.tsx +51 -0
- 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/calendar.tsx +5 -11
- package/src/serve/hub-app/social/comms-page.tsx +43 -15
- package/src/serve/hub-app/social/kit.tsx +32 -13
- package/src/serve/hub-app/social/next-release.tsx +3 -5
- package/src/serve/hub-app/social/post-card.tsx +142 -49
- 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/serial-writes.ts +13 -0
- package/src/serve/hub-app/social/social-model.ts +24 -5
- package/src/serve/hub-app/social/social-page.tsx +95 -36
- package/src/serve/hub-app/social/social-st.ts +162 -41
- 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 +10 -17
- 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 +97 -25
- 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/thread-row.tsx +101 -0
- package/src/serve/hub-app/time-ago.tsx +3 -2
- 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 +77 -0
- package/src/serve/hub-app/time.css +135 -0
- package/src/serve/hub-app/tree-build.ts +52 -42
- package/src/serve/hub-app/tree-row.tsx +3 -11
- 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-page.tsx +2 -11
- package/src/serve/hub-app/veille/veille-st.ts +12 -10
- package/src/serve/hub-app/veille.css +0 -1
- package/src/serve/hub-app/waiting-svc.ts +29 -0
- 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 +6 -5
- package/src/serve/hub-runtime.ts +35 -8
- package/src/serve/project-gutter-route.ts +42 -19
- package/src/serve/project-gutter.ts +16 -50
- package/src/serve/same-origin.ts +13 -0
- package/src/serve/secret-gate.ts +21 -0
- package/src/serve/serve-hub.ts +38 -20
- package/src/serve/tailnet-caller.ts +117 -0
- package/src/shipkit-files.ts +16 -2
- package/src/shipkit.ts +3 -3
- package/src/shot/shooter.ts +616 -420
- package/src/shot/shot-ask.ts +246 -155
- package/src/site/desk.ts +4 -4
- package/src/smoke/run-smoke.ts +6 -6
- package/src/social/brands.ts +4 -0
- package/src/social/card-drafts.ts +11 -19
- package/src/social/cover.ts +202 -0
- package/src/social/desk-index.ts +34 -13
- package/src/social/discord-layout.ts +37 -13
- package/src/social/drafts.ts +7 -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 +111 -65
- package/src/social/media-kind.ts +68 -160
- 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/discord.ts +5 -2
- package/src/social/publish/index.ts +17 -5
- package/src/social/publish/secret.ts +4 -4
- package/src/social/release-stage.ts +79 -63
- package/src/social/routes.ts +89 -24
- package/src/social/stage.ts +43 -58
- package/src/social/stats.ts +12 -9
- package/src/social/strip.ts +4 -1
- package/src/social/text.ts +4 -3
- package/src/social/thumbnail.ts +347 -0
- package/src/social/tracker.ts +1 -1
- package/src/social/writes.ts +12 -29
- package/src/stores/collection.ts +15 -11
- package/src/stores/desk.ts +246 -47
- package/src/stores/model.ts +72 -6
- package/src/stores/routes.ts +37 -12
- package/src/stores/unit.ts +16 -10
- 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/eleven.ts +33 -3
- 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 +360 -0
- package/src/vault/vault-import.ts +213 -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/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 -266
- package/src/social/migrate.ts +0 -123
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
// the move of a store's cards between its two backends (wiki tools/shipkit/threads-store.md): its files into the rows
|
|
2
|
+
// (`sk thread move --go`), the rows back into files (`sk thread move --back --go`, `sk thread export`). Both directions keep
|
|
3
|
+
// the later of two heads and every message by its id, so a move run twice, or stopped and run again, does what is left
|
|
4
|
+
// and nothing else. The one constraint a reader breaks first: nothing here deletes or rewrites a file or a row another
|
|
5
|
+
// write made later; a head the other side holds later stays, and is named
|
|
6
|
+
import { copyFileSync, existsSync, linkSync, mkdirSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
|
7
|
+
import { dirname, join, relative } from 'node:path'
|
|
8
|
+
import { rowsGone, rowsGoneCreated, rowsIO, rowsKeepGone, type CardBackend } from './card-rows.ts'
|
|
9
|
+
import { GONE, goneFolderCreated, goneFolders } from './gone.ts'
|
|
10
|
+
import { ID_RE, itemProblems, mediaFilesOf, MESSAGE_RE, messageProblems, type Message } from './model.ts'
|
|
11
|
+
import { revOf } from './rev.ts'
|
|
12
|
+
import { BUSY_MS } from '../ledger/db.ts'
|
|
13
|
+
import { filesIO } from './store.ts'
|
|
14
|
+
|
|
15
|
+
/** what one pass did for one store: heads and messages written, cards set aside carried, cards both sides hold alike,
|
|
16
|
+
* a line for each one left as it was, a line for each file that does not read */
|
|
17
|
+
export type Moved = { dir: string; cards: number; heads: number; msgs: number; gone: number; same: number; files: number; kept: string[]; broken: string[]; media?: { copied: number; missing: string[] }; read: { id: string; msgs: string[] }[] }
|
|
18
|
+
|
|
19
|
+
const fresh = (dir: string): Moved => ({ dir, cards: 0, heads: 0, msgs: 0, gone: 0, same: 0, files: 0, kept: [], broken: [], read: [] })
|
|
20
|
+
|
|
21
|
+
/** the files of a card's folder that are its media (its pictures, clips, posters, a message's image), never its head,
|
|
22
|
+
* its messages or its lock: what the rows keep in the spool */
|
|
23
|
+
function mediaOf(folder: string): string[] {
|
|
24
|
+
if (!existsSync(folder)) return []
|
|
25
|
+
const out: string[] = []
|
|
26
|
+
const walk = (d: string): void => {
|
|
27
|
+
for (const e of readdirSync(d, { withFileTypes: true })) {
|
|
28
|
+
const f = join(d, e.name)
|
|
29
|
+
const rel = relative(folder, f)
|
|
30
|
+
if (e.isDirectory()) {
|
|
31
|
+
if (e.name !== '.lock') walk(f)
|
|
32
|
+
} else if (!/^item(\.replaced)?\.json$/.test(rel) && !(rel.startsWith('thread/') && rel.endsWith('.json')) && !e.name.endsWith('.tmp')) out.push(rel)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
walk(folder)
|
|
36
|
+
return out
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** a card's media the other side lacks, linked there (copied across two disks): the side they come from stays as it is */
|
|
40
|
+
function carryMedia(id: string, from: CardBackend, to: CardBackend, out: Moved, dry: boolean): void {
|
|
41
|
+
const src = from.folder(id)
|
|
42
|
+
const dst = to.folder(id)
|
|
43
|
+
if (src === dst) return
|
|
44
|
+
for (const rel of mediaOf(src)) {
|
|
45
|
+
const t = join(dst, rel)
|
|
46
|
+
if (existsSync(t)) continue
|
|
47
|
+
out.files++
|
|
48
|
+
if (dry) continue
|
|
49
|
+
mkdirSync(dirname(t), { recursive: true })
|
|
50
|
+
try {
|
|
51
|
+
linkSync(join(src, rel), t)
|
|
52
|
+
} catch {
|
|
53
|
+
copyFileSync(join(src, rel), t)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** a card from one backend into the other: its head when the target lacks it or holds an older one, each message the
|
|
59
|
+
* target lacks. The head the target holds later stays */
|
|
60
|
+
/** the cards a side set aside, as `<id> <created>`: a card the other side still holds is not carried back over its
|
|
61
|
+
* deletion */
|
|
62
|
+
function goneOf(dir: string, rows: boolean): Set<string> {
|
|
63
|
+
if (rows) return new Set(rowsGone(dir).map((g) => `${g.id} ${rowsGoneCreated(dir, g.entry) ?? ''}`))
|
|
64
|
+
try {
|
|
65
|
+
return new Set(goneFolders(dir).map((g) => `${g.id} ${goneFolderCreated(dir, g.entry) ?? ''}`))
|
|
66
|
+
} catch {
|
|
67
|
+
return new Set()
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** one card carried from one side into the other while a move runs: a verb of a process that read the switch before it
|
|
72
|
+
* turned made it on the side the move left */
|
|
73
|
+
export function carryCard(dir: string, id: string, from: CardBackend, to: CardBackend): void {
|
|
74
|
+
copyCard(id, from, to, fresh(dir), false, goneOf(dir, to.rows))
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function copyCard(id: string, from: CardBackend, to: CardBackend, out: Moved, dry: boolean, gone: ReadonlySet<string>): void {
|
|
78
|
+
let h: { head: unknown; at: number } | null
|
|
79
|
+
try {
|
|
80
|
+
h = from.head(id)
|
|
81
|
+
} catch (e) {
|
|
82
|
+
out.broken.push(`${id}: ${(e as Error).message}`)
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
if (h == null) {
|
|
86
|
+
if (!from.rows) out.broken.push(`${id}: a folder with no item.json`)
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
const problems = itemProblems(h.head)
|
|
90
|
+
if (problems.length > 0 || (h.head as { id?: unknown }).id !== id) {
|
|
91
|
+
out.broken.push(`${id}: ${problems.join('; ') || 'another id in its head'}`)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
if (to.head(id) == null && gone.has(`${id} ${String((h.head as { created?: unknown }).created ?? '')}`)) {
|
|
95
|
+
out.kept.push(`${id}: deleted on the other side, it stays deleted`)
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
const msgs: Message[] = []
|
|
99
|
+
for (const mid of from.threadIds(id)) {
|
|
100
|
+
try {
|
|
101
|
+
const m = from.message(id, mid)
|
|
102
|
+
const p = MESSAGE_RE.test(mid) ? messageProblems(m, mid) : ['no message name']
|
|
103
|
+
if (p.length > 0) out.broken.push(`${id}/${mid}: ${p.join('; ')}`)
|
|
104
|
+
else msgs.push(m as Message)
|
|
105
|
+
} catch (e) {
|
|
106
|
+
out.broken.push(`${id}/${mid}: ${(e as Error).message}`)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
out.cards++
|
|
110
|
+
let there: { head: unknown; at: number } | null = null
|
|
111
|
+
try {
|
|
112
|
+
there = to.head(id)
|
|
113
|
+
} catch (e) {
|
|
114
|
+
out.kept.push(`${id}: its head on the other side does not read (${(e as Error).message}), it stays as it is`)
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
if (there != null && (there.head as { created?: unknown }).created !== (h.head as { created?: unknown }).created) {
|
|
118
|
+
out.kept.push(`${id}: another item of that id is on the other side, made at another moment: each stays`)
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
if (there == null || revOf(there.head) !== revOf(h.head)) {
|
|
122
|
+
if (there != null && there.at > h.at) out.kept.push(`${id}: the other side holds a later head, it stays`)
|
|
123
|
+
else {
|
|
124
|
+
if (!dry) {
|
|
125
|
+
if (!to.rows) mkdirSync(to.folder(id), { recursive: true })
|
|
126
|
+
// the head it replaces is an earlier write of the same card on this machine
|
|
127
|
+
to.write(id, h.head, h.at)
|
|
128
|
+
}
|
|
129
|
+
out.heads++
|
|
130
|
+
}
|
|
131
|
+
} else out.same++
|
|
132
|
+
for (const m of msgs) {
|
|
133
|
+
if (to.hasMessage(id, m.id)) {
|
|
134
|
+
if (revOf(to.message(id, m.id)) !== revOf(m)) out.kept.push(`${id}/${m.id}: another message of that id is on the other side, each stays`)
|
|
135
|
+
continue
|
|
136
|
+
}
|
|
137
|
+
if (!dry) to.append(id, m)
|
|
138
|
+
out.msgs++
|
|
139
|
+
}
|
|
140
|
+
out.read.push({ id, msgs: msgs.map((m) => m.id) })
|
|
141
|
+
carryMedia(id, from, to, out, dry)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** every card file of a store the rows lack, into the rows, with its cards set aside. `dry` counts and writes nothing */
|
|
145
|
+
export function importFiles(dir: string, o: { dry?: boolean } = {}): Moved {
|
|
146
|
+
const out = fresh(dir)
|
|
147
|
+
const from = filesIO(dir)
|
|
148
|
+
const to = rowsIO(dir)
|
|
149
|
+
const deleted = goneOf(dir, true)
|
|
150
|
+
for (const id of from.names()) {
|
|
151
|
+
if (!ID_RE.test(id)) continue
|
|
152
|
+
copyCard(id, from, to, out, o.dry === true, deleted)
|
|
153
|
+
}
|
|
154
|
+
const held = new Set(rowsGone(dir).map((g) => g.entry))
|
|
155
|
+
let gone: { id: string; entry: string }[] = []
|
|
156
|
+
try {
|
|
157
|
+
gone = goneFolders(dir)
|
|
158
|
+
} catch (e) {
|
|
159
|
+
out.broken.push(`${GONE}: ${(e as Error).message}`)
|
|
160
|
+
}
|
|
161
|
+
for (const g of gone) {
|
|
162
|
+
if (held.has(g.entry)) continue
|
|
163
|
+
const folder = join(dir, GONE, g.entry)
|
|
164
|
+
try {
|
|
165
|
+
const head = JSON.parse(readFileSync(join(folder, 'item.json'), 'utf8')) as { created?: unknown }
|
|
166
|
+
const t = join(folder, 'thread')
|
|
167
|
+
const thread = existsSync(t) ? readdirSync(t).filter((n) => n.endsWith('.json')).sort().map((n) => JSON.parse(readFileSync(join(t, n), 'utf8')) as unknown) : []
|
|
168
|
+
if (!o.dry) rowsKeepGone(dir, { entry: g.entry, id: g.id, created: typeof head.created === 'string' ? head.created : '', at: Math.floor(statSync(folder).ctimeMs), head, thread })
|
|
169
|
+
out.gone++
|
|
170
|
+
} catch (e) {
|
|
171
|
+
out.broken.push(`${GONE}/${g.entry}: ${(e as Error).message}`)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return out
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** every card of the rows into files: the store's own folder (`--back`), or a folder of its own (`to`, an export, with
|
|
178
|
+
* the media files this machine holds). `ids`: those cards only. A card the rows set aside that the files still hold
|
|
179
|
+
* goes aside in the files too */
|
|
180
|
+
export function exportRows(dir: string, o: { to?: string; ids?: readonly string[]; dry?: boolean } = {}): Moved {
|
|
181
|
+
const out = fresh(dir)
|
|
182
|
+
const from = rowsIO(dir)
|
|
183
|
+
const target = o.to ?? dir
|
|
184
|
+
const to = filesIO(target)
|
|
185
|
+
const ids = o.ids ?? from.names()
|
|
186
|
+
const deleted = goneOf(target, false)
|
|
187
|
+
for (const id of ids) {
|
|
188
|
+
if (!from.has(id)) {
|
|
189
|
+
out.kept.push(`${id}: no item of that id in the rows`)
|
|
190
|
+
continue
|
|
191
|
+
}
|
|
192
|
+
const was = out.files
|
|
193
|
+
copyCard(id, from, to, out, o.dry === true, deleted)
|
|
194
|
+
if (o.to != null && !o.dry) {
|
|
195
|
+
out.media ??= { copied: 0, missing: [] }
|
|
196
|
+
out.media.copied += out.files - was
|
|
197
|
+
const x = from.raw(id)
|
|
198
|
+
// a file the Space holds and this disk let go: said, the export does not fetch it
|
|
199
|
+
for (const name of x == null ? [] : mediaFilesOf(x)) if (!existsSync(join(from.folder(id), name))) out.media.missing.push(`${id}/${name}`)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (o.to == null && o.ids == null)
|
|
203
|
+
for (const g of rowsGone(dir)) {
|
|
204
|
+
const cur = to.head(g.id)
|
|
205
|
+
const created = (cur?.head as { created?: unknown } | undefined)?.created
|
|
206
|
+
if (cur == null || created !== rowsGoneCreated(dir, g.entry)) continue
|
|
207
|
+
if (!o.dry) to.setAside(g.id, { created: String(created) })
|
|
208
|
+
out.gone++
|
|
209
|
+
}
|
|
210
|
+
return out
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** what an import read that the rows do not hold: a card, or a message of one */
|
|
214
|
+
function unproven(p: Moved): string[] {
|
|
215
|
+
const rows = rowsIO(p.dir)
|
|
216
|
+
return p.read.flatMap((r) => (rows.has(r.id) ? r.msgs.filter((m) => !rows.hasMessage(r.id, m)).map((m) => `message ${r.id}/${m}`) : [`card ${r.id}`]))
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** what the files hold that the rows do not, by name and rev: a head the rows lack or hold older, a message they lack.
|
|
220
|
+
* Empty once a move took everything */
|
|
221
|
+
export function filesNotInRows(dir: string): string[] {
|
|
222
|
+
const files = filesIO(dir)
|
|
223
|
+
const rows = rowsIO(dir)
|
|
224
|
+
const deleted = goneOf(dir, true)
|
|
225
|
+
const out: string[] = []
|
|
226
|
+
for (const id of files.names()) {
|
|
227
|
+
if (!ID_RE.test(id)) continue
|
|
228
|
+
let h: { head: unknown; at: number } | null
|
|
229
|
+
try {
|
|
230
|
+
h = files.head(id)
|
|
231
|
+
} catch {
|
|
232
|
+
continue
|
|
233
|
+
}
|
|
234
|
+
if (h == null || itemProblems(h.head).length > 0) continue
|
|
235
|
+
const r = rows.head(id)
|
|
236
|
+
// a card the rows set aside after the move began: deleted, not missing
|
|
237
|
+
if (r == null && deleted.has(`${id} ${String((h.head as { created?: unknown }).created ?? '')}`)) continue
|
|
238
|
+
if (r == null) out.push(`card ${id}`)
|
|
239
|
+
else if (revOf(r.head) !== revOf(h.head) && !(r.at > h.at)) out.push(`card ${id} (another head)`)
|
|
240
|
+
for (const mid of files.threadIds(id))
|
|
241
|
+
if (!rows.hasMessage(id, mid)) {
|
|
242
|
+
try {
|
|
243
|
+
if (messageProblems(files.message(id, mid), mid).length === 0) out.push(`message ${id}/${mid}`)
|
|
244
|
+
} catch {
|
|
245
|
+
// a message that does not read is the broken line of the move
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return out
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** a pass's lines, one a store that did something */
|
|
253
|
+
function passLines(passes: readonly Moved[], would: boolean): string[] {
|
|
254
|
+
const w = would ? 'would ' : ''
|
|
255
|
+
const lines: string[] = []
|
|
256
|
+
for (const p of passes) {
|
|
257
|
+
if (p.heads + p.msgs + p.gone + p.files > 0 || would) lines.push(`${p.dir}: ${p.cards} cards, ${w}write ${p.heads} heads and ${p.msgs} messages, ${w === '' ? '' : 'would '}carry ${p.files} media files, ${p.gone} cards set aside, ${p.same} alike`)
|
|
258
|
+
for (const k of p.kept.slice(0, 5)) lines.push(` kept: ${k}`)
|
|
259
|
+
if (p.kept.length > 5) lines.push(` kept: and ${p.kept.length - 5} more`)
|
|
260
|
+
// a folder that does not read stays a folder: never a row, never lost, said here
|
|
261
|
+
if (p.broken.length > 0) lines.push(` ${p.broken.length} files do not read and stay as they are (${p.broken.slice(0, 3).join('; ')})`)
|
|
262
|
+
}
|
|
263
|
+
return lines
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** how long a writer may still commit to the store it read: its switch read (at most a second old), then a commit that
|
|
267
|
+
* waits its turn on the daemon's file (the busy timeout); the move reads the old store again after it */
|
|
268
|
+
export const MOVE_LAG_MS = 1000 + BUSY_MS + 1000
|
|
269
|
+
|
|
270
|
+
/** the line a machine whose cards are rows says at every move and every health pass: a shipkit older than the switch
|
|
271
|
+
* reads the files alone, so it would show none of the cards made since the move */
|
|
272
|
+
export const BACK_FIRST = 'the review cards of this machine are rows of the daemon\'s database: run `sk thread move --back --go` before any older shipkit runs here (a revert, a checkout, an older install)'
|
|
273
|
+
|
|
274
|
+
export type MoveOptions = {
|
|
275
|
+
dry: boolean
|
|
276
|
+
/** what the hq lacks of this machine's files, a line each; empty when both sides are equal; null skips (no hq) */
|
|
277
|
+
hqDiff?: () => Promise<string[] | null>
|
|
278
|
+
/** how long another process may still write what it read of the switch */
|
|
279
|
+
lagMs?: number
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** the move of this machine's cards into the rows: the files imported, every one proven in the rows, the switch on, the
|
|
283
|
+
* files read again after the lag for a writer that had not seen it. The files stay where they are, untouched */
|
|
284
|
+
export async function moveGo(stores: readonly string[], o: MoveOptions): Promise<{ ok: boolean; lines: string[] }> {
|
|
285
|
+
return o.dry ? goOnce(stores, o) : moving(o, () => goOnce(stores, o))
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** a move's run, its window said to every process: a verb that misses its card finds it on the other side meanwhile */
|
|
289
|
+
async function moving<T>(o: MoveOptions, fn: () => Promise<T>): Promise<T> {
|
|
290
|
+
const { setCardsMoving } = await import('../hq/switch.ts')
|
|
291
|
+
setCardsMoving(Date.now() + 2 * (o.lagMs ?? MOVE_LAG_MS) + 10 * 60_000)
|
|
292
|
+
try {
|
|
293
|
+
return await fn()
|
|
294
|
+
} finally {
|
|
295
|
+
setCardsMoving(null)
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
async function goOnce(stores: readonly string[], o: MoveOptions): Promise<{ ok: boolean; lines: string[] }> {
|
|
300
|
+
const { cardsInDb, setCardsInDb } = await import('../hq/switch.ts')
|
|
301
|
+
const lines: string[] = []
|
|
302
|
+
// the look asks the hq too: it says what --go would refuse
|
|
303
|
+
if (o.hqDiff != null) {
|
|
304
|
+
const d = await o.hqDiff()
|
|
305
|
+
if (d != null && d.length > 0) return { ok: false, lines: [`the hq and this machine do not hold the same cards (the check hq-cards): ${o.dry ? '--go would refuse, ' : ''}nothing moves until they do`, ...d] }
|
|
306
|
+
}
|
|
307
|
+
const first = stores.map((d) => importFiles(d, { dry: o.dry }))
|
|
308
|
+
lines.push(...passLines(first, o.dry))
|
|
309
|
+
if (o.dry) return { ok: true, lines: [`the switch cards-in-db is ${cardsInDb() ? 'on' : 'off'}`, ...lines] }
|
|
310
|
+
// the proof: every card and message the import read is in the rows. A writer still on the files may write after the
|
|
311
|
+
// read: that is the second pass's, after the switch and its lag
|
|
312
|
+
const left = first.flatMap((p) => unproven(p).map((l) => `${p.dir}: ${l}`))
|
|
313
|
+
if (left.length > 0) return { ok: false, lines: [...lines, `${left.length} rows the files hold are not in the rows after the import: the switch stays off`, ...left.slice(0, 20)] }
|
|
314
|
+
const was = cardsInDb()
|
|
315
|
+
if (!was && !setCardsInDb(true)) return { ok: false, lines: [...lines, 'the machine db does not open: the switch stays off'] }
|
|
316
|
+
// a writer that read the switch off before it moved may still write a file: read the files once more after it
|
|
317
|
+
await Bun.sleep(o.lagMs ?? MOVE_LAG_MS)
|
|
318
|
+
const second = stores.map((d) => importFiles(d))
|
|
319
|
+
const late = passLines(second, false)
|
|
320
|
+
const after = stores.flatMap((d) => filesNotInRows(d).map((l) => `${d}: ${l}`))
|
|
321
|
+
return {
|
|
322
|
+
ok: after.length === 0,
|
|
323
|
+
lines: [
|
|
324
|
+
...lines,
|
|
325
|
+
...(late.length > 0 ? ['read again after the switch:', ...late] : []),
|
|
326
|
+
...(after.length > 0 ? [`WARN ${after.length} files written after the switch are not in the rows: run sk thread move --go again`, ...after.slice(0, 20)] : []),
|
|
327
|
+
`ok: the switch cards-in-db is on${was ? ' (it was already)' : ''}: every thread is read and written in the daemon's database; the files stay where they are, untouched (sk thread move --back --go goes back)`,
|
|
328
|
+
],
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** each media file a card of the rows names that neither the spool nor the repo's folder holds (the media store sent it
|
|
333
|
+
* up and let it go), with the fetch that gives it back into the spool */
|
|
334
|
+
function onlyInSpace(dir: string): { what: string; fetch: () => Promise<string | null> }[] {
|
|
335
|
+
const rows = rowsIO(dir)
|
|
336
|
+
const out: { what: string; fetch: () => Promise<string | null> }[] = []
|
|
337
|
+
for (const id of rows.names()) {
|
|
338
|
+
const x = rows.raw(id)
|
|
339
|
+
if (x == null) continue
|
|
340
|
+
for (const name of mediaFilesOf(x)) {
|
|
341
|
+
const here = join(rows.folder(id), name)
|
|
342
|
+
if (existsSync(here) || existsSync(join(dir, id, name))) continue
|
|
343
|
+
const f = x.item.media?.[name]
|
|
344
|
+
const what = `${id}/${name}`
|
|
345
|
+
if (f == null) {
|
|
346
|
+
out.push({ what: `${what} (its head keeps no fact of it)`, fetch: async () => null })
|
|
347
|
+
continue
|
|
348
|
+
}
|
|
349
|
+
out.push({
|
|
350
|
+
what,
|
|
351
|
+
fetch: async () => {
|
|
352
|
+
const { fetchBack } = await import('../media-store/remote.ts')
|
|
353
|
+
const { reviewKey } = await import('./media-read.ts')
|
|
354
|
+
mkdirSync(dirname(here), { recursive: true })
|
|
355
|
+
return fetchBack(here, reviewKey(f, name), f, { store: dirname(rows.folder(id)), item: id, name })
|
|
356
|
+
},
|
|
357
|
+
})
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return out
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/** the way back: every card of the rows written into the files (a card made since included), the switch off, the rows
|
|
364
|
+
* written out again after the lag. The rows stay */
|
|
365
|
+
export async function moveBack(all: readonly string[], o: MoveOptions): Promise<{ ok: boolean; lines: string[] }> {
|
|
366
|
+
return o.dry ? backOnce(all, o) : moving(o, () => backOnce(all, o))
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
async function backOnce(all: readonly string[], o: MoveOptions): Promise<{ ok: boolean; lines: string[] }> {
|
|
370
|
+
const { cardsInDb, setCardsInDb } = await import('../hq/switch.ts')
|
|
371
|
+
// one folder a repo: a worktree shares its checkout's rows, which go back into the checkout's folder alone
|
|
372
|
+
const { repoIdOf } = await import('./card-db.ts')
|
|
373
|
+
const seen = new Set<string>()
|
|
374
|
+
const stores = all.filter((d) => {
|
|
375
|
+
const id = repoIdOf(d)
|
|
376
|
+
if (seen.has(id)) return false
|
|
377
|
+
seen.add(id)
|
|
378
|
+
return true
|
|
379
|
+
})
|
|
380
|
+
// the files go back whole: a media file the spool let go comes back from the Space first, or nothing moves
|
|
381
|
+
const away = stores.flatMap((d) => onlyInSpace(d))
|
|
382
|
+
if (o.dry && away.length > 0) {
|
|
383
|
+
const lines = passLines(stores.map((d) => exportRows(d, { dry: true })), true)
|
|
384
|
+
return { ok: true, lines: [`the switch cards-in-db is ${cardsInDb() ? 'on' : 'off'}`, ...lines, `${away.length} media files are only in the Space: --back --go fetches them first, and refuses if the Space is not reached`] }
|
|
385
|
+
}
|
|
386
|
+
const lacking: string[] = []
|
|
387
|
+
for (const a of away) if ((await a.fetch()) == null) lacking.push(a.what)
|
|
388
|
+
if (lacking.length > 0) return { ok: false, lines: [`${lacking.length} media files would be lacking in the files: neither this disk nor the Space gives them back, nothing moved`, ...lacking.slice(0, 20)] }
|
|
389
|
+
const first = stores.map((d) => exportRows(d, { dry: o.dry }))
|
|
390
|
+
const lines = passLines(first, o.dry)
|
|
391
|
+
if (away.length > 0) lines.push(`${away.length} media files fetched back from the Space first`)
|
|
392
|
+
if (o.dry) return { ok: true, lines: [`the switch cards-in-db is ${cardsInDb() ? 'on' : 'off'}`, ...lines] }
|
|
393
|
+
const was = cardsInDb()
|
|
394
|
+
if (was && !setCardsInDb(false)) return { ok: false, lines: [...lines, 'the machine db does not open: the switch stays on'] }
|
|
395
|
+
await Bun.sleep(o.lagMs ?? MOVE_LAG_MS)
|
|
396
|
+
const second = stores.map((d) => exportRows(d))
|
|
397
|
+
const late = passLines(second, false)
|
|
398
|
+
return { ok: true, lines: [...lines, ...(late.length > 0 ? ['written out again after the switch:', ...late] : []), `ok: the switch cards-in-db is off${was ? '' : ' (it was already)'}: the files are the store again; the rows stay in the daemon's database`] }
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/** what the tidy asks outside the store: the names of a repo's rows the hq does not hold at their rev (`card <id>`,
|
|
402
|
+
* `card-msg <id>/<message>`), or why it cannot say; and whether the Space holds a file */
|
|
403
|
+
export type TidyProof = {
|
|
404
|
+
hqLacks: (dir: string) => Promise<Set<string> | { refused: string }>
|
|
405
|
+
up: (key: string, size: number) => Promise<boolean>
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** where a folder goes before it is removed: a tidy killed between the two leaves it there, and the next one ends it */
|
|
409
|
+
const TIDY = '.tidy'
|
|
410
|
+
|
|
411
|
+
/** the files of the cards that also live as rows, removed from each repo once the rows hold all of them, the hq holds
|
|
412
|
+
* them, and their media are in the Space; never while the switch is off. A look by default. After it, the way back
|
|
413
|
+
* writes the files again from the rows */
|
|
414
|
+
export async function tidyFiles(stores: readonly string[], o: { dry: boolean; proof: TidyProof }): Promise<{ ok: boolean; lines: string[] }> {
|
|
415
|
+
const { cardsInDb } = await import('../hq/switch.ts')
|
|
416
|
+
if (!cardsInDb()) return { ok: false, lines: ['the switch cards-in-db is off: the files are the store, the tidy removes nothing'] }
|
|
417
|
+
const { reviewKey } = await import('./media-read.ts')
|
|
418
|
+
const { renameSync, rmSync } = await import('node:fs')
|
|
419
|
+
const lines: string[] = []
|
|
420
|
+
let removed = 0
|
|
421
|
+
let kept = 0
|
|
422
|
+
for (const dir of stores) {
|
|
423
|
+
if (!o.dry && existsSync(join(dir, TIDY))) rmSync(join(dir, TIDY), { recursive: true, force: true })
|
|
424
|
+
const files = filesIO(dir)
|
|
425
|
+
const rows = rowsIO(dir)
|
|
426
|
+
const ids = files.names().filter((n) => ID_RE.test(n))
|
|
427
|
+
if (ids.length === 0) continue
|
|
428
|
+
const lacks = await o.proof.hqLacks(dir)
|
|
429
|
+
if (!(lacks instanceof Set)) {
|
|
430
|
+
lines.push(`${dir}: ${ids.length} card folders stay: ${lacks.refused}`)
|
|
431
|
+
kept += ids.length
|
|
432
|
+
continue
|
|
433
|
+
}
|
|
434
|
+
const stay: string[] = []
|
|
435
|
+
let gone = 0
|
|
436
|
+
for (const id of ids) {
|
|
437
|
+
const why = await keepWhy(dir, id, files, rows, lacks, o.proof, reviewKey)
|
|
438
|
+
if (why != null) {
|
|
439
|
+
stay.push(`${id}: ${why}`)
|
|
440
|
+
continue
|
|
441
|
+
}
|
|
442
|
+
gone++
|
|
443
|
+
if (o.dry) continue
|
|
444
|
+
const aside = join(dir, TIDY, id)
|
|
445
|
+
mkdirSync(dirname(aside), { recursive: true })
|
|
446
|
+
renameSync(join(dir, id), aside)
|
|
447
|
+
rmSync(aside, { recursive: true, force: true })
|
|
448
|
+
}
|
|
449
|
+
if (!o.dry) rmSync(join(dir, TIDY), { recursive: true, force: true })
|
|
450
|
+
removed += gone
|
|
451
|
+
kept += stay.length
|
|
452
|
+
lines.push(`${dir}: ${o.dry ? 'would remove' : 'removed'} ${gone} card folders, ${stay.length} stay`)
|
|
453
|
+
for (const s of stay.slice(0, 5)) lines.push(` stays: ${s}`)
|
|
454
|
+
if (stay.length > 5) lines.push(` stays: and ${stay.length - 5} more`)
|
|
455
|
+
}
|
|
456
|
+
lines.push(`${o.dry ? 'a look: nothing removed. ' : ''}${removed} card folders ${o.dry ? 'would go' : 'gone'}, ${kept} stay; after it, sk thread move --back --go writes the files again from the rows, the media fetched back from the Space`)
|
|
457
|
+
return { ok: true, lines }
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/** why a card's folder stays, null when it may go: the rows hold its head (the same, or a later one of the same card)
|
|
461
|
+
* and each of its messages at the same rev, the hq holds every one of them, and the Space each media file it holds */
|
|
462
|
+
async function keepWhy(dir: string, id: string, files: CardBackend, rows: CardBackend, lacks: ReadonlySet<string>, proof: TidyProof, keyOf: (f: { sha: string }, name: string) => string): Promise<string | null> {
|
|
463
|
+
let h: { head: unknown; at: number } | null
|
|
464
|
+
try {
|
|
465
|
+
h = files.head(id)
|
|
466
|
+
} catch (e) {
|
|
467
|
+
return `its head does not read (${(e as Error).message})`
|
|
468
|
+
}
|
|
469
|
+
if (h == null) return 'a folder with no head'
|
|
470
|
+
// the only copy of a head another machine's change replaced: the way back does not write it again
|
|
471
|
+
if (existsSync(join(dir, id, 'item.replaced.json'))) return 'it holds a replaced head (item.replaced.json), kept nowhere else'
|
|
472
|
+
const r = rows.head(id)
|
|
473
|
+
if (r == null) return 'its rows lack it'
|
|
474
|
+
const created = (x: unknown): unknown => (x as { created?: unknown }).created
|
|
475
|
+
if (revOf(r.head) !== revOf(h.head) && !(created(r.head) === created(h.head) && r.at >= h.at)) return 'its rows differ from its files'
|
|
476
|
+
const mids = files.threadIds(id)
|
|
477
|
+
for (const m of mids) {
|
|
478
|
+
if (!rows.hasMessage(id, m)) return `its rows lack the message ${m}`
|
|
479
|
+
if (revOf(rows.message(id, m)) !== revOf(files.message(id, m))) return `its message ${m} differs in the rows`
|
|
480
|
+
}
|
|
481
|
+
if (lacks.has(`card ${id}`) || mids.some((m) => lacks.has(`card-msg ${id}/${m}`))) return 'the hq does not hold all of it'
|
|
482
|
+
const x = files.raw(id)
|
|
483
|
+
const media = (x?.item.media ?? {}) as Record<string, { sha: string; size: number }>
|
|
484
|
+
for (const name of x == null ? [] : mediaFilesOf(x)) {
|
|
485
|
+
if (!existsSync(join(dir, id, name))) continue
|
|
486
|
+
const f = media[name]
|
|
487
|
+
if (f == null) return `its file ${name} has no fact in its head`
|
|
488
|
+
if (!(await proof.up(keyOf(f, name), f.size))) return `its file ${name} is not in the Space`
|
|
489
|
+
}
|
|
490
|
+
return null
|
|
491
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// the address of a need's thread (wiki tools/shipkit/threads-how-it-fits.md, The model): `check:<repo>/<id>`,
|
|
2
|
+
// `reflection:<repo>/<file>`. Pure and browser safe: the sync (need-threads.ts) writes by it, the inbox pairs a need
|
|
3
|
+
// with its thread by it
|
|
4
|
+
import type { Resource } from '../collections/collection-types.ts'
|
|
5
|
+
import { canonicalAddress } from './model.ts'
|
|
6
|
+
|
|
7
|
+
/** the collections whose needs are threads, and the kind word of their address */
|
|
8
|
+
export const NEED_KINDS: Readonly<Record<string, string>> = { checks: 'check', reflections: 'reflection' }
|
|
9
|
+
|
|
10
|
+
/** a need's thread address, null for a need of another collection */
|
|
11
|
+
export function needAddress(repo: string, n: Pick<Resource, 'collection' | 'id'>): string | null {
|
|
12
|
+
const kind = NEED_KINDS[n.collection]
|
|
13
|
+
if (kind === undefined || !n.id.startsWith(`${kind}:`)) return null
|
|
14
|
+
return canonicalAddress(`${kind}:${repo}/${n.id.slice(kind.length + 1)}`)
|
|
15
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// a failing check is a thread (wiki tools/shipkit/threads-how-it-fits.md, The model): one per address, `check:<repo>/<id>`,
|
|
2
|
+
// opened and kept by the machine from the hub's needs. A need that stands writes `broken` once; a need gone writes
|
|
3
|
+
// `fixed`, so the thread reads working, then done; never his turn. A reflection is an object (review/reflection-object.ts):
|
|
4
|
+
// no thread opens for its file here; a thread opened on it by the owner's act gets `fixed` once its file is gone.
|
|
5
|
+
//
|
|
6
|
+
// the one constraint a reader breaks first: a collection whose read broke (its `<collection>:broken` row) closes nothing,
|
|
7
|
+
// or one broken read would close every thread of it
|
|
8
|
+
import type { Resource } from '../collections/collection-types.ts'
|
|
9
|
+
import { canonicalAddress, updatesOf, type UpdateState } from './model.ts'
|
|
10
|
+
import { NEED_KINDS, needAddress } from './need-address.ts'
|
|
11
|
+
import { openThread, postUpdate, readAll, storeDir, storeStamp, updateHead } from './store.ts'
|
|
12
|
+
import { orderedThreads, turnOf, type Thread } from './threads.ts'
|
|
13
|
+
|
|
14
|
+
export interface NeedSync {
|
|
15
|
+
opened: number
|
|
16
|
+
/** a thread that was fixed, broken again */
|
|
17
|
+
broken: number
|
|
18
|
+
fixed: number
|
|
19
|
+
/** already as the needs say: nothing written */
|
|
20
|
+
same: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const LINE_MAX = 300
|
|
24
|
+
const lineOf = (t: string): string => {
|
|
25
|
+
const l = t.split('\n').find((x) => x.trim() !== '')?.trim() ?? ''
|
|
26
|
+
return l.length > LINE_MAX ? `${l.slice(0, LINE_MAX - 1)}…` : l
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const lastState = (t: Thread): UpdateState | null => updatesOf(t.head).at(-1)?.update?.state ?? null
|
|
30
|
+
|
|
31
|
+
/** what a check's thread opens with: its line and its last wire lines */
|
|
32
|
+
const openingOf = (n: Resource): string => [n.text, n.md].filter((x) => x != null && x !== '').join('\n\n')
|
|
33
|
+
|
|
34
|
+
/** per store, what the last sync saw: the same needs on an unmoved store write nothing and read nothing */
|
|
35
|
+
const seen = new Map<string, string>()
|
|
36
|
+
|
|
37
|
+
/** the store of `root` made to match its needs: a thread opened or broken again for each check need, a thread fixed
|
|
38
|
+
* for each one whose need is gone; a reflection opens none, and a thread opened on one is fixed once its file is gone.
|
|
39
|
+
* Re-runnable: what already stands writes nothing */
|
|
40
|
+
export async function syncNeedThreads(root: string, repo: string, needs: readonly Resource[], now = new Date()): Promise<NeedSync> {
|
|
41
|
+
const out: NeedSync = { opened: 0, broken: 0, fixed: 0, same: 0 }
|
|
42
|
+
const dir = storeDir(root)
|
|
43
|
+
const broken = new Set(needs.filter((n) => n.id === `${n.collection}:broken`).map((n) => n.collection))
|
|
44
|
+
const want = new Map<string, Resource>()
|
|
45
|
+
// the reflections whose file stands: a thread on one stays as it is, a thread on one gone is fixed
|
|
46
|
+
const standing = new Set<string>()
|
|
47
|
+
for (const n of needs) {
|
|
48
|
+
const a = n.severity != null && !broken.has(n.collection) ? needAddress(repo, n) : null
|
|
49
|
+
if (a === null) continue
|
|
50
|
+
if (a.startsWith('reflection:')) standing.add(a)
|
|
51
|
+
else want.set(a, n)
|
|
52
|
+
}
|
|
53
|
+
const needsKey = `${[...want].map(([a, n]) => `${a}=${n.title || n.label}`).sort().join('\n')}|${[...standing].sort().join(' ')}|${[...broken].sort().join(' ')}`
|
|
54
|
+
if (seen.get(dir) === `${needsKey}|${storeStamp(dir)}`) return { ...out, same: want.size }
|
|
55
|
+
const prefixes = Object.entries(NEED_KINDS)
|
|
56
|
+
.filter(([col]) => !broken.has(col))
|
|
57
|
+
.map(([, kind]) => canonicalAddress(`${kind}:${repo}/x`)!.slice(0, -1))
|
|
58
|
+
const mine = new Map<string, Thread>()
|
|
59
|
+
for (const t of orderedThreads(readAll(dir).items)) {
|
|
60
|
+
const a = t.head.item.on !== undefined ? canonicalAddress(t.head.item.on) : null
|
|
61
|
+
if (a !== null && t.head.item.origin.by === 'agent' && Object.values(NEED_KINDS).some((k) => a.startsWith(`${k}:`)) && !mine.has(a)) mine.set(a, t)
|
|
62
|
+
}
|
|
63
|
+
const update = (id: string, state: UpdateState, text: string): Promise<unknown> => postUpdate(dir, id, { who: 'agent', state, text, machine: true, now })
|
|
64
|
+
for (const [a, n] of want) {
|
|
65
|
+
const t = mine.get(a)
|
|
66
|
+
// the hub's needs route sends the label alone, the in process needs the title too
|
|
67
|
+
const title = n.title || n.label || n.id
|
|
68
|
+
if (t === undefined) {
|
|
69
|
+
const item = await openThread(dir, a, { title, what: openingOf(n), machine: true, now })
|
|
70
|
+
await update(item.id, 'broken', lineOf(n.text))
|
|
71
|
+
out.opened++
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
// a check renamed keeps its thread, under its new name
|
|
75
|
+
if (t.head.item.title !== title) updateHead(dir, t.head.item.id, (cur) => ({ ...cur, title }))
|
|
76
|
+
if (lastState(t) !== 'broken') {
|
|
77
|
+
await update(t.head.item.id, 'broken', lineOf(n.text))
|
|
78
|
+
out.broken++
|
|
79
|
+
} else out.same++
|
|
80
|
+
}
|
|
81
|
+
for (const [a, t] of mine) {
|
|
82
|
+
if (want.has(a) || standing.has(a) || !prefixes.some((p) => a.startsWith(p))) continue
|
|
83
|
+
const last = lastState(t)
|
|
84
|
+
const reflection = a.startsWith('reflection:')
|
|
85
|
+
// a check's thread is fixed from broken; a reflection's thread, opened by the owner's act with no update, from anything not done
|
|
86
|
+
if (reflection ? last === 'fixed' || turnOf(t) === 'done' : last !== 'broken' && last !== 'better') continue
|
|
87
|
+
await update(t.head.item.id, 'fixed', reflection ? 'folded: its file is gone from .shipkit/reflections/' : 'no longer fails or warns')
|
|
88
|
+
out.fixed++
|
|
89
|
+
}
|
|
90
|
+
// the stamp after the writes: the next run on the same needs reads nothing
|
|
91
|
+
seen.set(dir, `${needsKey}|${storeStamp(dir)}`)
|
|
92
|
+
return out
|
|
93
|
+
}
|