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,285 @@
|
|
|
1
|
+
// the messages store's one writer (wiki tools/shipkit/messages.md): the owner's suggestions from the page (a message in the
|
|
2
|
+
// owner's words, one more phrasing), refused when messages.md changed since the page read it; and an object he approved in a
|
|
3
|
+
// thread (`applyObject`, a kind's apply), refused only when that object's own section moved since it was proposed.
|
|
4
|
+
// The one constraint a reader breaks first: every line outside what changes stays byte for byte, comments included
|
|
5
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
6
|
+
import { join } from 'node:path'
|
|
7
|
+
import { hashOf, MESSAGES_DIR, parseMessages } from './model.ts'
|
|
8
|
+
import { sameJson } from '../review/unit.ts'
|
|
9
|
+
import { FILE_OF, keyParts, mainRoot, objectJson, type MessageJson, type ObjectJson, type ObjectKind, type OneJson, type OneOptionJson, type OptionJson, type PersonaJson, type PhrasingJson, type SurfaceJson } from './objects.ts'
|
|
10
|
+
|
|
11
|
+
/** the source of a phrasing the owner wrote, as the store marks its sources */
|
|
12
|
+
export const OWNER = 'owner'
|
|
13
|
+
/** the fields a suggested message carries, each written empty when none was given: the lint and the page say « to fill » */
|
|
14
|
+
const FIELDS = ['meaning', 'value', 'truth', 'never'] as const
|
|
15
|
+
|
|
16
|
+
export type MessageSuggestion = { title: string; family?: string; meaning?: string; value?: string; phrasing?: string }
|
|
17
|
+
export type Suggestion = ({ kind: 'message' } & MessageSuggestion) | { kind: 'phrasing'; message: string; text: string }
|
|
18
|
+
|
|
19
|
+
/** one line: the store reads a field, a title or a phrasing up to its line's end */
|
|
20
|
+
export const oneLine = (s: string | undefined): string => (s ?? '').replace(/\s+/g, ' ').trim()
|
|
21
|
+
/** a phrasing sits between straight quotes, so its own quotes turn typographic */
|
|
22
|
+
export const quoted = (s: string): string => oneLine(s).replace(/"([^"]*)"/g, '“$1”').replace(/"/g, '”')
|
|
23
|
+
|
|
24
|
+
const STOP = new Set(['a', 'an', 'the', 'to', 'of', 'in', 'on', 'for', 'and', 'or', 'with', 'your', 'you', 'any', 'it', 'is', 'as', 'by', 'from', 'can', 'that', 'this', 'all', 'one'])
|
|
25
|
+
|
|
26
|
+
/** a message id from its title: two telling words, unique in the store */
|
|
27
|
+
function messageId(title: string, taken: Set<string>): string {
|
|
28
|
+
const words = title.toLowerCase().normalize('NFKD').replace(/[^a-z0-9\s]/g, ' ').split(/\s+/).filter((w) => w && !STOP.has(w))
|
|
29
|
+
const base = words.slice(0, 2).join('-') || 'message'
|
|
30
|
+
let id = base
|
|
31
|
+
for (let n = 2; taken.has(id); n++) id = `${base}-${n}`
|
|
32
|
+
return id
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** the next phrasing id under a prefix, past every id of the store that already uses it */
|
|
36
|
+
export function nextUnder(prefix: string, ids: string[]): string {
|
|
37
|
+
const re = new RegExp(`^${prefix.replace(/[^\w]/g, '\\$&')}(\\d+)$`)
|
|
38
|
+
const top = Math.max(0, ...ids.map((i) => Number(re.exec(i)?.[1] ?? 0)))
|
|
39
|
+
return `${prefix}${top + 1}`
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** the comments blanked line for line, so a line index of the parse is a line index of the file */
|
|
43
|
+
const lines = (md: string): string[] => md.replace(/<!--[\s\S]*?-->/g, (c) => c.replace(/[^\n]/g, ' ')).split('\n')
|
|
44
|
+
|
|
45
|
+
export function withMessage(md: string, s: MessageSuggestion): { md: string; id: string; phrasing?: string } {
|
|
46
|
+
const title = oneLine(s.title)
|
|
47
|
+
if (!title) throw new Error('a message needs its title')
|
|
48
|
+
const messages = parseMessages(md)
|
|
49
|
+
const ids = messages.flatMap((m) => m.candidates.map((c) => c.id))
|
|
50
|
+
const id = messageId(title, new Set(messages.map((m) => m.id)))
|
|
51
|
+
const text = quoted(s.phrasing ?? '')
|
|
52
|
+
const given: Record<string, string> = { meaning: oneLine(s.meaning), value: oneLine(s.value) }
|
|
53
|
+
const prefix = [...Array(id.length).keys()].map((n) => id.replace(/-/g, '').slice(0, n + 1)).find((p) => !ids.some((i) => new RegExp(`^${p}\\d+$`).test(i))) ?? id
|
|
54
|
+
const phrasing = text ? nextUnder(prefix, ids) : undefined
|
|
55
|
+
const family = oneLine(s.family)
|
|
56
|
+
const block = [
|
|
57
|
+
`## ${id}: ${title}`,
|
|
58
|
+
...(family ? [`- family: ${family}`] : []),
|
|
59
|
+
...FIELDS.map((k) => (given[k] ? `- ${k}: ${given[k]}` : `- ${k}:`)),
|
|
60
|
+
...(phrasing ? [`- \`${phrasing}\` "${text}" ${OWNER}`] : []),
|
|
61
|
+
]
|
|
62
|
+
const body = md.endsWith('\n') ? md : `${md}\n`
|
|
63
|
+
const gap = body.trim() === '' || body.endsWith('\n\n') ? '' : '\n'
|
|
64
|
+
return { md: `${body}${gap}${block.join('\n')}\n`, id, ...(phrasing ? { phrasing } : {}) }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function withPhrasing(md: string, message: string, raw: string): { md: string; id: string } {
|
|
68
|
+
const text = quoted(raw)
|
|
69
|
+
if (!text) throw new Error('a phrasing needs its words')
|
|
70
|
+
const m = parseMessages(md).find((x) => x.id === message)
|
|
71
|
+
if (!m) throw new Error(`messages.md has no message ${message}`)
|
|
72
|
+
const ids = parseMessages(md).flatMap((x) => x.candidates.map((c) => c.id))
|
|
73
|
+
const prefix = m.candidates[0]?.id.replace(/\d+$/, '') || m.id
|
|
74
|
+
const id = nextUnder(prefix, ids)
|
|
75
|
+
const ls = lines(md)
|
|
76
|
+
const head = ls.findIndex((l) => l.startsWith(`## ${message}: `))
|
|
77
|
+
const next = ls.findIndex((l, i) => i > head && l.startsWith('## '))
|
|
78
|
+
let at = (next === -1 ? ls.length : next) - 1
|
|
79
|
+
while (at > head && ls[at]!.trim() === '') at--
|
|
80
|
+
const raws = md.split('\n')
|
|
81
|
+
raws.splice(at + 1, 0, `- \`${id}\` "${text}" ${OWNER}`)
|
|
82
|
+
return { md: raws.join('\n'), id }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** the suggestion written into the store at `root`, refused when messages.md is no longer the text hashed `expect` */
|
|
86
|
+
export function suggest(root: string, expect: string | undefined, s: Suggestion): { id: string; phrasing?: string } {
|
|
87
|
+
const file = join(root, MESSAGES_DIR, 'messages.md')
|
|
88
|
+
const md = readFileSync(file, 'utf8')
|
|
89
|
+
if (expect !== hashOf(md)) throw new Changed()
|
|
90
|
+
const { md: next, ...made } = s.kind === 'message' ? withMessage(md, s) : withPhrasing(md, s.message, s.text)
|
|
91
|
+
writeFileSync(file, next)
|
|
92
|
+
return made
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export class Changed extends Error {
|
|
96
|
+
constructor() {
|
|
97
|
+
super('messages.md changed since this page read it (another session edited it). The page shows it again now: check your words are still wanted, then send again')
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ---- an object he approved in a thread
|
|
102
|
+
|
|
103
|
+
const ID = /^[\w-]+$/
|
|
104
|
+
/** a section's id from its head line: `## <id> (<role>)` for a persona, `## <id>: <title>` for the rest */
|
|
105
|
+
const headId = (kind: ObjectKind, l: string): string | null => (kind === 'persona' ? /^## ([\w-]+) \(/.exec(l) : /^## ([\w-]+): /.exec(l))?.[1] ?? null
|
|
106
|
+
|
|
107
|
+
/** the lines of one section: its head and its last line that is not blank, in the comments blanked lines */
|
|
108
|
+
function sectionOf(kind: ObjectKind, ls: readonly string[], id: string): { head: number; last: number } | null {
|
|
109
|
+
const head = ls.findIndex((l) => headId(kind, l)?.toLowerCase() === id.toLowerCase())
|
|
110
|
+
if (head === -1) return null
|
|
111
|
+
const next = ls.findIndex((l, i) => i > head && l.startsWith('## '))
|
|
112
|
+
let last = (next === -1 ? ls.length : next) - 1
|
|
113
|
+
while (last > head && ls[last]!.trim() === '') last--
|
|
114
|
+
return { head, last }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const phrasingLine = (p: PhrasingJson): string => `- \`${p.id}\` "${quoted(p.text)}"${oneLine(p.source) ? ` ${oneLine(p.source)}` : ''}`
|
|
118
|
+
const optionLine = (o: OptionJson): string => `- \`${o.id}\` "${quoted(o.headline)}"${oneLine(o.second) ? ` / "${quoted(o.second)}"` : ''}`
|
|
119
|
+
const fieldLine = (k: string, v: string | undefined): string => (oneLine(v) ? `- ${k}: ${oneLine(v)}` : `- ${k}:`)
|
|
120
|
+
/** a field's order in a written message: family first, as the store writes it */
|
|
121
|
+
const fieldKeys = (m: MessageJson): string[] => {
|
|
122
|
+
const keys = [...new Set([...Object.keys(m.fields), ...m.toFill])]
|
|
123
|
+
return [...keys.filter((k) => k === 'family'), ...keys.filter((k) => k !== 'family')]
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function blockOf(kind: ObjectKind, json: ObjectJson): string[] {
|
|
127
|
+
if (kind === 'persona') {
|
|
128
|
+
const p = json as PersonaJson
|
|
129
|
+
return [`## ${p.id} (${p.role})`, p.who.trim()]
|
|
130
|
+
}
|
|
131
|
+
if (kind === 'messages') {
|
|
132
|
+
const m = json as MessageJson
|
|
133
|
+
return [`## ${m.id}: ${oneLine(m.title)}`, ...fieldKeys(m).map((k) => fieldLine(k, m.fields[k])), ...m.phrasings.map(phrasingLine)]
|
|
134
|
+
}
|
|
135
|
+
const s = json as SurfaceJson
|
|
136
|
+
return [`## ${s.id}: ${oneLine(s.title)}`, ...(s.budget !== undefined ? [`- budget: ${s.budget} characters`] : []), ...(s.shot ? [`- shot: ${oneLine(s.shot)}`] : []), ...s.options.map(optionLine)]
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** a value that would break the store once written, else null: a comment opened or closed, a line that reads as a section,
|
|
140
|
+
* an id or a field key the parse does not take */
|
|
141
|
+
function storeProblem(j: unknown): string | null {
|
|
142
|
+
const o = (j ?? {}) as Record<string, unknown>
|
|
143
|
+
const ids = [...(Array.isArray(o.phrasings) ? o.phrasings : []), ...(Array.isArray(o.options) ? o.options : [])].map((x) => (x as { id?: unknown }).id)
|
|
144
|
+
for (const i of ids) if (typeof i !== 'string' || !ID.test(i)) return `id ${JSON.stringify(i)}: letters, digits, - and _`
|
|
145
|
+
if (typeof o.fields === 'object' && o.fields !== null) for (const k of Object.keys(o.fields)) if (!/^\w+$/.test(k)) return `field ${JSON.stringify(k)}: one word`
|
|
146
|
+
const texts: string[] = []
|
|
147
|
+
const walk = (v: unknown): void => void (typeof v === 'string' ? texts.push(v) : v && typeof v === 'object' ? Object.values(v).forEach(walk) : undefined)
|
|
148
|
+
walk(j)
|
|
149
|
+
for (const t of texts) {
|
|
150
|
+
if (t.includes('<!--') || t.includes('-->')) return `« ${t.slice(0, 40)} »: <!-- or --> would hide the store's lines behind it`
|
|
151
|
+
if (/^\s*## /m.test(t)) return `« ${t.slice(0, 40)} »: a line that starts with ## reads as a new section`
|
|
152
|
+
}
|
|
153
|
+
return null
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** what a proposal holds is the shape its kind and key name, else the reason it is not */
|
|
157
|
+
function shapeProblem(kind: ObjectKind, key: string, j: unknown): string | null {
|
|
158
|
+
const stored = storeProblem(j)
|
|
159
|
+
if (stored !== null) return stored
|
|
160
|
+
const { id, part } = keyParts(key)
|
|
161
|
+
const o = (j ?? {}) as Record<string, unknown>
|
|
162
|
+
const str = (k: string): boolean => typeof o[k] === 'string'
|
|
163
|
+
const idOk = (k: string, want: string): string | null => (str(k) && ID.test(o[k] as string) && (o[k] as string).toLowerCase() === want.toLowerCase() ? null : `${k}: ${want}, the address's own id`)
|
|
164
|
+
if (kind === 'persona') return part !== undefined ? 'a persona has no part' : (idOk('id', id) ?? (o.role === 'reader' || o.role === 'gatekeeper' ? null : 'role: reader or gatekeeper') ?? (str('who') && (o.who as string).trim() ? null : 'who: who it is, in words'))
|
|
165
|
+
if (kind === 'messages') {
|
|
166
|
+
if (part !== undefined) return idOk('message', id) ?? idOk('id', part) ?? (str('text') && oneLine(o.text as string) ? null : 'text: the phrasing')
|
|
167
|
+
return idOk('id', id) ?? (str('title') && oneLine(o.title as string) ? null : 'title: what the message says, in a few words') ?? (typeof o.fields === 'object' && o.fields !== null && Array.isArray(o.toFill) && Array.isArray(o.phrasings) ? null : 'fields, toFill and phrasings')
|
|
168
|
+
}
|
|
169
|
+
if (part !== undefined) return idOk('surface', id) ?? idOk('id', part) ?? (str('headline') && oneLine(o.headline as string) ? null : 'headline: the option')
|
|
170
|
+
return idOk('id', id) ?? (str('title') ? null : 'title: the place') ?? (Array.isArray(o.options) ? null : 'options')
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** an existing message or page top patched line by line: its head, each field, each phrasing or option by its id; every
|
|
174
|
+
* other line stays, comments included. A field or a line it no longer names is refused: removing one is a hand edit */
|
|
175
|
+
function patchSection(kind: 'messages' | 'surface', raws: string[], at: { head: number; last: number }, now: MessageJson | SurfaceJson, after: MessageJson | SurfaceJson): void {
|
|
176
|
+
const blank = lines(raws.join('\n'))
|
|
177
|
+
let tail = at.last
|
|
178
|
+
const inSection = (re: RegExp): number => {
|
|
179
|
+
for (let i = at.head + 1; i <= tail; i++) if (re.test(blank[i]!)) return i
|
|
180
|
+
return -1
|
|
181
|
+
}
|
|
182
|
+
/** the line at `i`, else a new line after `after` (the section's end by default) */
|
|
183
|
+
const put = (i: number, line: string, after = tail): void => {
|
|
184
|
+
if (i !== -1) raws[i] = line
|
|
185
|
+
else {
|
|
186
|
+
raws.splice(after + 1, 0, line)
|
|
187
|
+
blank.splice(after + 1, 0, line)
|
|
188
|
+
tail++
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/** a new field goes under the fields, above the lines */
|
|
192
|
+
const lastField = (): number => {
|
|
193
|
+
let last = at.head
|
|
194
|
+
for (let i = at.head + 1; i <= tail; i++) if (/^- \w+:/.test(blank[i]!)) last = i
|
|
195
|
+
return last
|
|
196
|
+
}
|
|
197
|
+
raws[at.head] = `## ${now.id}: ${oneLine(after.title)}`
|
|
198
|
+
const esc = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
199
|
+
if (kind === 'messages') {
|
|
200
|
+
const a = after as MessageJson
|
|
201
|
+
const n = now as MessageJson
|
|
202
|
+
for (const k of fieldKeys(n)) if (a.fields[k] === undefined && !a.toFill.includes(k)) throw new Error(`${n.id}: its field ${k} leaves only by a hand edit`)
|
|
203
|
+
for (const p of n.phrasings) if (!a.phrasings.some((x) => x.id === p.id)) throw new Error(`${n.id}/${p.id}: a phrasing leaves only by a hand edit (or is held: its source « held: <why> »)`)
|
|
204
|
+
for (const k of fieldKeys(a)) if (a.fields[k] !== n.fields[k] || a.toFill.includes(k) !== n.toFill.includes(k)) put(inSection(new RegExp(`^- ${esc(k)}:`)), fieldLine(k, a.fields[k]), lastField())
|
|
205
|
+
for (const p of a.phrasings) {
|
|
206
|
+
const was = n.phrasings.find((x) => x.id === p.id)
|
|
207
|
+
if (was && was.text === p.text && was.source === p.source) continue
|
|
208
|
+
const i = inSection(new RegExp(`^- \`${esc(p.id)}\` `))
|
|
209
|
+
put(i, i === -1 ? phrasingLine(p) : keepTail('messages', raws[i]!, phrasingLine(p)))
|
|
210
|
+
}
|
|
211
|
+
return
|
|
212
|
+
}
|
|
213
|
+
const a = after as SurfaceJson
|
|
214
|
+
const n = now as SurfaceJson
|
|
215
|
+
for (const o of n.options) if (!a.options.some((x) => x.id === o.id)) throw new Error(`${n.id}/${o.id}: an option leaves only by a hand edit`)
|
|
216
|
+
if (a.budget !== n.budget) put(inSection(/^- budget: /), `- budget: ${a.budget} characters`, lastField())
|
|
217
|
+
if (a.shot !== n.shot) put(inSection(/^- shot: /), `- shot: ${oneLine(a.shot)}`, lastField())
|
|
218
|
+
for (const o of a.options) {
|
|
219
|
+
const was = n.options.find((x) => x.id === o.id)
|
|
220
|
+
if (was && was.headline === o.headline && was.second === o.second) continue
|
|
221
|
+
const i = inSection(new RegExp(`^- \`${esc(o.id)}\` `))
|
|
222
|
+
put(i, i === -1 ? optionLine(o) : keepTail('surface', raws[i]!, optionLine(o)))
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** a phrasing or an option line rewritten with what followed the old line's words kept: an option's note after its last
|
|
227
|
+
* quote, a phrasing's comment (its source is its json's) */
|
|
228
|
+
function keepTail(kind: ObjectKind, old: string, line: string): string {
|
|
229
|
+
if (kind === 'messages') return old.includes('<!--') ? `${line} ${old.slice(old.indexOf('<!--'))}` : line
|
|
230
|
+
const words = /^- `[^`]+` "[^"]*"(?: \/ "[^"]*")?/.exec(old)
|
|
231
|
+
return words == null ? line : `${line}${old.slice(words[0].length)}`
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** an object he approved, written into the md of the repo's main checkout: appended when new, its section patched when
|
|
235
|
+
* not. `before`: the object as the proposal read it, null or absent for a new one. Refused, nothing written: a new
|
|
236
|
+
* object whose id is taken, an object whose section moved since it was proposed, a shape its kind does not take */
|
|
237
|
+
export function applyObject(root: string, kind: ObjectKind, key: string, after: unknown, before?: unknown): { file: string; id: string; made: boolean } {
|
|
238
|
+
const address = `${kind}:${key}`
|
|
239
|
+
const bad = shapeProblem(kind, key, after)
|
|
240
|
+
if (bad !== null) throw new Error(`${address}: ${bad}`)
|
|
241
|
+
const main = mainRoot(root)
|
|
242
|
+
const file = join(main, MESSAGES_DIR, FILE_OF[kind])
|
|
243
|
+
if (!existsSync(join(main, MESSAGES_DIR, 'messages.md'))) throw new Error(`no messages store in ${main} (${MESSAGES_DIR}/messages.md)`)
|
|
244
|
+
const md = existsSync(file) ? readFileSync(file, 'utf8') : ''
|
|
245
|
+
if (md.includes('\r')) throw new Error(`${FILE_OF[kind]} has CRLF line ends, which the store does not read: save it with LF first`)
|
|
246
|
+
const now = objectJson(root, kind, key)
|
|
247
|
+
// approved again (a verdict taken back, then given): what it holds is in the store already
|
|
248
|
+
if (before == null && now != null && sameJson(now, after)) return { file, id: (now as { id: string }).id, made: false }
|
|
249
|
+
if (before == null && now != null) throw new Error(`${address} exists already: a change of it is proposed with its before`)
|
|
250
|
+
if (before != null && now == null) throw new Error(`${address} is no longer in ${FILE_OF[kind]}: it was removed or renamed since it was proposed`)
|
|
251
|
+
if (before != null && !sameJson(before, now)) throw new Error(`${address} moved in ${FILE_OF[kind]} since it was proposed: propose it again from what it says now`)
|
|
252
|
+
const j = after as ObjectJson
|
|
253
|
+
if (kind === 'messages') {
|
|
254
|
+
// a phrasing's scores and its line in a run are by its id alone, so an id is the store's once
|
|
255
|
+
const mine = new Set(now != null && 'phrasings' in now ? now.phrasings.map((p) => p.id) : now != null ? [(now as OneJson).id] : [])
|
|
256
|
+
const fresh = 'phrasings' in j ? j.phrasings.map((p) => p.id) : [(j as OneJson).id]
|
|
257
|
+
const taken = new Set(parseMessages(md).flatMap((m) => m.candidates.map((c) => c.id)))
|
|
258
|
+
for (const p of fresh) if (!mine.has(p) && taken.has(p)) throw new Error(`${address}: the phrasing id ${p} is taken in messages.md`)
|
|
259
|
+
}
|
|
260
|
+
const raws = md.split('\n')
|
|
261
|
+
const { id, part } = keyParts(key)
|
|
262
|
+
if (part === undefined && now == null) {
|
|
263
|
+
const body = md === '' || md.endsWith('\n') ? md : `${md}\n`
|
|
264
|
+
const gap = body.trim() === '' || body.endsWith('\n\n') ? '' : '\n'
|
|
265
|
+
writeFileSync(file, `${body}${gap}${blockOf(kind, j).join('\n')}\n`)
|
|
266
|
+
return { file, id: (j as { id: string }).id, made: true }
|
|
267
|
+
}
|
|
268
|
+
const sec = sectionOf(kind, lines(md), id)
|
|
269
|
+
if (sec === null) throw new Error(`${address}: ${FILE_OF[kind]} has no section ${id} to write it under`)
|
|
270
|
+
if (kind === 'persona') {
|
|
271
|
+
raws.splice(sec.head, sec.last - sec.head + 1, ...blockOf(kind, j))
|
|
272
|
+
} else if (part === undefined) {
|
|
273
|
+
patchSection(kind, raws, sec, now as MessageJson | SurfaceJson, j as MessageJson | SurfaceJson)
|
|
274
|
+
} else {
|
|
275
|
+
const line = kind === 'messages' ? phrasingLine(j as OneJson) : optionLine(j as OneOptionJson)
|
|
276
|
+
const blank = lines(md)
|
|
277
|
+
const re = new RegExp(`^- \`${part.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\` `, 'i')
|
|
278
|
+
let i = -1
|
|
279
|
+
for (let k = sec.head + 1; k <= sec.last; k++) if (re.test(blank[k]!)) i = k
|
|
280
|
+
if (i !== -1) raws[i] = keepTail(kind, raws[i]!, line)
|
|
281
|
+
else raws.splice(sec.last + 1, 0, line)
|
|
282
|
+
}
|
|
283
|
+
writeFileSync(file, raws.join('\n'))
|
|
284
|
+
return { file, id: (j as { id: string }).id, made: now == null }
|
|
285
|
+
}
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
// repo's page bundles to live in the hub. No framework, no hub code beyond the keys table. Framed, it speaks the
|
|
3
3
|
// `{ shipkit: <verb> }` messages on its origin; alone at its own url, it keeps the keys in its own address, so the
|
|
4
4
|
// page works the same either way
|
|
5
|
+
import type { ObjectThread } from '../review/cells.ts'
|
|
5
6
|
import { pageKey, pageLetterKey, sectionKey } from '../serve/hub-app/keys.ts'
|
|
6
7
|
|
|
7
8
|
export type FrameTheme = 'dark' | 'light'
|
|
8
9
|
export type FrameBadge = { count: number; tone?: 'red' | 'warn' | null; title?: string }
|
|
10
|
+
/** the threads that name one object of the page, as the hub's `GET /api/review/of` answers */
|
|
11
|
+
export type FrameObjectThreads = { address: string; threads: ObjectThread[]; noteGoesTo: string | null }
|
|
9
12
|
|
|
10
13
|
export interface FrameOpts {
|
|
11
14
|
/** the page's state as url keys: from the hub's address, or the page's own; the page applies them */
|
|
@@ -31,9 +34,32 @@ export interface PageFrame {
|
|
|
31
34
|
setTitle(title: string, badge?: FrameBadge | null): void
|
|
32
35
|
/** another hub page, by its address (`#page:review:<id>`) */
|
|
33
36
|
open(hash: string): void
|
|
37
|
+
/** the threads that name one of the page's objects (wiki tools/shipkit/threads-page.md, A thread on any object) */
|
|
38
|
+
threads(address: string): void
|
|
39
|
+
/** his note on one of the page's objects: it goes into the thread its address has, else starts one, then opens */
|
|
40
|
+
note(address: string, name: string, text: string): void
|
|
41
|
+
/** the threads of each address, in the order asked; alone, none */
|
|
42
|
+
threadsOf(addresses: readonly string[]): Promise<FrameObjectThreads[]>
|
|
43
|
+
/** the hub's 💬 control on one of the page's objects, a plain element: its count, its menu, the owner's words; hidden alone */
|
|
44
|
+
threadControl(address: string, name: string): HTMLElement
|
|
34
45
|
stop(): void
|
|
35
46
|
}
|
|
36
47
|
|
|
48
|
+
/** the wait after the last control is made before the one `threads-of` request: a page draws its rows in one moment */
|
|
49
|
+
const QUIET_MS = 60
|
|
50
|
+
|
|
51
|
+
const TURN_WORDS: Record<ObjectThread['turn'], string> = { yours: 'your turn', aside: 'set aside', agents: "an agent's move", done: 'done' }
|
|
52
|
+
|
|
53
|
+
/** the control's colours on the frame's theme; the accent is the hub's own for « your turn » */
|
|
54
|
+
const paint = (t: FrameTheme) => (t === 'dark' ? { bg: '#1d1f24', fg: '#e8e8ea', dim: '#9a9ca3', line: '#3a3d45', accent: '#ff5fa2' } : { bg: '#ffffff', fg: '#1d1f24', dim: '#6b6e76', line: '#d9dae0', accent: '#d6337f' })
|
|
55
|
+
|
|
56
|
+
interface ControlRec {
|
|
57
|
+
address: string
|
|
58
|
+
name: string
|
|
59
|
+
button: HTMLButtonElement
|
|
60
|
+
data: FrameObjectThreads | null
|
|
61
|
+
}
|
|
62
|
+
|
|
37
63
|
type KeyLike = Pick<KeyboardEvent, 'key' | 'code' | 'altKey' | 'shiftKey' | 'metaKey' | 'ctrlKey'>
|
|
38
64
|
|
|
39
65
|
/** a key the hub owns: its ⌥ sections, a page's ⌥⇧ letter, the home's ⌘ keys */
|
|
@@ -57,18 +83,170 @@ export function frameClient(o: FrameOpts): PageFrame {
|
|
|
57
83
|
live = null
|
|
58
84
|
}
|
|
59
85
|
|
|
86
|
+
let theme: FrameTheme = 'light'
|
|
87
|
+
let seq = 0
|
|
88
|
+
const asked = new Map<number, (objects: FrameObjectThreads[]) => void>()
|
|
89
|
+
const threadsOf = (addresses: readonly string[]): Promise<FrameObjectThreads[]> => {
|
|
90
|
+
if (!framed || addresses.length === 0) return Promise.resolve([])
|
|
91
|
+
const id = ++seq
|
|
92
|
+
return new Promise((res) => {
|
|
93
|
+
asked.set(id, res)
|
|
94
|
+
up({ shipkit: 'threads-of', id, addresses: [...addresses] })
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
const controls = new Set<ControlRec>()
|
|
98
|
+
let quiet: ReturnType<typeof setTimeout> | null = null
|
|
99
|
+
/** every control the page holds, asked in one request once the page holds still */
|
|
100
|
+
const refresh = (): void => {
|
|
101
|
+
if (quiet !== null) clearTimeout(quiet)
|
|
102
|
+
quiet = setTimeout(() => {
|
|
103
|
+
quiet = null
|
|
104
|
+
for (const c of controls) if (!c.button.isConnected && c.data !== null) controls.delete(c)
|
|
105
|
+
const all = [...controls]
|
|
106
|
+
void threadsOf(all.map((c) => c.address)).then((objects) => {
|
|
107
|
+
all.forEach((c, i) => {
|
|
108
|
+
c.data = objects[i] ?? null
|
|
109
|
+
drawButton(c)
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
}, QUIET_MS)
|
|
113
|
+
}
|
|
114
|
+
/** the page's own scheme, read from what it paints: a page may stay light under a dark hub */
|
|
115
|
+
const pageTheme = (): FrameTheme => {
|
|
116
|
+
for (const el of [document.body, document.documentElement]) {
|
|
117
|
+
const m = getComputedStyle(el).backgroundColor.match(/[\d.]+/g)?.map(Number)
|
|
118
|
+
if (m == null || m.length < 3 || m[3] === 0) continue
|
|
119
|
+
return 0.2126 * m[0]! + 0.7152 * m[1]! + 0.0722 * m[2]! < 128 ? 'dark' : 'light'
|
|
120
|
+
}
|
|
121
|
+
return theme
|
|
122
|
+
}
|
|
123
|
+
const drawButton = (c: ControlRec): void => {
|
|
124
|
+
const p = paint(pageTheme())
|
|
125
|
+
const n = c.data?.threads.length ?? 0
|
|
126
|
+
const yours = c.data?.threads.some((t) => t.turn === 'yours') ?? false
|
|
127
|
+
c.button.textContent = n > 0 ? `💬 ${n}` : '💬'
|
|
128
|
+
c.button.title = `threads on ${c.name} (${c.address})${yours ? ': one waits on you' : ''}`
|
|
129
|
+
Object.assign(c.button.style, { color: yours ? p.accent : p.fg, fontWeight: yours ? '600' : '400', opacity: n > 0 ? '1' : '0.55', borderColor: yours ? p.accent : 'transparent' })
|
|
130
|
+
}
|
|
131
|
+
let menu: { el: HTMLElement; off: () => void } | null = null
|
|
132
|
+
const closeMenu = (): void => {
|
|
133
|
+
menu?.off()
|
|
134
|
+
menu?.el.remove()
|
|
135
|
+
menu = null
|
|
136
|
+
}
|
|
137
|
+
const openMenu = (c: ControlRec): void => {
|
|
138
|
+
closeMenu()
|
|
139
|
+
const p = paint(pageTheme())
|
|
140
|
+
const el = document.createElement('div')
|
|
141
|
+
el.setAttribute('data-shipkit-threads', c.address)
|
|
142
|
+
const r = c.button.getBoundingClientRect()
|
|
143
|
+
const w = Math.min(340, innerWidth - 16)
|
|
144
|
+
Object.assign(el.style, { position: 'fixed', zIndex: '2147483647', top: `${Math.min(r.bottom + 4, innerHeight - 180)}px`, left: `${Math.max(8, Math.min(r.left, innerWidth - w - 8))}px`, width: `${w}px`, boxSizing: 'border-box', padding: '8px', display: 'flex', flexDirection: 'column', gap: '6px', background: p.bg, color: p.fg, border: `1px solid ${p.line}`, borderRadius: '8px', boxShadow: '0 6px 24px rgba(0,0,0,.25)', font: '13px system-ui, sans-serif' })
|
|
145
|
+
const head = document.createElement('div')
|
|
146
|
+
head.innerHTML = '<b></b> <span></span>'
|
|
147
|
+
head.children[0]!.textContent = c.name
|
|
148
|
+
head.children[1]!.textContent = c.address
|
|
149
|
+
Object.assign((head.children[1] as HTMLElement).style, { color: p.dim, overflowWrap: 'anywhere' })
|
|
150
|
+
el.append(head)
|
|
151
|
+
for (const t of c.data?.threads ?? []) {
|
|
152
|
+
const b = document.createElement('button')
|
|
153
|
+
b.type = 'button'
|
|
154
|
+
b.setAttribute('data-thread', t.head)
|
|
155
|
+
Object.assign(b.style, { display: 'block', width: '100%', textAlign: 'left', padding: '6px', borderRadius: '6px', border: `1px solid ${p.line}`, background: 'none', color: 'inherit', font: 'inherit', cursor: 'pointer' })
|
|
156
|
+
const turn = document.createElement('span')
|
|
157
|
+
turn.textContent = TURN_WORDS[t.turn]
|
|
158
|
+
Object.assign(turn.style, { fontSize: '11px', padding: '0 5px', borderRadius: '9px', marginRight: '6px', border: `1px solid ${t.turn === 'yours' ? p.accent : p.line}`, color: t.turn === 'yours' ? p.accent : p.dim })
|
|
159
|
+
b.append(turn, t.title)
|
|
160
|
+
b.onclick = () => {
|
|
161
|
+
closeMenu()
|
|
162
|
+
up({ shipkit: 'open', hash: `#page:review:${t.head}` })
|
|
163
|
+
}
|
|
164
|
+
el.append(b)
|
|
165
|
+
}
|
|
166
|
+
const box = document.createElement('textarea')
|
|
167
|
+
box.rows = 2
|
|
168
|
+
box.placeholder = c.data?.noteGoesTo ? 'a note: it goes into its thread (Enter sends)' : 'a note: it starts a thread on it (Enter sends)'
|
|
169
|
+
Object.assign(box.style, { width: '100%', boxSizing: 'border-box', resize: 'vertical', font: 'inherit', padding: '6px', borderRadius: '6px', border: `1px solid ${p.line}`, background: p.bg, color: p.fg })
|
|
170
|
+
const send = document.createElement('button')
|
|
171
|
+
send.type = 'button'
|
|
172
|
+
send.textContent = c.data?.noteGoesTo ? 'send to its thread' : 'start a thread'
|
|
173
|
+
Object.assign(send.style, { alignSelf: 'flex-start', padding: '4px 10px', borderRadius: '6px', border: `1px solid ${p.accent}`, background: p.accent, color: '#fff', font: 'inherit', cursor: 'pointer' })
|
|
174
|
+
const go = (): void => {
|
|
175
|
+
const text = box.value.trim()
|
|
176
|
+
if (text === '') return box.focus()
|
|
177
|
+
closeMenu()
|
|
178
|
+
up({ shipkit: 'note', address: c.address, name: c.name, text })
|
|
179
|
+
}
|
|
180
|
+
send.onclick = go
|
|
181
|
+
box.onkeydown = (e) => {
|
|
182
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
183
|
+
e.preventDefault()
|
|
184
|
+
go()
|
|
185
|
+
} else if (e.key === 'Escape') closeMenu()
|
|
186
|
+
}
|
|
187
|
+
el.append(box, send)
|
|
188
|
+
document.body.append(el)
|
|
189
|
+
box.focus()
|
|
190
|
+
const outside = (e: PointerEvent): void => {
|
|
191
|
+
if (!el.contains(e.target as Node) && e.target !== c.button) closeMenu()
|
|
192
|
+
}
|
|
193
|
+
const esc = (e: KeyboardEvent): void => {
|
|
194
|
+
if (e.key === 'Escape') closeMenu()
|
|
195
|
+
}
|
|
196
|
+
setTimeout(() => addEventListener('pointerdown', outside, true))
|
|
197
|
+
addEventListener('keydown', esc)
|
|
198
|
+
menu = { el, off: () => (removeEventListener('pointerdown', outside, true), removeEventListener('keydown', esc)) }
|
|
199
|
+
}
|
|
200
|
+
const threadControl = (address: string, name: string): HTMLElement => {
|
|
201
|
+
const button = document.createElement('button')
|
|
202
|
+
button.type = 'button'
|
|
203
|
+
button.className = 'shipkit-threads'
|
|
204
|
+
button.setAttribute('data-address', address)
|
|
205
|
+
Object.assign(button.style, { font: 'inherit', fontSize: '12px', lineHeight: '1.6', padding: '0 6px', border: '1px solid transparent', borderRadius: '6px', background: 'none', cursor: 'pointer', verticalAlign: 'middle', whiteSpace: 'nowrap' })
|
|
206
|
+
if (!framed) {
|
|
207
|
+
button.hidden = true
|
|
208
|
+
return button
|
|
209
|
+
}
|
|
210
|
+
const c: ControlRec = { address, name, button, data: null }
|
|
211
|
+
drawButton(c)
|
|
212
|
+
button.onclick = (e) => {
|
|
213
|
+
e.stopPropagation()
|
|
214
|
+
if (menu?.el.getAttribute('data-shipkit-threads') === address) closeMenu()
|
|
215
|
+
else openMenu(c)
|
|
216
|
+
}
|
|
217
|
+
controls.add(c)
|
|
218
|
+
refresh()
|
|
219
|
+
return button
|
|
220
|
+
}
|
|
221
|
+
|
|
60
222
|
const onMessage = (e: MessageEvent): void => {
|
|
61
223
|
if (e.source !== window.parent || e.origin !== origin) return
|
|
62
|
-
const m = (e.data ?? {}) as { shipkit?: unknown; keys?: unknown; theme?: unknown; identity?: unknown; on?: unknown }
|
|
224
|
+
const m = (e.data ?? {}) as { shipkit?: unknown; keys?: unknown; theme?: unknown; identity?: unknown; on?: unknown; id?: unknown; objects?: unknown }
|
|
225
|
+
if (m.shipkit === 'threads-of' && typeof m.id === 'number') {
|
|
226
|
+
asked.get(m.id)?.(Array.isArray(m.objects) ? (m.objects as FrameObjectThreads[]) : [])
|
|
227
|
+
asked.delete(m.id)
|
|
228
|
+
return
|
|
229
|
+
}
|
|
63
230
|
if ((m.shipkit === 'hello' || m.shipkit === 'keys') && typeof m.keys === 'string') {
|
|
64
231
|
last = m.keys
|
|
65
232
|
o.onKeys(m.keys)
|
|
66
233
|
}
|
|
67
|
-
if ((m.shipkit === 'hello' || m.shipkit === 'theme') && (m.theme === 'dark' || m.theme === 'light'))
|
|
234
|
+
if ((m.shipkit === 'hello' || m.shipkit === 'theme') && (m.theme === 'dark' || m.theme === 'light')) {
|
|
235
|
+
theme = m.theme
|
|
236
|
+
o.onTheme?.(m.theme)
|
|
237
|
+
// once the page painted its scheme
|
|
238
|
+
requestAnimationFrame(() => setTimeout(() => controls.forEach(drawButton), 50))
|
|
239
|
+
}
|
|
68
240
|
if ((m.shipkit === 'hello' || m.shipkit === 'identity') && (typeof m.identity === 'string' || m.identity === null)) o.onIdentity?.(m.identity)
|
|
69
241
|
if ((m.shipkit === 'hello' || m.shipkit === 'focus') && typeof m.on === 'boolean') {
|
|
70
|
-
if (m.on)
|
|
71
|
-
|
|
242
|
+
if (m.on) {
|
|
243
|
+
openLive()
|
|
244
|
+
// a note sent from here opened its thread: back on the page, the counts may have moved
|
|
245
|
+
if (controls.size > 0) refresh()
|
|
246
|
+
} else {
|
|
247
|
+
closeLive()
|
|
248
|
+
closeMenu()
|
|
249
|
+
}
|
|
72
250
|
o.onFocus?.(m.on)
|
|
73
251
|
}
|
|
74
252
|
}
|
|
@@ -108,7 +286,16 @@ export function frameClient(o: FrameOpts): PageFrame {
|
|
|
108
286
|
open(hash) {
|
|
109
287
|
up({ shipkit: 'open', hash })
|
|
110
288
|
},
|
|
289
|
+
threads(address) {
|
|
290
|
+
up({ shipkit: 'threads', address })
|
|
291
|
+
},
|
|
292
|
+
note(address, name, text) {
|
|
293
|
+
up({ shipkit: 'note', address, name, text })
|
|
294
|
+
},
|
|
295
|
+
threadsOf,
|
|
296
|
+
threadControl,
|
|
111
297
|
stop() {
|
|
298
|
+
closeMenu()
|
|
112
299
|
window.removeEventListener('message', onMessage)
|
|
113
300
|
window.removeEventListener('keydown', onKey)
|
|
114
301
|
mq?.removeEventListener('change', onScheme)
|
package/src/plan/planner.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// is due next and why. The only thing that starts a run nobody asked for. A
|
|
3
3
|
// save makes the checks whose answer it moved `changed`; a check's `every` or
|
|
4
4
|
// `cron` makes it `scheduled`; a `wait` check of an inactive repo turns `late`
|
|
5
|
-
// and runs once the repo is active again
|
|
5
|
+
// and runs once the repo is active again, except a failed one, asked again
|
|
6
|
+
// once a day; a click or a terminal is `asked`.
|
|
6
7
|
//
|
|
7
8
|
// the one constraint a reader breaks first: the planner owns no clock. The host
|
|
8
9
|
// calls tick() on its own beat (the daemon's tick, or one interval in a hub of
|
|
@@ -13,11 +14,12 @@
|
|
|
13
14
|
// quiet (QUIET_MS, or MAX_WAIT_MS into a burst that never stops), a check a
|
|
14
15
|
// save moved waits COST_FACTOR times its last measured run and GATED_HOLD_MS
|
|
15
16
|
// after the latest gate someone else started in its repo, and nothing it
|
|
16
|
-
// starts on its own starts while
|
|
17
|
-
import { availableParallelism, loadavg } from 'os'
|
|
17
|
+
// starts on its own starts while every core is taken and has a queue (LOAD_MAX).
|
|
18
18
|
import { CATCH_UP_BEAT_MS, resumeCatchUp, type CatchUpStore } from './catch-up.ts'
|
|
19
19
|
import { nextDue, resolveCadence, resolveWhenInactive, stablePoint, type EveryValue, type LastResult, type PlanDecl } from './cadence.ts'
|
|
20
20
|
import { yieldLoop } from '../core/loop-watch.ts'
|
|
21
|
+
import { effectiveLoad, machineWords, type MachineLoad } from '../core/machine-busy.ts'
|
|
22
|
+
import { machineLoad } from '../core/machine-read.ts'
|
|
21
23
|
|
|
22
24
|
export type PlanReason = 'changed' | 'scheduled' | 'late' | 'asked'
|
|
23
25
|
|
|
@@ -93,18 +95,23 @@ export const MAX_WAIT_MS = 10 * 60_000
|
|
|
93
95
|
* measured run: a 30s suite at most every 10 minutes, a 200ms lint at once */
|
|
94
96
|
export const COST_FACTOR = 20
|
|
95
97
|
|
|
98
|
+
/** a failure on record in an inactive repo is asked again this often, even by
|
|
99
|
+
* a check that waits for its repo: a red nobody can refresh would stay for good */
|
|
100
|
+
export const RED_REASK_MS = 24 * 3_600_000
|
|
101
|
+
export const RED_REASK_MAX_MS = 7 * 24 * 3_600_000
|
|
102
|
+
/** how long a red of an inactive repo waits before it is asked again: a day, doubled for each run in a row that failed,
|
|
103
|
+
* a week at most. A red that is true (a slow benchmark, a real finding) costs its run time each time it is asked */
|
|
104
|
+
export const redReask = (streak: number): number => Math.min(RED_REASK_MAX_MS, RED_REASK_MS * 2 ** Math.max(0, Math.min(10, streak - 1)))
|
|
105
|
+
|
|
96
106
|
/** a save moved check waits this long after the latest run someone else
|
|
97
107
|
* started in its repo (a terminal, an agent, a click): whoever gates that
|
|
98
108
|
* tree is still at work, and its own gate measures what it changed */
|
|
99
109
|
export const GATED_HOLD_MS = 10 * 60_000
|
|
100
110
|
|
|
101
|
-
/** above this
|
|
102
|
-
*
|
|
111
|
+
/** above this effective load per core (core/machine-busy.ts), the plan starts nothing on its own: every core is
|
|
112
|
+
* taken and already has a process waiting for it. A long run queue with free cores holds nothing */
|
|
103
113
|
export const LOAD_MAX = 1
|
|
104
114
|
|
|
105
|
-
/** the machine's 1 minute load average per core */
|
|
106
|
-
export const machineLoad = (): number => loadavg()[0]! / Math.max(1, availableParallelism())
|
|
107
|
-
|
|
108
115
|
/** a decided fact whose probe could not answer retries after this, doubled
|
|
109
116
|
* per skip in a row, up to ONCE_RETRY_MAX_MS. From its run on record, so a
|
|
110
117
|
* restart changes nothing */
|
|
@@ -147,8 +154,7 @@ export class Planner {
|
|
|
147
154
|
private readonly timers: PlanTimers
|
|
148
155
|
private readonly quietMs: number
|
|
149
156
|
private readonly maxWaitMs: number
|
|
150
|
-
private readonly
|
|
151
|
-
private readonly cores: number
|
|
157
|
+
private readonly machine: () => MachineLoad
|
|
152
158
|
private holdReason: string | null = null
|
|
153
159
|
private readonly catchUp: CatchUpStore | null
|
|
154
160
|
private beatAt: number
|
|
@@ -160,16 +166,15 @@ export class Planner {
|
|
|
160
166
|
* the window it had (catch-up.ts) */
|
|
161
167
|
private readonly bootAt: number
|
|
162
168
|
|
|
163
|
-
constructor(private o: { now?: () => number; timers?: PlanTimers; quietMs?: number; maxWaitMs?: number;
|
|
169
|
+
constructor(private o: { now?: () => number; timers?: PlanTimers; quietMs?: number; maxWaitMs?: number; machine?: () => MachineLoad; catchUp?: CatchUpStore; onError?: (repo: string, e: Error) => void } = {}) {
|
|
164
170
|
this.now = o.now ?? Date.now
|
|
165
171
|
this.catchUp = o.catchUp ?? null
|
|
166
172
|
this.bootAt = this.catchUp != null ? resumeCatchUp(this.now(), this.catchUp) : this.now()
|
|
167
173
|
this.beatAt = this.now()
|
|
168
|
-
this.cores = o.cores ?? availableParallelism()
|
|
169
174
|
this.timers = o.timers ?? realTimers
|
|
170
175
|
this.quietMs = o.quietMs ?? QUIET_MS
|
|
171
176
|
this.maxWaitMs = o.maxWaitMs ?? MAX_WAIT_MS
|
|
172
|
-
this.
|
|
177
|
+
this.machine = o.machine ?? (() => machineLoad())
|
|
173
178
|
}
|
|
174
179
|
|
|
175
180
|
private fail(repo: string, e: unknown): void {
|
|
@@ -341,7 +346,13 @@ export class Planner {
|
|
|
341
346
|
const due = raw != null && raw < this.bootAt ? this.bootAt + Math.round(stablePoint(`catch up\0${r.src.repo}\0${c.id}`) * CATCH_UP_MS) : raw
|
|
342
347
|
if (due == null) return { ...base, state: 'idle', reason: null, dueAt: null }
|
|
343
348
|
if (due > now) return { ...base, state: 'next', reason: 'scheduled', dueAt: due }
|
|
344
|
-
if (!active && wi.value === 'wait')
|
|
349
|
+
if (!active && wi.value === 'wait') {
|
|
350
|
+
if (last?.status !== 'fail') return { ...base, state: 'late', reason: 'late', dueAt: due }
|
|
351
|
+
// a red never waits for its repo: nobody is there to refresh it, so the plan asks again
|
|
352
|
+
const again = Math.max(due, lastAt + redReask(last.streak))
|
|
353
|
+
const inactive = `${wi.rule}, but its last run failed: asked again a day later, then less often while it stays red`
|
|
354
|
+
return { ...base, inactive, state: again > now ? 'next' : 'due', reason: 'scheduled', dueAt: again }
|
|
355
|
+
}
|
|
345
356
|
return { ...base, state: 'due', reason: 'scheduled', dueAt: due }
|
|
346
357
|
}
|
|
347
358
|
|
|
@@ -406,11 +417,11 @@ export class Planner {
|
|
|
406
417
|
return null
|
|
407
418
|
}
|
|
408
419
|
// a loaded machine runs only what someone asked for
|
|
409
|
-
const
|
|
410
|
-
if (
|
|
420
|
+
const m = this.machine()
|
|
421
|
+
if (effectiveLoad(m) > LOAD_MAX * Math.max(1, m.cores)) {
|
|
411
422
|
due = due.filter((x) => x.reason === 'asked')
|
|
412
423
|
if (due.length === 0) {
|
|
413
|
-
this.holdReason = `held:
|
|
424
|
+
this.holdReason = `held: ${machineWords(m)}`
|
|
414
425
|
return null
|
|
415
426
|
}
|
|
416
427
|
}
|
|
@@ -15,6 +15,7 @@ export const RECORDING_KIND = 'recording'
|
|
|
15
15
|
export function recordingKindAt(root: string, o: { unassigned?: boolean } = {}): MediaKind {
|
|
16
16
|
return {
|
|
17
17
|
kind: RECORDING_KIND,
|
|
18
|
+
what: 'the screen recorder\'s takes',
|
|
18
19
|
storeOf: (repoRoot) => (o.unassigned ? join(root, UNASSIGNED) : repoDir(root, repoRoot)),
|
|
19
20
|
stamp(store) {
|
|
20
21
|
const parts = recordingsIn(root, store).map((r) => `${r.id}:${statSync(join(r.dir, 'meta.json'), { throwIfNoEntry: false })?.mtimeMs ?? '-'}:${Object.keys(r.files).map((n) => `${n}=${statSync(join(r.dir, n), { throwIfNoEntry: false })?.size ?? '-'}`).join(',')}`)
|