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,235 @@
|
|
|
1
|
+
// the projections of the thread's events (wiki tools/shipkit/threads-events.md, Projections): one table a kind, indexed
|
|
2
|
+
// for its index page, moved only by an event. One step function a kind (`nextGroupRow`, `nextPostRow`) serves the append,
|
|
3
|
+
// the rebuild and the check, so the three never disagree. The one constraint a reader breaks first: nothing writes a
|
|
4
|
+
// projection but `projectEvent` and `rebuildProjections`
|
|
5
|
+
import type { Database } from 'bun:sqlite'
|
|
6
|
+
import type { ThreadEvent } from './events.ts'
|
|
7
|
+
|
|
8
|
+
export type PostState = 'draft' | 'posted' | 'dropped'
|
|
9
|
+
export const POST_STATES: readonly PostState[] = ['draft', 'posted', 'dropped']
|
|
10
|
+
|
|
11
|
+
/** where a posted moment came from: the link's own id, the commit that recorded it (an import), his mark, nowhere */
|
|
12
|
+
export type PostedFrom = 'id' | 'commit' | 'mark' | 'unknown'
|
|
13
|
+
|
|
14
|
+
/** a post event's own part, under `content.post`; its words are the standard `body`, a venue title its `title` */
|
|
15
|
+
export interface PostContent {
|
|
16
|
+
/** its group's slug */
|
|
17
|
+
group: string
|
|
18
|
+
/** the account, `<account>/<name>` for one of several there */
|
|
19
|
+
key: string
|
|
20
|
+
/** the account; a group word (`short`) for a post that waits for an account of the group */
|
|
21
|
+
platform: string
|
|
22
|
+
/** a place of the account (a channel, a sub); empty, the account's own */
|
|
23
|
+
place: string
|
|
24
|
+
/** the text form's heading options but `name` and `place`: title, tags, media, rating, pin, embeds, tier, outro, mark */
|
|
25
|
+
options: Record<string, string>
|
|
26
|
+
/** the group heading it was written under (`short`, `vertical`), empty for an account's own */
|
|
27
|
+
format: string
|
|
28
|
+
state: PostState
|
|
29
|
+
url?: string
|
|
30
|
+
postedAt?: number | null
|
|
31
|
+
postedFrom?: PostedFrom
|
|
32
|
+
/** its words' versions, 1 for the first */
|
|
33
|
+
version: number
|
|
34
|
+
/** what moved it: `import`, `stage`, `save`, `text`, `posted`, `clear`, `publish`, `drop`, `undrop`, `discard`, `restore` */
|
|
35
|
+
why: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** a group event's own part, under `content.group`; its title and angle are the standard `title` and `body` */
|
|
39
|
+
export interface GroupContent {
|
|
40
|
+
slug: string
|
|
41
|
+
/** who speaks, resolved when it was written: its `speaksAs`, else the repo's */
|
|
42
|
+
identity: string
|
|
43
|
+
/** the text form's front matter but `title`, `status`, `media` and `dropped` */
|
|
44
|
+
meta: Record<string, string>
|
|
45
|
+
/** the media a post with none of its own attaches, the first first */
|
|
46
|
+
media: string[]
|
|
47
|
+
/** a long devlog post's bytes, null without one */
|
|
48
|
+
article: string | null
|
|
49
|
+
picked?: true
|
|
50
|
+
version: number
|
|
51
|
+
why: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const groupOf = (e: ThreadEvent): GroupContent => e.content.group as GroupContent
|
|
55
|
+
export const postOf = (e: ThreadEvent): PostContent => e.content.post as PostContent
|
|
56
|
+
|
|
57
|
+
export interface GroupRow {
|
|
58
|
+
repo: string
|
|
59
|
+
slug: string
|
|
60
|
+
title: string
|
|
61
|
+
kind: string
|
|
62
|
+
identity: string
|
|
63
|
+
rating: string
|
|
64
|
+
release: string
|
|
65
|
+
drafts: number
|
|
66
|
+
posted: number
|
|
67
|
+
dropped: number
|
|
68
|
+
version: number
|
|
69
|
+
first_seq: number
|
|
70
|
+
last_seq: number
|
|
71
|
+
first_at: number
|
|
72
|
+
last_at: number
|
|
73
|
+
event: string
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface PostRow {
|
|
77
|
+
repo: string
|
|
78
|
+
slug: string
|
|
79
|
+
key: string
|
|
80
|
+
platform: string
|
|
81
|
+
place: string
|
|
82
|
+
state: PostState
|
|
83
|
+
url: string
|
|
84
|
+
posted_at: number | null
|
|
85
|
+
title: string
|
|
86
|
+
version: number
|
|
87
|
+
first_seq: number
|
|
88
|
+
last_seq: number
|
|
89
|
+
first_at: number
|
|
90
|
+
last_at: number
|
|
91
|
+
event: string
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** the groups row after one more group event; its counts are its posts', set by `countPosts` */
|
|
95
|
+
export function nextGroupRow(prev: GroupRow | null, e: ThreadEvent): GroupRow {
|
|
96
|
+
const g = groupOf(e)
|
|
97
|
+
return {
|
|
98
|
+
repo: e.repo,
|
|
99
|
+
slug: g.slug,
|
|
100
|
+
title: e.content.title ?? '',
|
|
101
|
+
kind: g.meta['kind'] ?? '',
|
|
102
|
+
identity: g.identity,
|
|
103
|
+
rating: g.meta['rating'] ?? '',
|
|
104
|
+
release: g.meta['release'] ?? '',
|
|
105
|
+
drafts: prev?.drafts ?? 0,
|
|
106
|
+
posted: prev?.posted ?? 0,
|
|
107
|
+
dropped: prev?.dropped ?? 0,
|
|
108
|
+
version: g.version,
|
|
109
|
+
first_seq: prev?.first_seq ?? e.seq,
|
|
110
|
+
last_seq: e.seq,
|
|
111
|
+
first_at: prev?.first_at ?? e.at,
|
|
112
|
+
last_at: e.at,
|
|
113
|
+
event: e.id,
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** the posts row after one more post event */
|
|
118
|
+
export function nextPostRow(prev: PostRow | null, e: ThreadEvent): PostRow {
|
|
119
|
+
const p = postOf(e)
|
|
120
|
+
return {
|
|
121
|
+
repo: e.repo,
|
|
122
|
+
slug: p.group,
|
|
123
|
+
key: p.key,
|
|
124
|
+
platform: p.platform,
|
|
125
|
+
place: p.place,
|
|
126
|
+
state: p.state,
|
|
127
|
+
url: p.state === 'posted' ? (p.url ?? '') : '',
|
|
128
|
+
posted_at: p.state === 'posted' ? (p.postedAt ?? null) : null,
|
|
129
|
+
title: e.content.title ?? '',
|
|
130
|
+
version: p.version,
|
|
131
|
+
first_seq: prev?.first_seq ?? e.seq,
|
|
132
|
+
last_seq: e.seq,
|
|
133
|
+
first_at: prev?.first_at ?? e.at,
|
|
134
|
+
last_at: e.at,
|
|
135
|
+
event: e.id,
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const GROUP_COLS = ['repo', 'slug', 'title', 'kind', 'identity', 'rating', 'release', 'drafts', 'posted', 'dropped', 'version', 'first_seq', 'last_seq', 'first_at', 'last_at', 'event'] as const
|
|
140
|
+
const POST_COLS = ['repo', 'slug', 'key', 'platform', 'place', 'state', 'url', 'posted_at', 'title', 'version', 'first_seq', 'last_seq', 'first_at', 'last_at', 'event'] as const
|
|
141
|
+
|
|
142
|
+
const put = (db: Database, table: string, cols: readonly string[], r: object): void =>
|
|
143
|
+
void db.query(`insert or replace into ${table} (${cols.join(', ')}) values (${cols.map(() => '?').join(', ')})`).run(...cols.map((c) => (r as Record<string, string | number | null>)[c]!))
|
|
144
|
+
|
|
145
|
+
/** a group's posts counted by state */
|
|
146
|
+
function countPosts(db: Database, repo: string, slug: string): void {
|
|
147
|
+
const n = { draft: 0, posted: 0, dropped: 0 }
|
|
148
|
+
for (const r of db.query('select state, count(*) as n from thread_posts where repo = ? and slug = ? group by state').all(repo, slug) as { state: PostState; n: number }[]) n[r.state] = r.n
|
|
149
|
+
db.query('update thread_post_groups set drafts = ?, posted = ?, dropped = ? where repo = ? and slug = ?').run(n.draft, n.posted, n.dropped, repo, slug)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** moves the projection of one event's kind, inside the append's transaction */
|
|
153
|
+
export function projectEvent(db: Database, e: ThreadEvent): void {
|
|
154
|
+
if (e.stateKey == null) return
|
|
155
|
+
if (e.type === 'post-group') {
|
|
156
|
+
const prev = db.query('select * from thread_post_groups where repo = ? and slug = ?').get(e.repo, e.stateKey) as GroupRow | null
|
|
157
|
+
put(db, 'thread_post_groups', GROUP_COLS, nextGroupRow(prev, e))
|
|
158
|
+
countPosts(db, e.repo, e.stateKey)
|
|
159
|
+
} else if (e.type === 'post') {
|
|
160
|
+
const p = postOf(e)
|
|
161
|
+
const prev = db.query('select * from thread_posts where repo = ? and slug = ? and key = ?').get(e.repo, p.group, p.key) as PostRow | null
|
|
162
|
+
put(db, 'thread_posts', POST_COLS, nextPostRow(prev, e))
|
|
163
|
+
countPosts(db, e.repo, p.group)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
type EvRow = Parameters<typeof import('./events.ts').eventOfRow>[0]
|
|
168
|
+
|
|
169
|
+
/** every projection as the events make it, folded in memory: what the rebuild writes and the check compares */
|
|
170
|
+
export function foldProjections(db: Database, unsure: string[] = []): { groups: Map<string, GroupRow>; posts: Map<string, PostRow> } {
|
|
171
|
+
const { eventOfRow } = require('./events.ts') as typeof import('./events.ts')
|
|
172
|
+
const groups = new Map<string, GroupRow>()
|
|
173
|
+
const posts = new Map<string, PostRow>()
|
|
174
|
+
for (const r of db.query("select * from thread_events where type in ('post-group', 'post') and state_key is not null order by seq").iterate() as Iterable<EvRow>) {
|
|
175
|
+
const e = eventOfRow(r)
|
|
176
|
+
if (e.type === 'post-group') {
|
|
177
|
+
const k = `${e.repo}\0${e.stateKey}`
|
|
178
|
+
groups.set(k, nextGroupRow(groups.get(k) ?? null, e))
|
|
179
|
+
} else {
|
|
180
|
+
const p = postOf(e)
|
|
181
|
+
if (`${p.group}/${p.key}` !== e.stateKey) unsure.push(`thread_events ${e.repo} ${e.id}: its state key is not its group and key`)
|
|
182
|
+
const k = `${e.repo}\0${p.group}\0${p.key}`
|
|
183
|
+
posts.set(k, nextPostRow(posts.get(k) ?? null, e))
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
for (const g of groups.values()) {
|
|
187
|
+
g.drafts = g.posted = g.dropped = 0
|
|
188
|
+
}
|
|
189
|
+
for (const p of posts.values()) {
|
|
190
|
+
const g = groups.get(`${p.repo}\0${p.slug}`)
|
|
191
|
+
if (g == null) {
|
|
192
|
+
unsure.push(`thread_posts ${p.repo} ${p.slug}/${p.key}: no group event makes its group`)
|
|
193
|
+
continue
|
|
194
|
+
}
|
|
195
|
+
g[p.state === 'draft' ? 'drafts' : p.state]++
|
|
196
|
+
}
|
|
197
|
+
return { groups, posts }
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** every projection written again from the events, in one transaction */
|
|
201
|
+
export function rebuildProjections(db: Database): { groups: number; posts: number } {
|
|
202
|
+
return db
|
|
203
|
+
.transaction(() => {
|
|
204
|
+
const { groups, posts } = foldProjections(db)
|
|
205
|
+
// the first import's drafts projection: no reader is left
|
|
206
|
+
db.exec('drop table if exists thread_drafts; delete from thread_post_groups; delete from thread_posts')
|
|
207
|
+
for (const r of groups.values()) put(db, 'thread_post_groups', GROUP_COLS, r)
|
|
208
|
+
for (const r of posts.values()) put(db, 'thread_posts', POST_COLS, r)
|
|
209
|
+
return { groups: groups.size, posts: posts.size }
|
|
210
|
+
})
|
|
211
|
+
.immediate()
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** the rows where a projection differs from its events: empty is no drift */
|
|
215
|
+
export function projectionDrift(db: Database): string[] {
|
|
216
|
+
const bad: string[] = []
|
|
217
|
+
const want = foldProjections(db, bad)
|
|
218
|
+
const diff = <R extends object>(table: string, cols: readonly string[], keyOf: (r: R) => string, name: (r: R) => string, w: Map<string, R>): void => {
|
|
219
|
+
const seen = new Set<string>()
|
|
220
|
+
for (const r of db.query(`select * from ${table}`).all() as R[]) {
|
|
221
|
+
const k = keyOf(r)
|
|
222
|
+
seen.add(k)
|
|
223
|
+
const x = w.get(k)
|
|
224
|
+
if (x == null) bad.push(`${table} ${name(r)}: no event makes it`)
|
|
225
|
+
else {
|
|
226
|
+
const d = cols.filter((c) => (x as Record<string, unknown>)[c] !== (r as Record<string, unknown>)[c])
|
|
227
|
+
if (d.length > 0) bad.push(`${table} ${name(r)}: ${d.join(', ')} differ from its events`)
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
for (const [k, x] of w) if (!seen.has(k)) bad.push(`${table} ${name(x)}: missing, its events make it`)
|
|
231
|
+
}
|
|
232
|
+
diff<GroupRow>('thread_post_groups', GROUP_COLS, (r) => `${r.repo}\0${r.slug}`, (r) => `${r.repo} ${r.slug}`, want.groups)
|
|
233
|
+
diff<PostRow>('thread_posts', POST_COLS, (r) => `${r.repo}\0${r.slug}\0${r.key}`, (r) => `${r.repo} ${r.slug}/${r.key}`, want.posts)
|
|
234
|
+
return bad
|
|
235
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// which threads refer to an object (wiki tools/shipkit/threads-how-it-fits.md, An object stands on its own): the threads
|
|
2
|
+
// opened on its address or naming it in a store item, and each a link event puts it in. An object has no home thread
|
|
3
|
+
import type { Database } from 'bun:sqlite'
|
|
4
|
+
import { cardsDb } from './card-db.ts'
|
|
5
|
+
import { eventsRepo } from './events.ts'
|
|
6
|
+
import { readAllCached, specOf, storeDir } from './store.ts'
|
|
7
|
+
import { holderOf, membersOf, ownAddressesOf, threadsNaming, threadsOf, type Thread } from './threads.ts'
|
|
8
|
+
|
|
9
|
+
/** the keys of the threads that refer to `<kind>:<key>` or a part of it (`<kind>:<key>/…`), each once: a thread's own
|
|
10
|
+
* address, else its head item's id, the way `sk thread show` and a link's `thread` name it */
|
|
11
|
+
export function threadsReferring(root: string, kind: string, key: string, db: Database = cardsDb()): string[] {
|
|
12
|
+
const address = `${kind}:${key}`
|
|
13
|
+
const dir = storeDir(root)
|
|
14
|
+
const spec = specOf(dir)
|
|
15
|
+
const items = readAllCached(dir).items
|
|
16
|
+
const threads = threadsOf(items, spec)
|
|
17
|
+
const keyOf = (t: Thread): string => ownAddressesOf(t, spec)[0] ?? t.head.item.id
|
|
18
|
+
// a link names its thread by any key of it: one thread, one key
|
|
19
|
+
const resolve = (k: string): string => {
|
|
20
|
+
const t = threads.find((x) => ownAddressesOf(x, spec).includes(k) || x.head.item.id === k || membersOf(x).some((m) => m.item.id === k))
|
|
21
|
+
return t == null ? k : keyOf(t)
|
|
22
|
+
}
|
|
23
|
+
const named = threadsNaming(address, items, spec).map(keyOf)
|
|
24
|
+
const linked = db
|
|
25
|
+
.query("select thread from thread_events where repo = ? and type = 'link' and (json_extract(content, '$.link.address') = ? or json_extract(content, '$.link.address') like ?) group by thread order by min(seq)")
|
|
26
|
+
.all(eventsRepo(dir), address, `${address}/%`) as { thread: string }[]
|
|
27
|
+
return [...new Set([...named, ...linked.map((r) => resolve(r.thread))])]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** the keys of the objects of one type that link events put into a thread, oldest first: the thread named by any key
|
|
31
|
+
* of it (its own address, its head's id, any item of it), since a link names its thread by whichever key its writer had */
|
|
32
|
+
export function objectsLinkedInto(root: string, thread: string, type: string, db: Database = cardsDb()): string[] {
|
|
33
|
+
const dir = storeDir(root)
|
|
34
|
+
const spec = specOf(dir)
|
|
35
|
+
const t = threadsOf(readAllCached(dir).items, spec).find((x) => ownAddressesOf(x, spec).includes(thread) || x.head.item.id === thread || membersOf(x).some((m) => m.item.id === thread))
|
|
36
|
+
const keys = t == null ? [thread] : [...new Set([...ownAddressesOf(t, spec), t.head.item.id, ...membersOf(t).map((m) => m.item.id)])]
|
|
37
|
+
const rows = db
|
|
38
|
+
.query(`select json_extract(content, '$.link.key') as key from thread_events where repo = ? and type = 'link' and json_extract(content, '$.link.type') = ? and thread in (${keys.map(() => '?').join(', ')}) group by key order by min(seq)`)
|
|
39
|
+
.all(eventsRepo(dir), type, ...keys) as { key: string | null }[]
|
|
40
|
+
return rows.flatMap((r) => (r.key ? [r.key] : []))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** the thread an agent holds that it acted in last (rule 5: its new object is attached there), null when it holds none
|
|
44
|
+
* in this repo: a lane by its name, the session itself (no lane) by its id */
|
|
45
|
+
export function heldThreadOf(root: string, me: { lane: string } | { session: string }): Thread | null {
|
|
46
|
+
const dir = storeDir(root)
|
|
47
|
+
let best: { t: Thread; at: string } | null = null
|
|
48
|
+
for (const t of threadsOf(readAllCached(dir).items, specOf(dir))) {
|
|
49
|
+
const h = holderOf(t)
|
|
50
|
+
if (h === null || ('lane' in me ? h.lane !== me.lane : h.lane !== undefined || h.session !== me.session)) continue
|
|
51
|
+
if (best == null || h.at > best.at) best = { t, at: h.at }
|
|
52
|
+
}
|
|
53
|
+
return best?.t ?? null
|
|
54
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// a reflection is an object, never a thread of its own (wiki tools/shipkit/threads-how-it-fits.md, The model): its file in
|
|
2
|
+
// `.shipkit/reflections/` is its truth, the repo's reflections page its index, its box in the thread where it was written
|
|
3
|
+
// its place in a conversation. A thread opens on one only when someone discusses it.
|
|
4
|
+
//
|
|
5
|
+
// the one constraint a reader breaks first: a reflection's own thread opens by the owner's act alone (actOnReflection), never by
|
|
6
|
+
// the machine, or every file becomes a thread again
|
|
7
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'
|
|
8
|
+
import { join } from 'path'
|
|
9
|
+
import { firstHeading, REFLECTIONS_DIR } from '../reflections/reflections-queue.ts'
|
|
10
|
+
import { HOUSE_KINDS } from './kinds.ts'
|
|
11
|
+
import { canonicalAddress, partyOf, updatesOf, type Message } from './model.ts'
|
|
12
|
+
import { heldThreadOf } from './referring.ts'
|
|
13
|
+
import { agentName, attachTo, openThread, postAction, postUpdate, readAll, readAllCached, sessionId, specOf, storeDir } from './store.ts'
|
|
14
|
+
import { membersOf, orderedThreads, ownAddressesOf, threadsOf, turnOf, type Thread } from './threads.ts'
|
|
15
|
+
|
|
16
|
+
export const REFLECTION = 'reflection'
|
|
17
|
+
|
|
18
|
+
/** `reflection:<repo>/<file>`, the one address of a reflection */
|
|
19
|
+
export const reflectionAddress = (repo: string, file: string): string => canonicalAddress(`${REFLECTION}:${repo}/${file}`) ?? `${REFLECTION}:${repo}/${file}`
|
|
20
|
+
|
|
21
|
+
/** the repo and the file an address names; null for another kind */
|
|
22
|
+
export function reflectionOfAddress(address: string): { repo: string; file: string } | null {
|
|
23
|
+
const m = /^reflection:([^/]+)\/([^/]+\.md)$/i.exec(address.trim())
|
|
24
|
+
return m === null ? null : { repo: m[1]!, file: m[2]! }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** a reflection as its file says now; `standing` false once the file is gone (folded, discarded) */
|
|
28
|
+
export interface ReflectionObject {
|
|
29
|
+
address: string
|
|
30
|
+
file: string
|
|
31
|
+
title: string
|
|
32
|
+
md: string
|
|
33
|
+
standing: boolean
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function readReflection(root: string, repo: string, file: string): ReflectionObject {
|
|
37
|
+
const address = reflectionAddress(repo, file)
|
|
38
|
+
let md: string | null = null
|
|
39
|
+
try {
|
|
40
|
+
md = readFileSync(join(root, REFLECTIONS_DIR, file), 'utf8')
|
|
41
|
+
} catch {
|
|
42
|
+
// gone: folded into its owner or discarded, the triage moved it out
|
|
43
|
+
}
|
|
44
|
+
return { address, file, title: (md === null ? null : firstHeading(md)) ?? file, md: md ?? '', standing: md !== null }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** an agent's message that links `address` into its thread */
|
|
48
|
+
const linksIt = (m: Message, address: string): boolean => partyOf(m.who) === 'agent' && (m.about ?? []).some((a) => (canonicalAddress(a) ?? a) === address)
|
|
49
|
+
|
|
50
|
+
/** a thread that refers to a reflection, as its index shows it */
|
|
51
|
+
export interface ReflectionThread {
|
|
52
|
+
/** the item the hub opens */
|
|
53
|
+
id: string
|
|
54
|
+
title: string
|
|
55
|
+
/** `own`: the thread opened on the reflection; `link`: a thread an agent linked it into */
|
|
56
|
+
how: 'own' | 'link'
|
|
57
|
+
done: boolean
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const ownThreadOf = (threads: readonly Thread[], address: string, dir: string): Thread | null => threads.find((t) => ownAddressesOf(t, specOf(dir)).includes(address)) ?? null
|
|
61
|
+
|
|
62
|
+
/** the threads that refer to each reflection of the store, one pass: `of(file)` lists one's, the open ones first, the
|
|
63
|
+
* newest first in each */
|
|
64
|
+
export function reflectionThreads(root: string, repo: string): (file: string) => ReflectionThread[] {
|
|
65
|
+
const dir = storeDir(root)
|
|
66
|
+
const spec = specOf(dir)
|
|
67
|
+
const by = new Map<string, (ReflectionThread & { at: string })[]>()
|
|
68
|
+
const add = (address: string, r: ReflectionThread & { at: string }): void => {
|
|
69
|
+
const l = by.get(address) ?? []
|
|
70
|
+
const same = l.find((x) => x.id === r.id)
|
|
71
|
+
if (same === undefined) l.push(r)
|
|
72
|
+
else if (r.how === 'own' || r.at > same.at) Object.assign(same, r.how === 'own' ? { how: 'own' } : { at: r.at })
|
|
73
|
+
by.set(address, l)
|
|
74
|
+
}
|
|
75
|
+
for (const t of threadsOf(readAllCached(dir).items, spec)) {
|
|
76
|
+
const base = { id: t.head.item.id, title: t.head.item.title, done: turnOf(t) === 'done' }
|
|
77
|
+
for (const a of ownAddressesOf(t, spec)) if (a.startsWith(`${REFLECTION}:`)) add(a, { ...base, how: 'own', at: t.head.item.created })
|
|
78
|
+
for (const x of membersOf(t))
|
|
79
|
+
for (const m of x.thread)
|
|
80
|
+
if (partyOf(m.who) === 'agent') for (const a of m.about ?? []) if (a.startsWith(`${REFLECTION}:`)) add(canonicalAddress(a) ?? a, { ...base, how: 'link', at: m.at })
|
|
81
|
+
}
|
|
82
|
+
return (file) => (by.get(reflectionAddress(repo, file)) ?? []).sort((a, b) => Number(a.done) - Number(b.done) || b.at.localeCompare(a.at)).map(({ at: _, ...r }) => r)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** what the owner's click on the reflection does: where it was written, the thread that hears it, and whether it opened it */
|
|
86
|
+
export interface ReflectionAct {
|
|
87
|
+
thread: string
|
|
88
|
+
opened: boolean
|
|
89
|
+
message: Message
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** the owner's action on a reflection from its index (accept, rework, discard): in the newest thread that links it, on its
|
|
93
|
+
* link, so its holder hears it; else in the reflection's own thread, opened by this act when none stands */
|
|
94
|
+
export async function actOnReflection(root: string, repo: string, file: string, a: { name: string; text?: string; now?: Date }): Promise<ReflectionAct> {
|
|
95
|
+
const actions = HOUSE_KINDS[REFLECTION]?.actions ?? {}
|
|
96
|
+
if (actions[a.name] === undefined) throw new Error(`action: ${a.name} is none of ${Object.keys(actions).join(', ')}`)
|
|
97
|
+
const o = readReflection(root, repo, file)
|
|
98
|
+
if (!o.standing) throw new Error(`${o.address}: its file is gone from ${REFLECTIONS_DIR}/, nothing to act on`)
|
|
99
|
+
const dir = storeDir(root)
|
|
100
|
+
const threads = orderedThreads(readAll(dir).items)
|
|
101
|
+
const words = [o.address, a.text?.trim() ?? ''].filter((w) => w !== '').join(': ')
|
|
102
|
+
const now = a.now ?? new Date()
|
|
103
|
+
let link: { item: string; m: Message } | null = null
|
|
104
|
+
// the thread where it was written hears the owner's word whatever its turn: its holder's inbox reads any unseen word of the owner's
|
|
105
|
+
for (const t of threads) {
|
|
106
|
+
for (const x of membersOf(t)) for (const m of x.thread) if (linksIt(m, o.address) && (link === null || m.at > link.m.at)) link = { item: x.item.id, m }
|
|
107
|
+
}
|
|
108
|
+
if (link !== null) return { thread: link.item, opened: false, message: postAction(dir, link.item, { name: a.name, text: words, re: link.m.id, now }) }
|
|
109
|
+
const own = ownThreadOf(threadsOf(readAll(dir).items, specOf(dir)), o.address, dir)
|
|
110
|
+
if (own !== null) return { thread: own.head.item.id, opened: false, message: postAction(dir, own.head.item.id, { name: a.name, text: words, now }) }
|
|
111
|
+
const item = await openThread(dir, o.address, { title: o.title, what: o.md, machine: true, now })
|
|
112
|
+
return { thread: item.id, opened: true, message: postAction(dir, item.id, { name: a.name, text: words, now }) }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** `YYYYMMDD-<slug>.md` of a title: the queue's file name */
|
|
116
|
+
export function reflectionFile(title: string, now: Date): string {
|
|
117
|
+
const slug = title
|
|
118
|
+
.toLowerCase()
|
|
119
|
+
.normalize('NFD')
|
|
120
|
+
.replace(/[̀-ͯ]/g, '')
|
|
121
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
122
|
+
.replace(/^-+|-+$/g, '')
|
|
123
|
+
.slice(0, 60)
|
|
124
|
+
.replace(/-+$/, '')
|
|
125
|
+
if (slug === '') throw new Error(`the title « ${title} » makes no file name: give it words`)
|
|
126
|
+
return `${now.toISOString().slice(0, 10).replace(/-/g, '')}-${slug}.md`
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** what `sk thread reflect` wrote: the file, and the thread it is linked into (null: the agent holds none here) */
|
|
130
|
+
export interface Written {
|
|
131
|
+
file: string
|
|
132
|
+
address: string
|
|
133
|
+
linked: string | null
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** an agent's reflection: its file written, and linked in the same call into the thread the agent holds (rule 5 of the
|
|
137
|
+
* hub map), or the one `into` names. Never over an existing file */
|
|
138
|
+
export function writeReflection(root: string, repo: string, r: { title: string; body: string; into?: string; now?: Date }): Written {
|
|
139
|
+
const now = r.now ?? new Date()
|
|
140
|
+
const title = r.title.trim().split('\n')[0] ?? ''
|
|
141
|
+
const file = reflectionFile(title, now)
|
|
142
|
+
const path = join(root, REFLECTIONS_DIR, file)
|
|
143
|
+
if (existsSync(path)) throw new Error(`${REFLECTIONS_DIR}/${file} exists: give another title, or edit that file`)
|
|
144
|
+
const body = r.body.trim()
|
|
145
|
+
const md = body.startsWith('#') ? `${body}\n` : `# ${title}\n\n${body}\n`
|
|
146
|
+
const dir = storeDir(root)
|
|
147
|
+
const lane = process.env.SK_AGENT?.trim()
|
|
148
|
+
const session = sessionId()
|
|
149
|
+
const held = r.into !== undefined ? null : lane ? heldThreadOf(root, { lane }) : session ? heldThreadOf(root, { session }) : null
|
|
150
|
+
const into = r.into ?? held?.head.item.id ?? null
|
|
151
|
+
if (r.into !== undefined && !readAll(dir).items.some((x) => x.item.id === r.into)) throw new Error(`no thread item ${r.into}`)
|
|
152
|
+
mkdirSync(join(root, REFLECTIONS_DIR), { recursive: true })
|
|
153
|
+
writeFileSync(path, md)
|
|
154
|
+
const address = reflectionAddress(repo, file)
|
|
155
|
+
if (into !== null) attachTo(dir, into, agentName(), address, now)
|
|
156
|
+
return { file, address, linked: into }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** what the fold did, per store */
|
|
160
|
+
export interface Fold {
|
|
161
|
+
threads: number
|
|
162
|
+
folded: number
|
|
163
|
+
/** a thread where the owner spoke or acted: it stays, referring to the object */
|
|
164
|
+
kept: number
|
|
165
|
+
/** folded by an earlier run, or closed already */
|
|
166
|
+
already: number
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** the owner's words or acts in a thread: any message of the owner's but a read mark */
|
|
170
|
+
const hisActs = (t: Thread): Message[] => membersOf(t).flatMap((x) => x.thread).filter((m) => partyOf(m.who) === 'owner' && m.op !== 'seen')
|
|
171
|
+
|
|
172
|
+
export const FOLDED = 'folded into its object: the reflection reads from its file and its index; a thread opens on it again when someone discusses it'
|
|
173
|
+
|
|
174
|
+
/** every `reflection:` thread the machine opened in this store, with none of the owner's words or acts, closed into its object
|
|
175
|
+
* (a machine `fixed`: done, kept, never deleted). Re-runnable: one closed already is counted, never written again */
|
|
176
|
+
export async function foldReflectionThreads(root: string, o: { go: boolean; now?: Date }): Promise<Fold> {
|
|
177
|
+
const dir = storeDir(root)
|
|
178
|
+
const out: Fold = { threads: 0, folded: 0, kept: 0, already: 0 }
|
|
179
|
+
for (const t of orderedThreads(readAll(dir).items)) {
|
|
180
|
+
const on = t.head.item.on
|
|
181
|
+
if (on === undefined || !on.startsWith(`${REFLECTION}:`) || t.head.item.origin.by !== 'agent') continue
|
|
182
|
+
out.threads++
|
|
183
|
+
if (hisActs(t).length > 0) {
|
|
184
|
+
out.kept++
|
|
185
|
+
continue
|
|
186
|
+
}
|
|
187
|
+
if (turnOf(t) === 'done' || updatesOf(t.head).at(-1)?.update?.state === 'fixed') {
|
|
188
|
+
out.already++
|
|
189
|
+
continue
|
|
190
|
+
}
|
|
191
|
+
out.folded++
|
|
192
|
+
if (o.go) await postUpdate(dir, t.head.item.id, { who: 'agent', state: 'fixed', text: FOLDED, machine: true, ...(o.now ? { now: o.now } : {}) })
|
|
193
|
+
}
|
|
194
|
+
return out
|
|
195
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// the bytes the review store writes for a head or a message, and their sha: what two machines and two backends compare
|
|
2
|
+
|
|
3
|
+
/** the bytes the store writes for a head or a message */
|
|
4
|
+
export const jsonText = (v: unknown): string => `${JSON.stringify(v, null, 4)}\n`
|
|
5
|
+
|
|
6
|
+
/** the rev of a head or a message: the sha256 of the bytes the store writes for it, so one card has one rev on every
|
|
7
|
+
* machine and in both backends, whatever spacing an older writer gave its file */
|
|
8
|
+
export const revOf = (v: unknown): string => new Bun.CryptoHasher('sha256').update(jsonText(v)).digest('hex')
|
package/src/review/role.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// the dispatcher role (wiki tools/shipkit/
|
|
1
|
+
// the dispatcher role (wiki tools/shipkit/threads.md, Raised items): one session routes what the owner, the players and
|
|
2
2
|
// the rules raise. Its file sits beside the store, out of the store's watch
|
|
3
3
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
|
|
4
4
|
import { join } from 'node:path'
|