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
package/src/cli/cmd_Review.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
// sk
|
|
2
|
-
// what he, a player or a rule raised, a worker claims and closes it (review/store.ts, wiki tools/shipkit/
|
|
1
|
+
// sk thread: an agent shows the owner something as one card of the one store and reads his answer; a dispatcher routes
|
|
2
|
+
// what he, a player or a rule raised, a worker claims and closes it (review/store.ts, wiki tools/shipkit/threads.md).
|
|
3
3
|
// Every module loads inside execute: the cli registers this file on every `sk` call
|
|
4
4
|
import { Command, Option } from 'clipanion'
|
|
5
|
+
import type { AnswerKind } from '../review/model.ts'
|
|
5
6
|
|
|
6
|
-
const DETAILS = `the one
|
|
7
|
+
const DETAILS = `threads, the one exchange with the owner (wiki tools/shipkit/threads.md): one thread per subject, found by its address <kind>:<key>, for its whole life. sk thread post <address> sends a version into it, linked by the tool; ask, propose, reply and update write in it, and start it when no thread owns the address. He answers in the hub's threads page; you read his answer with watch, inbox or the inbox hook, then mark it seen. What he, a player or a rule raises is an item of the same store with its own state, closed with sk thread fixed. The store: .shipkit/review/ of each repo, or the daemon's rows (sk thread move). SK_AGENT names your lane.`
|
|
7
8
|
|
|
8
9
|
type Ctx = { stdout: NodeJS.WritableStream; stderr: NodeJS.WritableStream }
|
|
9
10
|
type Unit = import('../review/unit.ts').ReviewUnit
|
|
@@ -33,8 +34,17 @@ async function run(context: Ctx, body: (h: Here) => Promise<number> | number, o:
|
|
|
33
34
|
const out = (l: string): void => void context.stdout.write(`${l}\n`)
|
|
34
35
|
const err = (l: string): void => void context.stderr.write(`${l}\n`)
|
|
35
36
|
try {
|
|
37
|
+
// the older name still works: it says the new one where a person reads it, never in a hook's or a script's output
|
|
38
|
+
const argv = process.argv.slice(2)
|
|
39
|
+
if (argv[0] === 'review' && !argv.includes('--hook') && !argv.includes('--json')) err(`sk review is now sk thread: sk thread ${argv.slice(1).map((a) => (/^[\w./=,@:+#-]+$/.test(a) ? a : JSON.stringify(a))).join(' ')}`)
|
|
36
40
|
const root = await reviewRoot(process.cwd())
|
|
37
|
-
if (root == null) throw new Error(`${process.cwd()} is in no shipkit repo (no repo.config.ts at its git root), so no hub would ever show what is stored here: run it from inside the repo the
|
|
41
|
+
if (root == null) throw new Error(`${process.cwd()} is in no shipkit repo (no repo.config.ts at its git root), so no hub would ever show what is stored here: run it from inside the repo the thread is for`)
|
|
42
|
+
// a repo where an agent writes in a thread needs a next session that hears it; the gate's repair wires the hook
|
|
43
|
+
if (WRITING_VERBS.has(argv[1] ?? '')) {
|
|
44
|
+
const { inboxHookLacks } = await import('../review/inbox-read.ts')
|
|
45
|
+
const lacks = inboxHookLacks(root)
|
|
46
|
+
if (lacks.length > 0) err(`review: no inbox hook runs here on ${lacks.join(' and ')}, so the next session may not hear his answer: sk ci --only SK049 wires it (wiki tools/shipkit/threads-how-it-fits.md)`)
|
|
47
|
+
}
|
|
38
48
|
if (o.unit === false) {
|
|
39
49
|
const { storeDir } = await import('../review/store.ts')
|
|
40
50
|
return await body({ dir: storeDir(root), unit: null, say: { spec: (await import('../review/model.ts')).NO_SPEC, more: () => [] }, out, err })
|
|
@@ -45,12 +55,17 @@ async function run(context: Ctx, body: (h: Here) => Promise<number> | number, o:
|
|
|
45
55
|
return await body({ dir, unit, say: { spec: specOf(dir), more: (x) => factLines(unit, x) }, out, err })
|
|
46
56
|
} catch (e) {
|
|
47
57
|
err(`FAIL: review: ${e instanceof Error ? e.message : String(e)}`)
|
|
48
|
-
|
|
58
|
+
// a walk of the cards' database runs: run it again once it ends
|
|
59
|
+
const { isStoreRefused, WAIT_EXIT } = await import('../core/machine-db.ts')
|
|
60
|
+
return isStoreRefused(e) && e.wait ? WAIT_EXIT : 1
|
|
49
61
|
}
|
|
50
62
|
}
|
|
51
63
|
|
|
52
64
|
const isHelp = (a: string): boolean => a === '--help' || a === '-h'
|
|
53
65
|
|
|
66
|
+
/** the verbs that write an agent's act in a thread */
|
|
67
|
+
const WRITING_VERBS = new Set(['post', 'add', 'add-view', 'ask', 'propose', 'reply', 'update', 'take', 'assign', 'working', 'fixed', 'done', 'attach', 'ready'])
|
|
68
|
+
|
|
54
69
|
/** the agent that acts: --as, else SK_AGENT; `need` refuses an unnamed one */
|
|
55
70
|
function actor(as: string | undefined, need: boolean, verb: string): string {
|
|
56
71
|
const n = as?.trim() || process.env.SK_AGENT?.trim()
|
|
@@ -60,14 +75,61 @@ function actor(as: string | undefined, need: boolean, verb: string): string {
|
|
|
60
75
|
return 'agent'
|
|
61
76
|
}
|
|
62
77
|
|
|
63
|
-
/** an item id
|
|
78
|
+
/** an item id, a player report's ref (`live#3`), or an address (`trailer:comfy-ts/main`, the newest version of the
|
|
79
|
+
* thread that owns it, or the one above it) to its item id */
|
|
64
80
|
async function idOf(dir: string, ref: string): Promise<string> {
|
|
65
|
-
const { itemOfRef } = await import('../review/store.ts')
|
|
81
|
+
const { itemOfRef, readAll, specOf } = await import('../review/store.ts')
|
|
82
|
+
const { addressOrThrow, ID_RE } = await import('../review/model.ts')
|
|
83
|
+
if (!ID_RE.test(ref) && ref.includes(':') && !/^\w+#\d+$/.test(ref)) {
|
|
84
|
+
const a = addressOrThrow(ref)
|
|
85
|
+
const { threadOfAddress } = await import('../review/threads.ts')
|
|
86
|
+
const t = threadOfAddress(a, readAll(dir).items, specOf(dir), { up: true })
|
|
87
|
+
if (!t) throw new Error(`no thread owns ${a}: sk thread post ${a} --title "…" --what "…" starts it`)
|
|
88
|
+
return t.head.item.id
|
|
89
|
+
}
|
|
66
90
|
const x = itemOfRef(dir, ref)
|
|
67
91
|
if (!x) throw new Error(`no item ${ref}`)
|
|
68
92
|
return x.item.id
|
|
69
93
|
}
|
|
70
94
|
|
|
95
|
+
/** an address an agent starts a thread on or links: its kind word must be one a kind declares (the repo's or the
|
|
96
|
+
* house's, `sk thread kinds`), so one subject never becomes two threads under two words */
|
|
97
|
+
async function declaredOrThrow(h: Here, a: string): Promise<void> {
|
|
98
|
+
const { readAll } = await import('../review/store.ts')
|
|
99
|
+
const { addressRefusal } = await import('../review/threads.ts')
|
|
100
|
+
const why = addressRefusal(a, readAll(h.dir).items, h.say.spec)
|
|
101
|
+
if (why !== null) throw new Error(why)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** the item an act on `ref` goes on: an id's, or the newest version of the thread its address has; an address no
|
|
105
|
+
* thread owns gets its thread opened with words first, `title` its title, so a question needs no picture */
|
|
106
|
+
|
|
107
|
+
/** an urgent word of an agent: it brings back a thread he set aside (wiki tools/shipkit/threads-asks.md, Snooze) */
|
|
108
|
+
async function urgentOn(dir: string, id: string, who: string): Promise<void> {
|
|
109
|
+
const { appendMessage } = await import('../review/store.ts')
|
|
110
|
+
appendMessage(dir, id, { who, urgent: true })
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async function idOrOpen(h: Here, ref: string, title: string, as: string | undefined): Promise<string> {
|
|
114
|
+
const { addressOrThrow, ID_RE } = await import('../review/model.ts')
|
|
115
|
+
if (ID_RE.test(ref) || !ref.includes(':') || /^\w+#\d+$/.test(ref)) return idOf(h.dir, ref)
|
|
116
|
+
const a = addressOrThrow(ref)
|
|
117
|
+
const { openThread, readAll, specOf } = await import('../review/store.ts')
|
|
118
|
+
const { threadOfAddress } = await import('../review/threads.ts')
|
|
119
|
+
const t = threadOfAddress(a, readAll(h.dir).items, specOf(h.dir), { up: true })
|
|
120
|
+
if (t) return t.head.item.id
|
|
121
|
+
await declaredOrThrow(h, a)
|
|
122
|
+
const lane = laneOfCaller(as)
|
|
123
|
+
const x = await openThread(h.dir, a, { title, ...(lane ? { lane } : {}) })
|
|
124
|
+
h.err(`${a}: no thread owned it, this one starts it: ${x.id}`)
|
|
125
|
+
return x.id
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** why a version that names no subject is refused: a thread is found by its address, so a version without one would
|
|
129
|
+
* start a thread nobody finds again */
|
|
130
|
+
const NO_ADDRESS =
|
|
131
|
+
'a version names the subject he judges, so it goes into that subject\'s one thread: sk thread post <kind>:<key> --title "…" --what "…" <media> (screen:<screen>, asset:<asset>, page:<page>, or a kind this repo\'s review unit declares; --trailer and --draft name their own). Page: wiki tools/shipkit/threads.md, The model'
|
|
132
|
+
|
|
71
133
|
/** the sources pulled before a read: a line per source down, said once a process */
|
|
72
134
|
const downSaid = new Set<string>()
|
|
73
135
|
async function pull(h: Here): Promise<void> {
|
|
@@ -135,8 +197,18 @@ export function takeViews(args: readonly string[]): { views: ViewInput[]; rest:
|
|
|
135
197
|
return { views, rest }
|
|
136
198
|
}
|
|
137
199
|
|
|
138
|
-
const ADD_VIEW_USAGE = 'add-view <id> "<label>" <a.png> [<b.png>] | --image <a.png> | --before <a.png> --after <b.png> | --video <clip> | --audio <sound> | --gallery <a.png> … [--label "<label>"] [--note "<text>"]'
|
|
200
|
+
const ADD_VIEW_USAGE = 'add-view <id> "<label>" <a.png> [<b.png>] | --image <a.png> | --before <a.png> --after <b.png> | --video <clip> | --audio <sound> | --gallery <a.png> … [--label "<label>"] [--note "<text>"] [--keep]'
|
|
139
201
|
const MEDIA_FILE = /\.(png|jpe?g|webp|gif|mp4|webm|mov|wav|mp3|flac|ogg|opus|m4a)$/i
|
|
202
|
+
|
|
203
|
+
/** one `--option` of a question: words, a media file, `<label>=<file>` or `<label>=<before>,<after>` (a gallery tile's
|
|
204
|
+
* form); the part after the last `=` is media only when each of its files is one */
|
|
205
|
+
export function askOption(a: string): { label: string; files?: string[] } {
|
|
206
|
+
const eq = a.lastIndexOf('=')
|
|
207
|
+
const tail = eq >= 0 ? a.slice(eq + 1).split(',').map((f) => f.trim()) : [a.trim()]
|
|
208
|
+
const media = tail.length <= 2 && tail.every((f) => MEDIA_FILE.test(f))
|
|
209
|
+
if (!media) return { label: a }
|
|
210
|
+
return { label: eq >= 0 ? a.slice(0, eq).trim() : '', files: tail }
|
|
211
|
+
}
|
|
140
212
|
const quoted = (a: string): string => (/^[\w./=,@:+-]+$/.test(a) ? a : `"${a.replace(/"/g, '\\"')}"`)
|
|
141
213
|
|
|
142
214
|
/** add-view's args: the positional form, or the view flags of add; a flag is never a label, `own` are the repo unit's flags */
|
|
@@ -172,7 +244,7 @@ export async function addViewArgs(args: readonly string[], own: readonly string[
|
|
|
172
244
|
if (label === undefined && gallery?.[0] !== undefined && !MEDIA_FILE.test(gallery[0]) && !gallery[0].includes('=')) label = gallery.shift()
|
|
173
245
|
const given = [files.length > 0 ? 'files' : '', one.image ? '--image' : '', one.video ? '--video' : '', one.audio ? '--audio' : '', one.before || one.after ? '--before --after' : '', gallery ? '--gallery' : ''].filter((x) => x !== '')
|
|
174
246
|
if (given.length !== 1) throw new Error(`${given.length === 0 ? 'no media' : `one media a view, not ${given.join(' and ')}`}; ${ADD_VIEW_USAGE}`)
|
|
175
|
-
if (!label?.trim()) throw new Error(`the view needs its label: sk
|
|
247
|
+
if (!label?.trim()) throw new Error(`the view needs its label: sk thread ${['add-view', id, '"<label>"', ...args.filter((a) => a !== id).map(quoted)].join(' ')}`)
|
|
176
248
|
if ((one.before === undefined) !== (one.after === undefined)) throw new Error(`--before and --after go together; ${ADD_VIEW_USAGE}`)
|
|
177
249
|
if (gallery?.length === 0) throw new Error(`--gallery needs its images; ${ADD_VIEW_USAGE}`)
|
|
178
250
|
const view: ViewInput = one.image
|
|
@@ -207,7 +279,7 @@ function flagsOf(args: readonly string[], values: readonly string[], repeat: rea
|
|
|
207
279
|
on.add(name)
|
|
208
280
|
continue
|
|
209
281
|
}
|
|
210
|
-
if (!values.includes(name) && !repeat.includes(name)) throw new Error(`${a}: no such flag (sk
|
|
282
|
+
if (!values.includes(name) && !repeat.includes(name)) throw new Error(`${a}: no such flag (sk thread post --help)`)
|
|
211
283
|
const v = args[i + 1]
|
|
212
284
|
if (v === undefined) throw new Error(`${a}: needs a value`)
|
|
213
285
|
i++
|
|
@@ -218,33 +290,37 @@ function flagsOf(args: readonly string[], values: readonly string[], repeat: rea
|
|
|
218
290
|
}
|
|
219
291
|
|
|
220
292
|
const ADD_FLAGS = `flags:
|
|
221
|
-
--title "<title>" one short line: what he looks at (a lone "<title>" after
|
|
293
|
+
--title "<title>" one short line: what he looks at (a lone "<title>" after the address is the same)
|
|
222
294
|
--what "<what>" what changed and why, short markdown: one line, then - bullets
|
|
223
295
|
--post "<line>" the public line for a post of it, what a user gets (the repo's guard reads it)
|
|
224
|
-
--changelog "<category>: <line>" its change in the release being filled: on his approval it lands in .shipkit/releases/next.md with the
|
|
296
|
+
--changelog "<category>: <line>" its change in the release being filled: on his approval it lands in .shipkit/releases/next.md with the version's after picture (the repo's guard reads it)
|
|
225
297
|
--rating <safe|mild|explicit> with --changelog: what its media shows at full size, the rating its picture lands with; unset, unrated (reads explicit: no SFW venue shows it)
|
|
298
|
+
--verdict words with no media wait for the owner's verdict like a version (a version asks it always)
|
|
226
299
|
--image <a.png> the subject; a clip (webm, mp4) goes anywhere an image goes
|
|
227
300
|
--video <clip.mp4> a clip
|
|
228
301
|
--audio <sound.wav> a sound: a waveform and a player (wav, mp3, flac, ogg, opus, m4a)
|
|
229
302
|
--before <a.png> --after <b.png> a before and after: two images, two clips of one size, or two sounds
|
|
230
303
|
--label "<label>" the first view's label
|
|
231
304
|
--view "<label>" <a.png> [<b.png>] another view of the same subject (repeat it); --note "<text>" right after it: a line on that view
|
|
232
|
-
--choice
|
|
233
|
-
--pick <
|
|
305
|
+
--choice the older form of a question: posts sk thread ask with each --view an option, and prints that form
|
|
306
|
+
--pick <n> with --choice: the option you suggest, by its number from 1 (a letter or a label works too); the « my pick » pill
|
|
234
307
|
--gallery "<label>" <a.png> … a grid he rates tile by tile (stars, OK, fix or no, a word), alone or beside other views; a tile is "[<row>/]<label>=[<before>,]<after>": a redraw carries its before, a row holds one asset's variants
|
|
235
|
-
--trailer <cut.trailer> a trailer cut, played in the
|
|
308
|
+
--trailer <cut.trailer> a trailer cut, played in the thread by the trailer entry's player, never a compiled clip; his notes land on its shots
|
|
236
309
|
--version v<n> with --trailer: a kept version of that cut, else the cut's own render
|
|
237
310
|
--before v<m> | <cut> with --trailer: the render he switches to on the same shot
|
|
238
311
|
--shots <a,b> with --trailer: the shots the change touched (else, with --before, the shots whose block differs)
|
|
239
|
-
--
|
|
312
|
+
--draft <slug> a post draft of the repo's social store (its slug or its topic), shown itself in the thread, read live: a block a place, each with its own OK, fix or no and his word; no image is made
|
|
313
|
+
--topic <topic> what part of the project it is about (sk thread topics)
|
|
240
314
|
--subject <kind> what is judged (default shot; the repo's unit names its kinds)
|
|
241
315
|
--commit <sha> the commit it shows
|
|
242
316
|
--lane <id> the lane that made it; else SK_AGENT
|
|
243
|
-
--wip "<what is still wrong>" a
|
|
244
|
-
--
|
|
317
|
+
--wip "<what is still wrong>" a version sent in work: « in progress », no verdict asked; each step after: sk thread update <id> <broken|better|fixed> "<line>" <file>
|
|
318
|
+
--on <address> the version's own address (page:review/lightbox, trailer:<name>/<cut>): it goes into the thread that owns it, one thread per address; a trailer or a draft names its own
|
|
319
|
+
--about <address> another object it is about, a link that finds it (repeat it); never its thread
|
|
245
320
|
--answers <id | live#3> the item it answers (a note he raised, a player's report), one thread (repeat it)
|
|
246
|
-
--keeps "<what stays>"
|
|
247
|
-
--new --why "<reason>" a
|
|
321
|
+
--keeps "<what stays>" on a new version of an approved look: what of it stays
|
|
322
|
+
--new --why "<reason>" a version with no address of its own whose title reads like an active thread's: why it is another subject
|
|
323
|
+
--keep every picture as given; otherwise a png lands as a lossless webp, its pixels checked exact, and the version keeps that webp alone (a jpeg always lands as given)`
|
|
248
324
|
|
|
249
325
|
/** the help of add or add-view, then the flags this repo's review unit adds (any kind's, then each kind's under
|
|
250
326
|
* `--subject <kind>`); a repo with no unit, or one that does not load, says so on one line */
|
|
@@ -271,7 +347,7 @@ export async function trailerOfFlags(o: Record<string, string>, others: boolean)
|
|
|
271
347
|
return null
|
|
272
348
|
}
|
|
273
349
|
const clash = ['image', 'video', 'audio', 'after', 'live'].filter((k) => o[k] !== undefined)
|
|
274
|
-
if (clash.length > 0 || others) throw new Error(`--trailer: the
|
|
350
|
+
if (clash.length > 0 || others) throw new Error(`--trailer: the version plays the cut; no ${clash.length > 0 ? clash.map((k) => `--${k}`).join(', ') : '--view, --gallery, --choice or --wip'} beside it`)
|
|
275
351
|
const { mkdtempSync, rmSync } = await import('node:fs')
|
|
276
352
|
const { tmpdir } = await import('node:os')
|
|
277
353
|
const { join } = await import('node:path')
|
|
@@ -290,20 +366,34 @@ export async function trailerOfFlags(o: Record<string, string>, others: boolean)
|
|
|
290
366
|
}
|
|
291
367
|
}
|
|
292
368
|
|
|
369
|
+
/** --draft as a card: the post draft its slug names, pinned by the hashes of its head and of each message; null without
|
|
370
|
+
* --draft. A draft that does not load clean is refused in the loader's words */
|
|
371
|
+
export async function draftOfFlags(o: Record<string, string>, others: boolean, cwd: string = process.cwd()): Promise<import('../review/model.ts').DraftCard | null> {
|
|
372
|
+
if (o.draft === undefined) return null
|
|
373
|
+
const clash = ['image', 'video', 'audio', 'before', 'after', 'label', 'live', 'trailer'].filter((k) => o[k] !== undefined)
|
|
374
|
+
if (clash.length > 0 || others) throw new Error(`--draft: the version shows the draft itself; no ${clash.length > 0 ? clash.map((k) => `--${k}`).join(', ') : '--view, --gallery or --choice'} beside it`)
|
|
375
|
+
const [{ findRepoRoot }, { openDesk }, { draftCardOf }] = await Promise.all([import('../ts/config.ts'), import('../social/open.ts'), import('../review/draft-card.ts')])
|
|
376
|
+
return draftCardOf((await openDesk(findRepoRoot(cwd))).desk, o.draft, cwd).card
|
|
377
|
+
}
|
|
378
|
+
|
|
293
379
|
export class ReviewAddCommand extends Command {
|
|
294
|
-
static override paths = [['review', 'add']]
|
|
380
|
+
static override paths = [['thread', 'post'], ['review', 'add']]
|
|
295
381
|
static essential = {}
|
|
382
|
+
/** the flags its proxy reads, as its help lists them: what a doc may name (RV019) */
|
|
383
|
+
static proxyFlags = [...new Set(ADD_FLAGS.match(/--[a-z][a-z0-9-]*/g) ?? [])]
|
|
296
384
|
static override usage = Command.Usage({
|
|
297
385
|
category: 'Review',
|
|
298
|
-
description:
|
|
299
|
-
details: `${DETAILS}\n\n${ADD_FLAGS}`,
|
|
386
|
+
description: "a version in the thread of its subject, by its address; it starts the thread; no media: words",
|
|
387
|
+
details: `${DETAILS}\n\nsk thread post [<address> | <id>] <flags>. The address is the version's own (screen:<screen>, asset:<asset>, page:<page>, a kind of the repo's unit); --trailer and --draft name theirs, so it may be left out. An id names its thread. With no media, --title and --what are words: they start the thread, or are a reply in it. sk thread add is its older name.\n\n${ADD_FLAGS}`,
|
|
300
388
|
examples: [
|
|
301
|
-
['one image', 'sk
|
|
302
|
-
['a before and after', 'sk
|
|
303
|
-
['
|
|
304
|
-
['a pick among three voices, yours on the second', 'sk
|
|
305
|
-
['icons he rates one by one', 'sk
|
|
306
|
-
['a trailer cut against its last kept version', 'sk
|
|
389
|
+
['one image', 'sk thread post screen:menu --title "the new menu" --what "the menu, bigger" --image shots/menu.png'],
|
|
390
|
+
['a before and after', 'sk thread post asset:lamps --title "lamps lit" --what "..." --before a.png --after b.png'],
|
|
391
|
+
['the next version: the same address, the tool links it', 'sk thread post asset:lamps --title "lamps lit, warmer" --what "..." --image c.png'],
|
|
392
|
+
['a pick among three voices, yours on the second', 'sk thread post asset:narrator --choice --pick 2 --title "the narrator" --what "..." --view "voice 0" a.flac --note "low, breathy" --view "voice 1" b.flac --view "voice 2" c.flac'],
|
|
393
|
+
['icons he rates one by one', 'sk thread post asset:buff-icons --title "buff icons" --what "..." --gallery "icons" vitality=a.png haste=b.png greed=c.png'],
|
|
394
|
+
['a trailer cut against its last kept version', 'sk thread post --trailer trailer/demo/main.trailer --version v4 --before v3 --title "the drop, recut" --what "..."'],
|
|
395
|
+
['a post draft, each place answered on its own', 'sk thread post --draft 20261119-174922-trailer --title "the trailer post" --what "..."'],
|
|
396
|
+
['words, no picture', 'sk thread post messages:tui/u1 --title "the hook line" --what "three phrasings tested, the second wins"'],
|
|
307
397
|
],
|
|
308
398
|
})
|
|
309
399
|
args = Option.Proxy()
|
|
@@ -314,6 +404,7 @@ export class ReviewAddCommand extends Command {
|
|
|
314
404
|
}
|
|
315
405
|
return run(this.context, async (h) => {
|
|
316
406
|
const { addItem, postUpdate, agentName } = await import('../review/store.ts')
|
|
407
|
+
if (this.path[1] === 'add') h.err('sk thread add is now sk thread post [<address>]: the same flags')
|
|
317
408
|
// `--wip "<what is still wrong>"`: a card sent in work, its first update still broken; a bare --wip goes with --live
|
|
318
409
|
const w = this.args.indexOf('--wip')
|
|
319
410
|
const wipLine = w >= 0 && this.args[w + 1] !== undefined && !this.args[w + 1]!.startsWith('--') ? this.args[w + 1] : undefined
|
|
@@ -322,22 +413,50 @@ export class ReviewAddCommand extends Command {
|
|
|
322
413
|
const kindName = rest[rest.indexOf('--subject') + 1]
|
|
323
414
|
const kind = rest.includes('--subject') && kindName ? h.unit?.kinds?.[kindName] : undefined
|
|
324
415
|
const own = [...Object.keys(kind?.flags ?? {}), ...Object.keys(h.unit?.flags ?? {})]
|
|
325
|
-
const f = flagsOf(rest, ['title', 'what', 'post', 'changelog', 'rating', 'image', 'video', 'audio', 'before', 'after', 'label', 'topic', 'subject', 'commit', 'lane', 'supersedes', 'keeps', 'why', 'live', 'trailer', 'version', 'shots', 'pick'], ['answers', ...own], ['new', 'wip', 'choice'])
|
|
416
|
+
const f = flagsOf(rest, ['title', 'what', 'post', 'changelog', 'rating', 'image', 'video', 'audio', 'before', 'after', 'label', 'topic', 'subject', 'commit', 'lane', 'supersedes', 'keeps', 'why', 'live', 'trailer', 'version', 'shots', 'pick', 'draft', 'on'], ['answers', 'about', ...own], ['new', 'wip', 'choice', 'keep', 'verdict'])
|
|
326
417
|
const o = f.one
|
|
418
|
+
// the first word names the thread: an address (the version's own), or an id (its thread)
|
|
419
|
+
const { addressOrThrow, canonicalAddress, ID_RE } = await import('../review/model.ts')
|
|
420
|
+
const first = f.positionals[0]
|
|
421
|
+
// post names its thread first; add's lone word is a title, unless it reads as an address
|
|
422
|
+
const named = first !== undefined && (ID_RE.test(first) || canonicalAddress(first) !== null || (this.path[1] === 'post' && !MEDIA_FILE.test(first)))
|
|
423
|
+
const target = named ? f.positionals.shift() : undefined
|
|
424
|
+
if (target !== undefined && ID_RE.test(target)) {
|
|
425
|
+
const { readAll } = await import('../review/store.ts')
|
|
426
|
+
const { threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
427
|
+
const { ownAddressOf } = await import('../review/model.ts')
|
|
428
|
+
const t = threadOfItem((await idOf(h.dir, target)), threadsOf(readAll(h.dir).items, h.say.spec))
|
|
429
|
+
if (!t) throw new Error(`no thread holds ${target}`)
|
|
430
|
+
const head = t.head.item
|
|
431
|
+
const own = ownAddressOf(head, h.say.spec)
|
|
432
|
+
if (head.origin.by === 'agent') o.supersedes ??= head.id
|
|
433
|
+
else if (own !== null) o.on ??= own
|
|
434
|
+
else f.many.answers = [...(f.many.answers ?? []), head.id]
|
|
435
|
+
} else if (target !== undefined) {
|
|
436
|
+
const a = addressOrThrow(target)
|
|
437
|
+
if (o.on !== undefined && addressOrThrow(o.on) !== a) throw new Error(`${a} and --on ${o.on}: one address a version`)
|
|
438
|
+
o.on = a
|
|
439
|
+
}
|
|
440
|
+
if (o.on !== undefined) await declaredOrThrow(h, addressOrThrow(o.on))
|
|
441
|
+
for (const a of f.many.about ?? []) await declaredOrThrow(h, addressOrThrow(a))
|
|
327
442
|
// a lone word is the title, as `sk ask <title>` takes it; a media file never is
|
|
328
443
|
const [lone, ...more] = f.positionals
|
|
329
444
|
if (lone !== undefined && more.length === 0 && o.title === undefined && !MEDIA_FILE.test(lone)) o.title = lone
|
|
330
|
-
else if (lone !== undefined) throw new Error(`unexpected ${f.positionals.map(quoted).join(' ')}: the title is --title "<title>", the subject --image <a.png> (sk
|
|
445
|
+
else if (lone !== undefined) throw new Error(`unexpected ${f.positionals.map(quoted).join(' ')}: the title is --title "<title>", the subject --image <a.png> (sk thread post --help)`)
|
|
446
|
+
if (f.on.has('choice') && f.on.has('verdict')) throw new Error("--choice --verdict: a choice is a question, its pick is the owner's answer; post it without --verdict")
|
|
447
|
+
if (f.on.has('choice')) return choiceAsQuestion(h, o, views, f.many)
|
|
448
|
+
const states = await statesOfFlags(h, o, views.length > 0)
|
|
331
449
|
const trailer = await trailerOfFlags(o, views.length > 0 || f.on.has('wip') || f.on.has('choice'))
|
|
450
|
+
const draft = await draftOfFlags(o, views.length > 0 || f.on.has('choice'))
|
|
332
451
|
const repoFlags = Object.fromEntries(own.flatMap((k) => (f.many[k] ? [[k, f.many[k]]] : [])))
|
|
333
452
|
const parsed = kind?.parse ? kind.parse(Object.fromEntries(Object.keys(kind.flags ?? {}).map((k) => [k, f.many[k] ?? []]))) : null
|
|
334
|
-
if (wipLine !== undefined && o.live !== undefined) throw new Error('--wip "<line>" sends a
|
|
453
|
+
if (wipLine !== undefined && o.live !== undefined) throw new Error('--wip "<line>" sends a version in work; --wip --live <name> a draft on a live shot: one of the two')
|
|
335
454
|
if (wipLine === undefined && f.on.has('wip') !== (o.live !== undefined))
|
|
336
|
-
throw new Error('--wip "<what is still wrong>" sends a
|
|
455
|
+
throw new Error('--wip "<what is still wrong>" sends a version in work (sk thread update as it moves); --wip --live <name> a draft on a live shot')
|
|
337
456
|
let wipViews: ViewInput[] = []
|
|
338
457
|
if (o.live !== undefined) {
|
|
339
458
|
if (!h.unit?.live) throw new Error("--live: the repo's review unit declares no live shots (live: { frames })")
|
|
340
|
-
if (o.image || o.video || o.audio || o.before || o.after || views.length > 0) throw new Error('--wip: the
|
|
459
|
+
if (o.image || o.video || o.audio || o.before || o.after || views.length > 0) throw new Error('--wip: the version shows the live shot alone, no --image, --video, pair or --view beside it')
|
|
341
460
|
const fr = h.unit.live.frames(o.live)
|
|
342
461
|
wipViews = [{ label: '', image: fr.image }, ...(fr.history.length > 0 ? [{ label: 'history', gallery: fr.history }] : [])]
|
|
343
462
|
}
|
|
@@ -375,9 +494,11 @@ export class ReviewAddCommand extends Command {
|
|
|
375
494
|
what: o.what ?? '',
|
|
376
495
|
...(o.post ? { post: o.post } : {}),
|
|
377
496
|
...(changelog ? { changelog } : {}),
|
|
378
|
-
...(parsed ? { subject: parsed.subject } : o.subject ? { subject: { kind: o.subject } } : trailer ? { subject: { kind: 'trailer' } } : {}),
|
|
497
|
+
...(parsed ? { subject: parsed.subject } : o.subject ? { subject: { kind: o.subject } } : trailer ? { subject: { kind: 'trailer' } } : draft ? { subject: { kind: 'draft', slug: draft.slug } } : {}),
|
|
379
498
|
...(topic ? { topic } : {}),
|
|
380
499
|
...(trailer ? { image: trailer.image, trailer: trailer.card } : {}),
|
|
500
|
+
...(draft ? { draft } : {}),
|
|
501
|
+
...(states ? { states } : {}),
|
|
381
502
|
...(o.image ? { image: o.image } : {}),
|
|
382
503
|
...(o.video ? { video: o.video } : {}),
|
|
383
504
|
...(o.audio ? { audio: o.audio } : {}),
|
|
@@ -390,24 +511,63 @@ export class ReviewAddCommand extends Command {
|
|
|
390
511
|
...(o.keeps ? { keeps: o.keeps } : {}),
|
|
391
512
|
...(o.why ? { why: o.why } : {}),
|
|
392
513
|
...(answers.length > 0 ? { answers } : {}),
|
|
514
|
+
...(o.on ? { on: o.on } : {}),
|
|
515
|
+
...((f.many.about ?? []).length > 0 ? { about: f.many.about } : {}),
|
|
393
516
|
...(f.on.has('new') ? { fresh: true } : {}),
|
|
394
517
|
...(f.on.has('choice') ? { choice: true } : {}),
|
|
518
|
+
...(f.on.has('keep') ? { keep: true } : {}),
|
|
395
519
|
...(o.pick !== undefined ? { agentPick: o.pick } : {}),
|
|
396
520
|
...(o.live !== undefined ? { image: wipViews[0]?.image ?? '', views: wipViews.slice(1), wip: { live: o.live } } : { views }),
|
|
397
521
|
}
|
|
522
|
+
const media = [o.image, o.video, o.audio, o.before, o.after, o.live, o.trailer, o.draft].some((v) => v !== undefined) || views.length > 0 || states !== null
|
|
523
|
+
if (!media && input.on !== undefined) return postWords(h, input.on, input.title, input.what, input.lane, f.on.has('verdict'))
|
|
524
|
+
// a version asks the owner's verdict always: the field says it, the flag changes nothing else
|
|
525
|
+
if (f.on.has('verdict')) input = { ...input, asksVerdict: true }
|
|
398
526
|
if (h.unit?.add) input = await h.unit.add(input, repoFlags)
|
|
527
|
+
const { ownAddressOf } = await import('../review/model.ts')
|
|
528
|
+
const address = ownAddressOf({ subject: input.subject ?? { kind: 'shot' }, ...(input.on ? { on: input.on } : {}), ...(input.trailer ? { trailer: input.trailer } : {}), origin: { by: 'agent' }, views: [] } as unknown as import('../review/model.ts').Item, h.say.spec)
|
|
529
|
+
if (address === null && input.supersedes === undefined && (input.answers ?? []).length === 0) {
|
|
530
|
+
trailer?.drop()
|
|
531
|
+
throw new Error(NO_ADDRESS)
|
|
532
|
+
}
|
|
399
533
|
const item = await addItem(h.dir, input).finally(() => trailer?.drop())
|
|
400
534
|
h.out(item.id)
|
|
535
|
+
// on stderr: a script reads the id alone on stdout
|
|
536
|
+
await saidIntoThread(h, item, o.supersedes !== undefined)
|
|
401
537
|
if (wipLine !== undefined) {
|
|
402
538
|
const who = item.origin.by === 'agent' ? (item.origin.lane ?? agentName()) : agentName()
|
|
403
539
|
await postUpdate(h.dir, item.id, { who, state: 'broken', text: wipLine })
|
|
404
|
-
h.err(`in progress: he sees it, it waits on no verdict; post each step with sk
|
|
540
|
+
h.err(`in progress: he sees it, it waits on no verdict; post each step with sk thread update ${item.id} <broken|better|fixed> "<line>" <file>`)
|
|
405
541
|
}
|
|
406
542
|
// on stderr: a script reads the id alone on stdout
|
|
407
543
|
for (const line of await (await import('../review/previews.ts')).playCopies(h.dir, item)) h.err(line)
|
|
408
|
-
if (item.trailer) h.out(`trailer
|
|
409
|
-
|
|
410
|
-
if (item.
|
|
544
|
+
if (item.trailer) h.out(`trailer version: ${item.trailer.trailer}/${item.trailer.after.cut}${item.trailer.before ? ` against ${item.trailer.before.cut}` : ''}${item.trailer.shots.length > 0 ? `, shots ${item.trailer.shots.join(', ')}` : ''}`)
|
|
545
|
+
// a cut shown on a card is a version from then on: the next edit of its file makes the one after it
|
|
546
|
+
if (item.trailer && o.trailer !== undefined && o.version === undefined) {
|
|
547
|
+
try {
|
|
548
|
+
const [b, { keepShown, thumbnailKept, versionVideo }, { findRepoRoot }] = await Promise.all([import('../trailer/build.ts'), import('../trailer/passage.ts'), import('../ts/config.ts')])
|
|
549
|
+
const root = findRepoRoot(process.cwd())
|
|
550
|
+
const l = await b.load(b.trailerFile(o.trailer, root, process.cwd()), root)
|
|
551
|
+
if ((await import('node:fs')).existsSync(b.mockMark(l))) h.err('the cut this version shows is a MOCK (sk trailer --mock built it last): its --what must say so; for the filmed cut, sk trailer first')
|
|
552
|
+
// a version is a video a post may use: a cut that may not render (no thumbnail word) keeps none
|
|
553
|
+
if (l.errors.length > 0) throw new Error(`${l.errors[0]!.message} (line ${l.errors[0]!.line})`)
|
|
554
|
+
const lines: string[] = []
|
|
555
|
+
const v = keepShown(l, (line) => lines.push(line), process.cwd())
|
|
556
|
+
// what the keep says is left by hand (its index row, the commit, the tag) is said here too
|
|
557
|
+
for (const line of lines) h.err(line)
|
|
558
|
+
h.err(v ? `kept as ${v}: the trailer page lists it, and the file now makes the version after it` : 'this render is kept already: no new version')
|
|
559
|
+
const video = v ? versionVideo(l.dir, v) : null
|
|
560
|
+
if (video)
|
|
561
|
+
await thumbnailKept(l, video, (line) => h.err(line), process.cwd()).catch((e: unknown) =>
|
|
562
|
+
h.err(`WARN ${v} is kept, its thumbnail is not: ${(e as Error).message}`),
|
|
563
|
+
)
|
|
564
|
+
} catch (e) {
|
|
565
|
+
h.err(`WARN the version is sent, the cut was not kept as a version: ${(e as Error).message}`)
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
if (item.draft) h.out(`draft version: ${item.draft.slug}, ${item.draft.posts.length} place${item.draft.posts.length > 1 ? 's' : ''}: ${item.draft.posts.map((p) => p.name).join(', ')}`)
|
|
569
|
+
if (item.origin.by === 'agent' && !item.origin.lane) h.err('no lane on the version: pass --lane <id> (or SK_AGENT), so the hub colours it')
|
|
570
|
+
if (item.choice && item.agentPick === undefined) h.err(`a choice with no pick of yours: every question carries one, sk thread pick ${item.id} <view> (or --pick on post)`)
|
|
411
571
|
const { unheardLine } = await import('../review/model.ts')
|
|
412
572
|
const { liveWatchers } = await import('../review/watchers.ts')
|
|
413
573
|
const unheard = unheardLine(item, liveWatchers(h.dir))
|
|
@@ -417,16 +577,130 @@ export class ReviewAddCommand extends Command {
|
|
|
417
577
|
}
|
|
418
578
|
}
|
|
419
579
|
|
|
580
|
+
/** what a version that went into a thread says on stderr: the version it follows (and that one's verdict, which only the
|
|
581
|
+
* newest version takes), the way out for a subject of its own, and his notes it leaves open */
|
|
582
|
+
/** `post <address> --before <state> --after <state>` on an object of a kind (threads-how-it-fits.md, Kinds): each side
|
|
583
|
+
* a json file (`{ json, files? }` or bare json), or a git ref (`.` the working tree) the kind's `read` turns into one;
|
|
584
|
+
* null when the flags are a picture's before and after. The flags it takes are cleared, so no media reads them */
|
|
585
|
+
async function statesOfFlags(h: Here, o: Record<string, string>, views: boolean): Promise<{ before?: import('../review/model.ts').StoredState; after: import('../review/model.ts').StoredState } | null> {
|
|
586
|
+
if (o.on === undefined || o.after === undefined) return null
|
|
587
|
+
const word = o.on.slice(0, o.on.indexOf(':'))
|
|
588
|
+
const key = o.on.slice(o.on.indexOf(':') + 1)
|
|
589
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
590
|
+
const root = findRepoRoot(process.cwd())
|
|
591
|
+
const kind = (await import('../review/house-kind-defs.ts')).serverKindOf(root, h.unit, word)
|
|
592
|
+
const json = (v: string): boolean => /\.json$/i.test(v)
|
|
593
|
+
if (!kind?.read && !json(o.after)) return null
|
|
594
|
+
if (views || o.image || o.video || o.audio) throw new Error(`${o.on}: a version of an object shows its two states alone, no picture beside them`)
|
|
595
|
+
const { existsSync, readFileSync } = await import('node:fs')
|
|
596
|
+
const side = async (flag: string, v: string): Promise<import('../review/model.ts').StoredState> => {
|
|
597
|
+
if (json(v)) {
|
|
598
|
+
if (!existsSync(v)) throw new Error(`--${flag} ${v}: no such file`)
|
|
599
|
+
const parsed = JSON.parse(readFileSync(v, 'utf8')) as unknown
|
|
600
|
+
return typeof parsed === 'object' && parsed !== null && 'json' in parsed ? (parsed as import('../review/model.ts').StoredState) : { json: parsed }
|
|
601
|
+
}
|
|
602
|
+
if (!kind?.read) throw new Error(`--${flag} ${v}: a json file, or a git ref the kind reads; the kind ${word} declares no read`)
|
|
603
|
+
let at: string | undefined
|
|
604
|
+
if (v !== '.') {
|
|
605
|
+
const p = Bun.spawnSync(['git', '-C', root, 'rev-parse', '--verify', '--quiet', `${v}^{commit}`], { stdout: 'pipe', stderr: 'ignore' })
|
|
606
|
+
at = p.stdout.toString().trim()
|
|
607
|
+
if (p.exitCode !== 0 || at === '') throw new Error(`--${flag} ${v}: no commit of this repo by that name (a json file, a git ref, or . for the working tree)`)
|
|
608
|
+
}
|
|
609
|
+
const st = await kind.read(key, at)
|
|
610
|
+
if (st === null) throw new Error(`--${flag} ${v}: the kind ${word} reads no ${key} there`)
|
|
611
|
+
return { ...st, ...(at ? { at } : {}) }
|
|
612
|
+
}
|
|
613
|
+
const after = await side('after', o.after)
|
|
614
|
+
const before = o.before !== undefined ? await side('before', o.before) : undefined
|
|
615
|
+
delete o.before
|
|
616
|
+
delete o.after
|
|
617
|
+
return { ...(before ? { before } : {}), after }
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/** `post --choice`, the older form of a question with media options: each view an option (its note after its label),
|
|
621
|
+
* the title and what its words, posted as the question into the address's thread; it prints the `ask` form */
|
|
622
|
+
async function choiceAsQuestion(h: Here, o: Record<string, string>, views: readonly ViewInput[], many: Record<string, string[]>): Promise<number> {
|
|
623
|
+
const versionOnly = ['changelog', 'rating', 'post', 'keeps', 'supersedes', 'trailer', 'draft', 'live', 'why'].filter((k) => o[k] !== undefined)
|
|
624
|
+
if (many.answers?.length) versionOnly.push('answers')
|
|
625
|
+
if (versionOnly.length > 0) throw new Error(`--choice is a question now, and a question takes no ${versionOnly.map((k) => `--${k}`).join(', ')}: ask, then post the version once he picked`)
|
|
626
|
+
if (views.some((v) => v.gallery)) throw new Error('--choice: a gallery is no option; a set he rates one by one stays a gallery version, a row per asset')
|
|
627
|
+
if (o.on === undefined) throw new Error(NO_ADDRESS)
|
|
628
|
+
const first = o.image ?? o.video ?? o.audio
|
|
629
|
+
const all: ViewInput[] = [...(first !== undefined ? [{ label: o.label ?? 'option 1', image: first }] : o.before !== undefined && o.after !== undefined ? [{ label: o.label ?? 'option 1', before: o.before, after: o.after }] : []), ...views]
|
|
630
|
+
const options = all.map((v) => ({ label: v.note?.trim() ? `${v.label}: ${v.note.trim()}` : v.label, files: v.before !== undefined && v.after !== undefined ? [v.before, v.after] : [v.image ?? v.video ?? v.audio ?? ''] }))
|
|
631
|
+
const { viewIndexOf } = await import('../review/model.ts')
|
|
632
|
+
const pick = o.pick === undefined ? undefined : /^\d+$/.test(o.pick) ? Number(o.pick) - 1 : viewIndexOf(all, o.pick)
|
|
633
|
+
const text = [o.title, o.what].filter((x) => x?.trim()).join('\n') || 'which one ?'
|
|
634
|
+
const form = `sk thread ask ${o.on} ${quoted(text.split('\n')[0]!)} ${options.map((x) => `--option ${quoted(`${x.label}=${x.files.join(',')}`)}`).join(' ')}${pick !== undefined ? ` --pick ${pick + 1}` : ''}`
|
|
635
|
+
h.err(`post --choice is now a question: ${form}`)
|
|
636
|
+
if (pick === undefined) h.err('no --pick: the house rule wants your pick on every question')
|
|
637
|
+
const { postAsk } = await import('../review/store.ts')
|
|
638
|
+
const as = o.lane
|
|
639
|
+
const id = await idOrOpen(h, o.on, o.title ?? text, as)
|
|
640
|
+
const m = await postAsk(h.dir, id, { who: actor(as, false, 'ask'), text, options, ...(pick !== undefined ? { pick } : {}) })
|
|
641
|
+
h.out(`${id} asked: ${m.ask?.options.map((x, i) => `${i + 1} ${x}${m.ask?.pick === i ? ' (your pick)' : ''}`).join(' · ')}`)
|
|
642
|
+
return 0
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
async function saidIntoThread(h: Here, item: import('../review/model.ts').Item, typed: boolean): Promise<void> {
|
|
646
|
+
const { readAll } = await import('../review/store.ts')
|
|
647
|
+
const { ownAddressOf, stateOf, verdictOf } = await import('../review/model.ts')
|
|
648
|
+
const { threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
649
|
+
const items = readAll(h.dir).items
|
|
650
|
+
const t = threadOfItem(item.id, threadsOf(items, h.say.spec))
|
|
651
|
+
const own = ownAddressOf(item, h.say.spec)
|
|
652
|
+
const before = item.supersedes === undefined ? undefined : items.find((x) => x.item.id === item.supersedes)
|
|
653
|
+
if (before && !typed) {
|
|
654
|
+
const waited = verdictOf(before) === null && before.item.views.length > 0
|
|
655
|
+
h.err(`into its thread ${own ?? ''}: the next version after ${before.item.id} "${before.item.title}"${waited ? ', which waited on his answer: only this one takes his marks now' : ''}. A subject he judges on its own takes its own address: --on ${own ?? '<kind>:<key>'}/<part>`)
|
|
656
|
+
}
|
|
657
|
+
const notes = t ? [...(t.head.item.origin.by === 'agent' ? [] : [t.head]), ...t.answers.filter((x) => t.joined.has(x.item.id))] : []
|
|
658
|
+
const open = notes.filter((x) => stateOf(x, false).state !== 'closed' && !(item.answers ?? []).includes(x.item.id))
|
|
659
|
+
if (open.length > 0) h.err(`his notes in the thread stay open: ${open.map((x) => `${x.item.id} "${x.item.title}"`).join('; ')}. Close one once done: sk thread fixed <id> "<what was done>"; or name it on the version: --answers <id>`)
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/** `post <address>` with no media: words that start the address's thread, or a reply in the thread it has */
|
|
663
|
+
async function postWords(h: Here, address: string, title: string, what: string, lane: string | undefined, verdict = false): Promise<number> {
|
|
664
|
+
const { agentName, openThread, readAll, specOf } = await import('../review/store.ts')
|
|
665
|
+
const { threadOfAddress } = await import('../review/threads.ts')
|
|
666
|
+
if (!title.trim() && !what.trim()) throw new Error('--title "<words>" (and --what): with no media, a post is words')
|
|
667
|
+
const t = threadOfAddress(address, readAll(h.dir).items, specOf(h.dir), { up: true })
|
|
668
|
+
if (t) {
|
|
669
|
+
const m = await wordsIn(h.dir, t.head.item.id, lane?.trim() || agentName(), [title.trim(), what.trim()].filter(Boolean).join('\n'), verdict)
|
|
670
|
+
h.out(`${t.head.item.id}: ${m.id}`)
|
|
671
|
+
h.err(`a word in the thread of ${address}${verdict ? ", waiting for the owner's verdict" : ''}`)
|
|
672
|
+
return 0
|
|
673
|
+
}
|
|
674
|
+
const x = await openThread(h.dir, address, { title: title.trim() || what.trim(), ...(what.trim() ? { what } : {}), ...(lane?.trim() ? { lane: lane.trim() } : {}), ...(verdict ? { asksVerdict: true as const } : {}) })
|
|
675
|
+
h.out(x.id)
|
|
676
|
+
h.err(`${address}: the thread starts with these words`)
|
|
677
|
+
return 0
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/** an agent's words in a thread, its image beside them; `verdict`: they wait for the owner's verdict (review/verdict-items.ts) */
|
|
681
|
+
async function wordsIn(dir: string, id: string, who: string, text: string, verdict: boolean, image?: string): Promise<import('../review/model.ts').Message> {
|
|
682
|
+
const { addMessage, appendMessage, readItem } = await import('../review/store.ts')
|
|
683
|
+
if (!verdict) return addMessage(dir, id, who, text, image)
|
|
684
|
+
const { textOf } = await import('../review/model.ts')
|
|
685
|
+
if (!readItem(dir, id)) throw new Error(`no card ${id}`)
|
|
686
|
+
const t = textOf(text)
|
|
687
|
+
if ('error' in t) throw new Error(t.error)
|
|
688
|
+
return appendMessage(dir, id, { who, text: t.text, asksVerdict: true }, image !== undefined ? { image } : {})
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/** `--verdict` on a posting verb: it waits for the owner's verdict (wiki tools/shipkit/threads-how-it-fits.md, The model) */
|
|
692
|
+
const VERDICT_FLAG = "it waits for the owner's verdict (approve, fix, reject on it in the hub, « judge » in the inbox): a thing made that the owner approves before it ships or lands; a choice of what to do is a question, a visible change a version, never on a progress line"
|
|
693
|
+
|
|
420
694
|
export class ReviewAddViewCommand extends Command {
|
|
421
695
|
static override paths = [['review', 'add-view']]
|
|
422
696
|
static essential = {}
|
|
423
697
|
static override usage = Command.Usage({
|
|
424
698
|
category: 'Review',
|
|
425
|
-
description: 'another angle on a
|
|
699
|
+
description: 'another angle on a version he has not answered yet: an image, a pair, a clip or a gallery',
|
|
426
700
|
details: `${DETAILS}\n\nsk ${ADD_VIEW_USAGE}. The view flags are add's; the id may be its moment alone (<YYYYMMDD-HHMMSS>).`,
|
|
427
701
|
examples: [
|
|
428
|
-
['a view from above', 'sk
|
|
429
|
-
['a before and after', 'sk
|
|
702
|
+
['a view from above', 'sk thread add-view <id> "from above" top.png'],
|
|
703
|
+
['a before and after', 'sk thread add-view <id> --label "on a phone" --before a.png --after b.png'],
|
|
430
704
|
],
|
|
431
705
|
})
|
|
432
706
|
args = Option.Proxy()
|
|
@@ -437,13 +711,14 @@ export class ReviewAddViewCommand extends Command {
|
|
|
437
711
|
}
|
|
438
712
|
return run(this.context, async (h) => {
|
|
439
713
|
const { addView } = await import('../review/store.ts')
|
|
440
|
-
const
|
|
714
|
+
const keep = this.args.includes('--keep')
|
|
715
|
+
const a = await addViewArgs(this.args.filter((x) => x !== '--keep'), Object.keys(h.unit?.flags ?? {}))
|
|
441
716
|
const v = a.view
|
|
442
717
|
const id = await idOf(h.dir, a.id)
|
|
443
718
|
const extra = h.unit?.addView ? await h.unit.addView(v, a.repoFlags) : {}
|
|
444
|
-
const item = await addView(h.dir, id, v, extra)
|
|
445
|
-
const {
|
|
446
|
-
h.out(`${id}: view ${
|
|
719
|
+
const item = await addView(h.dir, id, v, { ...extra, ...(keep ? { keep: true } : {}) })
|
|
720
|
+
const { viewNo } = await import('../review/model.ts')
|
|
721
|
+
h.out(`${id}: view ${viewNo(item.views.length - 1)} "${v.label}" added`)
|
|
447
722
|
for (const line of await (await import('../review/previews.ts')).playCopies(h.dir, item, item.views.length - 1)) h.err(line)
|
|
448
723
|
return 0
|
|
449
724
|
})
|
|
@@ -454,9 +729,9 @@ export class ReviewLsCommand extends Command {
|
|
|
454
729
|
static override paths = [['review'], ['review', 'ls']]
|
|
455
730
|
static override usage = Command.Usage({
|
|
456
731
|
category: 'Review',
|
|
457
|
-
description: "the store's active threads, one line each: status, id, title; `sk
|
|
458
|
-
details: `${DETAILS}\n\nsk
|
|
459
|
-
examples: [['what is open', 'sk
|
|
732
|
+
description: "the store's active threads, one line each: status, id, title; `sk thread <verb>` runs a unit's verb",
|
|
733
|
+
details: `${DETAILS}\n\nsk thread [--all] lists; sk thread <verb> … runs a verb the repo's review unit declares (verbs: {...}).`,
|
|
734
|
+
examples: [['what is open', 'sk thread ls'], ['every thread', 'sk thread ls --all']],
|
|
460
735
|
})
|
|
461
736
|
args = Option.Proxy()
|
|
462
737
|
|
|
@@ -475,14 +750,14 @@ export class ReviewLsCommand extends Command {
|
|
|
475
750
|
const { typoOf } = await import('./family-help.ts')
|
|
476
751
|
const own = this.cli.definitions().map((d) => d.path.split(' ')).filter((w) => w[1] === 'review' && w.length === 3).map((w) => w[2]!)
|
|
477
752
|
const close = typoOf(verb, [...own, ...Object.keys(verbs)], 2)
|
|
478
|
-
throw new Error(`no verb « ${verb} »: ${close.length > 0 ? `did you mean ${close.map((c) => `sk
|
|
753
|
+
throw new Error(`no verb « ${verb} »: ${close.length > 0 ? `did you mean ${close.map((c) => `sk thread ${c}`).join(', ')} ? ` : ''}sk thread --help lists sk's own; the repo's unit declares ${Object.keys(verbs).join(', ') || 'none'}`)
|
|
479
754
|
}
|
|
480
755
|
const { dirname } = await import('node:path')
|
|
481
756
|
return v.run(rest, { dir: h.dir, root: dirname(dirname(h.dir)), say: h.out, err: h.err })
|
|
482
757
|
})
|
|
483
758
|
const every = rest.length === 0 && verb === '--all'
|
|
484
759
|
if (verb !== undefined && !every) {
|
|
485
|
-
this.context.stderr.write(`FAIL: review: unexpected ${this.args.join(' ')} (sk
|
|
760
|
+
this.context.stderr.write(`FAIL: review: unexpected ${this.args.join(' ')} (sk thread --help)\n`)
|
|
486
761
|
return 1
|
|
487
762
|
}
|
|
488
763
|
// the listing reads no unit: it stays the fast answer, and the unit's refusals show in inbox and the hub
|
|
@@ -495,7 +770,11 @@ export class ReviewLsCommand extends Command {
|
|
|
495
770
|
for (const b of all.broken) h.err(`review: FAIL ${b.id}: ${b.error}`)
|
|
496
771
|
const threads = orderedThreads(all.items).filter((t) => every || isActive(t))
|
|
497
772
|
if (threads.length === 0) h.out(every ? 'review: the store is empty' : 'review: nothing active (--all shows every thread)')
|
|
498
|
-
|
|
773
|
+
const { ownAddressesOf, threadTitle } = await import('../review/threads.ts')
|
|
774
|
+
for (const t of threads) {
|
|
775
|
+
const at = ownAddressesOf(t)[0]
|
|
776
|
+
h.out(`${statusOf(t.head, all.items).padEnd(17)} ${t.head.item.id} ${threadTitle(t)}${t.versions.length > 1 ? ` (v${t.versions.length})` : ''}${at ? ` ${at}` : ''}`)
|
|
777
|
+
}
|
|
499
778
|
return all.broken.length > 0 ? 1 : 0
|
|
500
779
|
},
|
|
501
780
|
{ unit: false },
|
|
@@ -505,14 +784,14 @@ export class ReviewLsCommand extends Command {
|
|
|
505
784
|
|
|
506
785
|
export class ReviewShowCommand extends Command {
|
|
507
786
|
static override paths = [['review', 'show']]
|
|
508
|
-
static essential = { args: '<id>' }
|
|
787
|
+
static essential = { args: '<address | id>' }
|
|
509
788
|
static override usage = Command.Usage({
|
|
510
789
|
category: 'Review',
|
|
511
790
|
description: 'one item and its thread: the verdict, rectangles, reactions, the whole conversation',
|
|
512
|
-
details: `${DETAILS}\n\nTakes an item id or a player report's ref (live#3). --paste prints the short block that hands the
|
|
513
|
-
examples: [['hand a
|
|
791
|
+
details: `${DETAILS}\n\nTakes an item id or a player report's ref (live#3). --paste prints the short block that hands the thread to another agent session (the hub's copy button gives the same).`,
|
|
792
|
+
examples: [['hand a thread to another session', 'sk thread show <id> --paste']],
|
|
514
793
|
})
|
|
515
|
-
id = Option.String()
|
|
794
|
+
id = Option.String({ name: 'address | id' })
|
|
516
795
|
paste = Option.Boolean('--paste', false, { description: 'the block another agent session acts on: title, repo, this command, the links' })
|
|
517
796
|
|
|
518
797
|
async execute(): Promise<number> {
|
|
@@ -561,104 +840,202 @@ export class ReviewInboxCommand extends Command {
|
|
|
561
840
|
category: 'Review',
|
|
562
841
|
description: 'every answer not marked seen and every open item he raised, frame notes included',
|
|
563
842
|
details: DETAILS,
|
|
564
|
-
examples: [['what waits on you', 'sk
|
|
843
|
+
examples: [['what waits on you', 'sk thread inbox'], ['his notes on trailer frames', 'sk thread inbox --subject frame'], ['the threads this session holds', 'sk thread inbox --mine'], ['as a Claude Code hook, on UserPromptSubmit and on Stop', 'sk thread inbox --hook']],
|
|
565
844
|
})
|
|
566
|
-
mine = Option.Boolean('--mine', false, { description: "only this Claude Code session
|
|
567
|
-
session = Option.String('--session', { description: "only that session
|
|
845
|
+
mine = Option.Boolean('--mine', false, { description: "only the threads this Claude Code session holds" })
|
|
846
|
+
session = Option.String('--session', { description: "only the threads that session holds" })
|
|
568
847
|
subject = Option.String('--subject', { description: 'only items of this subject kind (frame, shot…)' })
|
|
569
848
|
all = Option.Boolean('--all', false, { description: 'a plain approval too, not only the counted line' })
|
|
570
849
|
hook = Option.Boolean('--hook', false, { description: 'run as a Claude Code hook (UserPromptSubmit, Stop): the hook input on stdin, its json answer on stdout. The unseen answers join a prompt as context, and a turn does not end while one is unseen' })
|
|
571
850
|
|
|
572
851
|
async execute(): Promise<number> {
|
|
573
|
-
const {
|
|
852
|
+
const { hookPasses, hookSession, parseHookInput } = await import('../review/inbox-hook.ts')
|
|
574
853
|
// the hook input is one small json on stdin; a terminal has none
|
|
575
854
|
const input = this.hook ? parseHookInput(process.stdin.isTTY === true ? '' : await new Response(Bun.stdin.stream()).text().catch(() => '')) : null
|
|
576
855
|
if (input != null && hookPasses(input)) return 0
|
|
577
|
-
return run(this.context, async (
|
|
578
|
-
|
|
579
|
-
const unseenLines: string[] = []
|
|
580
|
-
const h = input == null ? hh : { ...hh, out: (l: string) => void unseenLines.push(l) }
|
|
581
|
-
const { liveWatchers } = await import('../review/watchers.ts')
|
|
582
|
-
const { readAll } = await import('../review/store.ts')
|
|
583
|
-
const { BUILTIN_KINDS, coversCard, moveOf, stateOf, unreadBy, untakenOf, verdictOf } = await import('../review/model.ts')
|
|
584
|
-
const { followedIds, threadOfItem, threadsOf, unseen } = await import('../review/threads.ts')
|
|
585
|
-
const { detail, threadDetail, untakenLine } = await import('../review/format.ts')
|
|
856
|
+
return run(this.context, async (h) => {
|
|
857
|
+
const { BUILTIN_KINDS, untakenOf } = await import('../review/model.ts')
|
|
586
858
|
const kinds = [...Object.keys(h.say.spec.kinds), ...Object.keys(BUILTIN_KINDS)]
|
|
587
859
|
if (this.subject !== undefined && Object.keys(h.say.spec.kinds).length > 0 && !kinds.includes(this.subject)) throw new Error(`--subject: one of ${kinds.join(', ')}`)
|
|
588
|
-
const
|
|
860
|
+
const { selectInbox, selectedText, hookReply } = await import('../review/inbox-read.ts')
|
|
861
|
+
const { followedIds, hears, listenersOf, sinceHeLeft, threadByItem, threadsOf } = await import('../review/threads.ts')
|
|
862
|
+
const { untakenLine } = await import('../review/format.ts')
|
|
863
|
+
const { liveWatchers } = await import('../review/watchers.ts')
|
|
589
864
|
await pull(h)
|
|
590
|
-
const
|
|
591
|
-
for (const b of
|
|
592
|
-
const of = (x: (typeof all.items)[number]): boolean => coversCard({ session, lane: null }, x) && (this.subject === undefined || x.item.subject.kind === this.subject)
|
|
593
|
-
const news = unseen(all.items).filter(of)
|
|
594
|
-
const followed = followedIds(all.items)
|
|
595
|
-
// what he or a player raised and nobody closed is the agents' move, read or not
|
|
596
|
-
const open = all.items.filter((x) => of(x) && x.item.origin.by !== 'agent' && moveOf(stateOf(x, followed.has(x.item.id)).state) === 'agents' && !news.includes(x))
|
|
597
|
-
// a plain approval (no comment, no rectangle, no reaction, no pick, no reply) asks for no work: counted on one
|
|
598
|
-
// line unless --all
|
|
599
|
-
const plain = (x: (typeof news)[number]): boolean => {
|
|
600
|
-
const v = verdictOf(x)
|
|
601
|
-
return v?.status === 'approved' && !v.seen && !v.comment && v.rects.length === 0 && !v.reactions && v.pick === undefined && unreadBy(x, 'agent').length === 0
|
|
602
|
-
}
|
|
603
|
-
// as a hook: a raised item a lane claimed is in that lane's hands until it closes it, so it never blocks a turn
|
|
604
|
-
const inHand = (x: (typeof news)[number]): boolean => input != null && x.item.origin.by !== 'agent' && stateOf(x, followed.has(x.item.id)).state === 'claimed'
|
|
605
|
-
const shown = [...(this.all ? news : news.filter((x) => !plain(x))), ...open].filter((x) => !inHand(x))
|
|
606
|
-
if (shown.length === 0 && news.length === 0) h.out('review: no unseen feedback or reply')
|
|
607
|
-
const threads = threadsOf(all.items)
|
|
608
|
-
const printed = new Set<string>()
|
|
609
|
-
for (const x of shown) {
|
|
610
|
-
const t = threadOfItem(x.item.id, threads)
|
|
611
|
-
if (t && printed.has(t.head.item.id)) continue
|
|
612
|
-
if (t) printed.add(t.head.item.id)
|
|
613
|
-
h.out(`${t ? threadDetail(t, h.dir, false, h.say) : detail(x, h.dir, false, false, h.say)}\n`)
|
|
614
|
-
}
|
|
615
|
-
// a « fix » or a « no » an agent read and has not done: owed, never an unseen answer again
|
|
616
|
-
const owed = threads.filter((t) => of(t.head) && !printed.has(t.head.item.id) && t.head.item.origin.by === 'agent' && verdictOf(t.head)?.seen === true && stateOf(t.head, false).state === 'claimed')
|
|
617
|
-
const owedLine = (x: (typeof all.items)[number]): string => {
|
|
618
|
-
const fix = verdictOf(x)?.status === 'approved-with-fix'
|
|
619
|
-
const close = fix ? `sk review done ${x.item.id} "<what changed>"` : `--supersedes ${x.item.id} on its new version`
|
|
620
|
-
return ` ${x.item.id} ${fix ? 'ok with a fix' : 'rejected'} "${x.item.title}": ${close}, or sk review wontfix ${x.item.id} --note "<why>"`
|
|
621
|
-
}
|
|
865
|
+
const here = await hereStore(h)
|
|
866
|
+
for (const b of here.broken) h.err(`review: FAIL ${b.id}: ${b.error}`)
|
|
622
867
|
if (input != null) {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
const
|
|
626
|
-
|
|
627
|
-
|
|
868
|
+
// as a hook: what this session hears, in its own repo and in every store it or its lanes wrote in
|
|
869
|
+
const session = hookSession(input)
|
|
870
|
+
const { noteHanded, noteSession } = await import('../agent-time/registry.ts')
|
|
871
|
+
if (session !== null) noteSession(h.dir)
|
|
872
|
+
const stores = [here, ...(session === null ? [] : await storesOf(session, h.dir))]
|
|
873
|
+
const parties = await partiesFor(stores, session)
|
|
874
|
+
const me = { lane: null, session }
|
|
875
|
+
const answer = hookReply({ input, me, stores, parties, onHanded: noteHanded })
|
|
876
|
+
if (answer != null) h.out(answer)
|
|
628
877
|
return 0
|
|
629
878
|
}
|
|
630
|
-
|
|
879
|
+
const session = await sessionOf(this.mine, this.session)
|
|
880
|
+
const lane = this.mine ? laneOfCaller(undefined) : null
|
|
881
|
+
const parties = session === null && lane === null ? null : await partiesFor([here], session)
|
|
882
|
+
const since = sinceHeLeft(here.items)
|
|
883
|
+
if (since && since.moved > 0) h.out(`since you left (${since.at}): ${since.moved} moved, ${since.yours} yours\n`)
|
|
884
|
+
// his requests for a lane first: the orchestrator's (review/lane-ask.ts)
|
|
885
|
+
const { laneAsksFor } = await import('../review/inbox-read.ts')
|
|
886
|
+
for (const l of laneAsksFor(here, { session, lane }, parties ?? { sessions: [], lanes: [] })) h.out(`${l}\n`)
|
|
887
|
+
const sel = selectInbox(here, (x, byItem) => hears({ session, lane }, x, byItem, parties), { all: this.all, subject: this.subject })
|
|
888
|
+
if (sel.threads.length === 0 && sel.news.length === 0) h.out('review: no unseen feedback or reply')
|
|
889
|
+
for (const g of sel.threads) h.out(`${selectedText(here, g)}\n`)
|
|
890
|
+
const { ownAddressOf, verdictOf } = await import('../review/model.ts')
|
|
891
|
+
const owedLine = (t: (typeof sel.owed)[number]): string => {
|
|
892
|
+
const x = t.head
|
|
893
|
+
const fix = verdictOf(x)?.status === 'approved-with-fix'
|
|
894
|
+
const close = fix ? `sk thread fixed ${x.item.id} "<what changed>"` : `its next version, sk thread post ${ownAddressOf(x.item, h.say.spec) ?? x.item.id} …`
|
|
895
|
+
return ` ${x.item.id} ${fix ? 'ok with a fix' : 'rejected'} "${x.item.title}": ${close}, or sk thread wontfix ${x.item.id} --note "<why>"`
|
|
896
|
+
}
|
|
897
|
+
if (sel.owed.length > 0) h.out(`owed, read and not done:\n${sel.owed.map(owedLine).join('\n')}\n`)
|
|
631
898
|
const watchers = liveWatchers(h.dir)
|
|
632
|
-
const
|
|
633
|
-
|
|
899
|
+
const byItem = threadByItem(threadsOf(here.items, h.say.spec))
|
|
900
|
+
const followed = followedIds(here.items)
|
|
901
|
+
const untaken = here.items.flatMap((x) => {
|
|
902
|
+
const why = untakenOf(x, followed.has(x.item.id), listenersOf(watchers, x, byItem).length > 0, new Date(), h.say.spec.dispatcher)
|
|
634
903
|
return why === null ? [] : [untakenLine(x, why, null)]
|
|
635
904
|
})
|
|
636
905
|
if (untaken.length > 0) h.out(`not taken:\n${untaken.join('\n')}\n`)
|
|
637
|
-
|
|
638
|
-
if (
|
|
639
|
-
|
|
640
|
-
return all.broken.length > 0 ? 1 : 0
|
|
906
|
+
if (sel.plain.length > 0) h.out(`review: ${sel.plain.length} plain approval(s), nothing to do: sk thread seen ${sel.plain.map((x) => x.item.id).join(' ')}`)
|
|
907
|
+
if (sel.threads.length > 0) h.out('mark each handled: sk thread seen <id>; close a raised one: sk thread fixed <id> --note "<what was done>"')
|
|
908
|
+
return here.broken.length > 0 ? 1 : 0
|
|
641
909
|
})
|
|
642
910
|
}
|
|
643
911
|
}
|
|
644
912
|
|
|
913
|
+
/** the store the verb stands in, read for the inbox */
|
|
914
|
+
async function hereStore(h: Here): Promise<import('../review/inbox-read.ts').StoreRead> {
|
|
915
|
+
const { readAll } = await import('../review/store.ts')
|
|
916
|
+
const { repoNameOf } = await import('../agent-time/registry.ts')
|
|
917
|
+
const { dirname } = await import('node:path')
|
|
918
|
+
const root = dirname(dirname(h.dir))
|
|
919
|
+
return { repo: repoNameOf(root), root, dir: h.dir, here: true, ...readAll(h.dir), say: h.say }
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
/** every other store this session or its lanes wrote in (agent-time/registry.ts), each with its repo's unit bound */
|
|
923
|
+
async function storesOf(session: string, hereDir: string): Promise<import('../review/inbox-read.ts').StoreRead[]> {
|
|
924
|
+
const { forgetStores, readSessionRecords, repoNameOf } = await import('../agent-time/registry.ts')
|
|
925
|
+
const { existsSync } = await import('node:fs')
|
|
926
|
+
const { dirname, resolve } = await import('node:path')
|
|
927
|
+
const dirs: string[] = []
|
|
928
|
+
const gone: string[] = []
|
|
929
|
+
// only a store its commands run in: `sk thread seen` there refuses a folder that is no shipkit repo
|
|
930
|
+
for (const d of (readSessionRecords().find((r) => r.session === session)?.stores ?? []).filter((x) => resolve(x) !== resolve(hereDir)))
|
|
931
|
+
(existsSync(d) && (await reviewRoot(dirname(dirname(d)))) !== null ? dirs : gone).push(d)
|
|
932
|
+
forgetStores(session, gone)
|
|
933
|
+
const out: import('../review/inbox-read.ts').StoreRead[] = []
|
|
934
|
+
for (const dir of dirs) {
|
|
935
|
+
const root = dirname(dirname(dir))
|
|
936
|
+
try {
|
|
937
|
+
const { openReview, factLines } = await import('../review/project.ts')
|
|
938
|
+
const { readAll, specOf } = await import('../review/store.ts')
|
|
939
|
+
const { unit } = await openReview(root)
|
|
940
|
+
out.push({ repo: repoNameOf(root), root, dir, here: false, ...readAll(dir), say: { spec: specOf(dir), more: (x) => factLines(unit, x) } })
|
|
941
|
+
} catch {
|
|
942
|
+
// a store that does not read now: its own repo's hook and inbox say why
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return out
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/** the parties these stores' threads name: their holders' sessions and the caller's, with each store's live watches */
|
|
949
|
+
async function partiesFor(stores: readonly import('../review/inbox-read.ts').StoreRead[], self: string | null): Promise<import('../review/parties.ts').Parties> {
|
|
950
|
+
const { readParties } = await import('../agent-time/registry.ts')
|
|
951
|
+
const { holderOf, threadsOf } = await import('../review/threads.ts')
|
|
952
|
+
const { liveWatchers } = await import('../review/watchers.ts')
|
|
953
|
+
const ids = new Set<string>()
|
|
954
|
+
for (const s of stores) for (const t of threadsOf(s.items, s.say.spec)) {
|
|
955
|
+
const hs = holderOf(t)?.session
|
|
956
|
+
if (hs) ids.add(hs)
|
|
957
|
+
}
|
|
958
|
+
return readParties({ sessions: [...ids], watchers: stores.flatMap((s) => liveWatchers(s.dir)), self })
|
|
959
|
+
}
|
|
960
|
+
|
|
645
961
|
/** the lane that acts on a reply or a seen: --as, else SK_AGENT, else none */
|
|
646
962
|
const laneOfCaller = (as: string | undefined): string | null => as?.trim() || process.env.SK_AGENT?.trim() || null
|
|
647
963
|
|
|
648
|
-
/** why the caller may not
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
const {
|
|
964
|
+
/** why the caller may not mark his answer on this item seen (review/threads.ts seenRefusal, rule 4: the holder or its
|
|
965
|
+
* session), null when it may */
|
|
966
|
+
async function seenRefused(dir: string, id: string, as: string | undefined): Promise<string | null> {
|
|
967
|
+
const { readAll } = await import('../review/store.ts')
|
|
968
|
+
const { seenRefusal, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
969
|
+
const items = readAll(dir).items
|
|
970
|
+
const x = items.find((y) => y.item.id === id)
|
|
971
|
+
if (x === undefined) return null
|
|
972
|
+
const t = threadOfItem(id, threadsOf(items))
|
|
973
|
+
const { me, parties } = await callerParties(dir, t, as)
|
|
974
|
+
return seenRefusal(x, t, me, parties)
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
/** the caller and the parties its thread's holder names */
|
|
978
|
+
async function callerParties(dir: string, t: import('../review/threads.ts').Thread | null, as: string | undefined): Promise<{ me: import('../review/parties.ts').Me; parties: import('../review/parties.ts').Parties }> {
|
|
979
|
+
const { sessionId } = await import('../review/store.ts')
|
|
980
|
+
const { holderOf } = await import('../review/threads.ts')
|
|
981
|
+
const { readParties } = await import('../agent-time/registry.ts')
|
|
652
982
|
const { liveWatchers } = await import('../review/watchers.ts')
|
|
653
|
-
const
|
|
654
|
-
|
|
983
|
+
const me = { lane: laneOfCaller(as), session: sessionId() }
|
|
984
|
+
const hs = t ? holderOf(t)?.session : undefined
|
|
985
|
+
return { me, parties: await readParties({ sessions: hs ? [hs] : [], watchers: liveWatchers(dir), self: me.session }) }
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/** the caller holds the item's thread, or is the session of the lane that does (rule 4, review/parties.ts maySee): it
|
|
989
|
+
* may close what that lane claimed, as itself */
|
|
990
|
+
async function callerHolds(dir: string, id: string, as: string | undefined): Promise<boolean> {
|
|
991
|
+
const { readAll } = await import('../review/store.ts')
|
|
992
|
+
const { holderOf, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
993
|
+
const { maySee } = await import('../review/parties.ts')
|
|
994
|
+
const t = threadOfItem(id, threadsOf(readAll(dir).items))
|
|
995
|
+
if (t === null) return false
|
|
996
|
+
const h = holderOf(t)
|
|
997
|
+
if (h === null) return false
|
|
998
|
+
const { me, parties } = await callerParties(dir, t, as)
|
|
999
|
+
return maySee(me, h, parties)
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
/** `--replaces <object>`: the thread item `id` is in, and the message id the new object supersedes, once the caller may
|
|
1003
|
+
* (review/supersede.ts replaceRefusal: the holder or its session, an agent's object not superseded yet); thrown
|
|
1004
|
+
* before anything is written. A cell id the hub copies (`<item>/<message>`) names its message */
|
|
1005
|
+
async function replacing(dir: string, ref: string, target: string, as: string | undefined): Promise<{ id: string; replaces: string }> {
|
|
1006
|
+
const id = await idOf(dir, ref)
|
|
1007
|
+
const { readAll } = await import('../review/store.ts')
|
|
1008
|
+
const { membersOf, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1009
|
+
const { replaceRefusal } = await import('../review/supersede.ts')
|
|
1010
|
+
const t = threadOfItem(id, threadsOf(readAll(dir).items))
|
|
1011
|
+
if (t === null) throw new Error(`--replaces ${target}: ${id} reads in no thread`)
|
|
1012
|
+
const replaces = target.includes('/') ? target.slice(target.lastIndexOf('/') + 1) : target
|
|
1013
|
+
const no = replaceRefusal(membersOf(t), replaces, { holds: await mayHold(dir, t, as) })
|
|
1014
|
+
if (no !== null) throw new Error(no)
|
|
1015
|
+
return { id, replaces }
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/** the caller may act as the thread's holder: it holds it, or is the session of the lane that does, or nobody holds it */
|
|
1019
|
+
async function mayHold(dir: string, t: import('../review/threads.ts').Thread, as: string | undefined): Promise<boolean> {
|
|
1020
|
+
const { holderOf } = await import('../review/threads.ts')
|
|
1021
|
+
const { maySee } = await import('../review/parties.ts')
|
|
1022
|
+
const { me, parties } = await callerParties(dir, t, as)
|
|
1023
|
+
return maySee(me, holderOf(t), parties)
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
/** mayHold for the thread item `id` is in, false when it reads in none */
|
|
1027
|
+
export async function mayHoldItem(dir: string, id: string, as?: string): Promise<boolean> {
|
|
1028
|
+
const { readAll } = await import('../review/store.ts')
|
|
1029
|
+
const { threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1030
|
+
const t = threadOfItem(id, threadsOf(readAll(dir).items))
|
|
1031
|
+
return t !== null && mayHold(dir, t, as)
|
|
655
1032
|
}
|
|
656
1033
|
|
|
657
1034
|
export class ReviewSeenCommand extends Command {
|
|
658
1035
|
static override paths = [['review', 'seen']]
|
|
659
|
-
static essential = { args: '<ids>' }
|
|
660
|
-
static override usage = Command.Usage({ category: 'Review', description: 'mark his
|
|
661
|
-
ids = Option.Rest({ required: 1 })
|
|
1036
|
+
static essential = { args: '<address | ids>' }
|
|
1037
|
+
static override usage = Command.Usage({ category: 'Review', description: 'mark his new words read as you read them: by id, or a whole thread by its address', details: DETAILS })
|
|
1038
|
+
ids = Option.Rest({ required: 1, name: 'address | id' })
|
|
662
1039
|
as = Option.String('--as', { description: 'the lane that read it (else SK_AGENT)' })
|
|
663
1040
|
|
|
664
1041
|
async execute(): Promise<number> {
|
|
@@ -666,8 +1043,23 @@ export class ReviewSeenCommand extends Command {
|
|
|
666
1043
|
const { markSeen } = await import('../review/store.ts')
|
|
667
1044
|
// every id checked before any is marked: his answer on another lane's card stays unread for that lane
|
|
668
1045
|
const ids: [string, string][] = []
|
|
669
|
-
|
|
670
|
-
|
|
1046
|
+
const { ID_RE } = await import('../review/model.ts')
|
|
1047
|
+
for (const ref of this.ids) {
|
|
1048
|
+
// an address: every item of its thread with an answer not marked seen
|
|
1049
|
+
if (!ID_RE.test(ref) && ref.includes(':')) {
|
|
1050
|
+
const { readAll } = await import('../review/store.ts')
|
|
1051
|
+
const { membersOf, threadOfItem, threadsOf, unseen } = await import('../review/threads.ts')
|
|
1052
|
+
const items = readAll(h.dir).items
|
|
1053
|
+
const t = threadOfItem(await idOf(h.dir, ref), threadsOf(items, h.say.spec))
|
|
1054
|
+
const members = new Set(t ? membersOf(t).map((x) => x.item.id) : [])
|
|
1055
|
+
const open = unseen(items).filter((x) => members.has(x.item.id))
|
|
1056
|
+
if (open.length === 0) h.out(`${ref}: nothing of his unseen`)
|
|
1057
|
+
for (const x of open) ids.push([x.item.id, x.item.id])
|
|
1058
|
+
continue
|
|
1059
|
+
}
|
|
1060
|
+
ids.push([ref, await idOf(h.dir, ref).catch(() => ref)])
|
|
1061
|
+
}
|
|
1062
|
+
const refused = (await Promise.all(ids.map(([, id]) => seenRefused(h.dir, id, this.as)))).filter((w) => w !== null)
|
|
671
1063
|
if (refused.length > 0) throw new Error(`nothing marked: ${refused.join('; ')}`)
|
|
672
1064
|
let bad = 0
|
|
673
1065
|
for (const [ref, id] of ids) {
|
|
@@ -682,22 +1074,141 @@ export class ReviewSeenCommand extends Command {
|
|
|
682
1074
|
}
|
|
683
1075
|
}
|
|
684
1076
|
|
|
1077
|
+
/** the longest « what I do now » line: a glance in his thread, never a report */
|
|
1078
|
+
const WORKING_MAX = 200
|
|
1079
|
+
|
|
1080
|
+
export class ThreadWorkingCommand extends Command {
|
|
1081
|
+
static override paths = [['thread', 'working']]
|
|
1082
|
+
static essential = { args: '<address | id> "<what I do now>"' }
|
|
1083
|
+
static override usage = Command.Usage({
|
|
1084
|
+
category: 'Review',
|
|
1085
|
+
description: 'say you are on his new words in a thread, one line of what you do now; your next act there ends it',
|
|
1086
|
+
details: `${DETAILS}\n\nMark his new words seen as you read them (sk thread seen), then, for work longer than your next call, say what you do with them here: he sees « L29 is on it: <line> » in the thread, its head and its row. It ends with the next act in the thread, yours or another agent's (a version, an update, a reply, a question, a change, a close, a take, a newer working), or once nothing moved for 2 h. A read with no act after it keeps his word owed: a turn's end holds on it. Never written for you: no watch, beat or hook says it (wiki tools/shipkit/threads-how-it-fits.md, Read and on it).`,
|
|
1087
|
+
examples: [['on it', 'SK_AGENT=L29 sk thread working page:backup "backing up the key in OpenBao"']],
|
|
1088
|
+
})
|
|
1089
|
+
ref = Option.String({ name: 'address | id' })
|
|
1090
|
+
line = Option.String()
|
|
1091
|
+
as = Option.String('--as', { description: 'the lane on it (else SK_AGENT)' })
|
|
1092
|
+
|
|
1093
|
+
async execute(): Promise<number> {
|
|
1094
|
+
return run(this.context, async (h) => {
|
|
1095
|
+
const line = this.line.trim()
|
|
1096
|
+
if (line === '') throw new Error('say what you do now: sk thread working <address> "<line>"')
|
|
1097
|
+
if (line.length > WORKING_MAX) throw new Error(`one short line: at most ${WORKING_MAX} characters, ${line.length} given`)
|
|
1098
|
+
const { appendMessage, readAll } = await import('../review/store.ts')
|
|
1099
|
+
const { threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1100
|
+
const id = await idOf(h.dir, this.ref)
|
|
1101
|
+
const t = threadOfItem(id, threadsOf(readAll(h.dir).items, h.say.spec))
|
|
1102
|
+
const who = laneOfCaller(this.as) ?? 'agent'
|
|
1103
|
+
appendMessage(h.dir, t?.head.item.id ?? id, { who, op: 'working', note: line })
|
|
1104
|
+
h.out(`${this.ref}: ${who} is on it: ${line} (your next act in this thread ends it)`)
|
|
1105
|
+
return 0
|
|
1106
|
+
})
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
export class ThreadTakeCommand extends Command {
|
|
1111
|
+
static override paths = [['thread', 'take']]
|
|
1112
|
+
static essential = { args: '<address | id>' }
|
|
1113
|
+
static override usage = Command.Usage({
|
|
1114
|
+
category: 'Review',
|
|
1115
|
+
description: 'hold a thread from now on: his answers on it reach you, and you mark them seen',
|
|
1116
|
+
details: `${DETAILS}\n\nWho holds a thread is the agent of its newest act in it; a take is that act with no words, its state left as it is. A thread whose agent ended, or one nobody hears (the inbox hook lists those at a session's prompt), becomes yours. Writing in a thread (reply, update, post) takes it too. A session takes its own ended lane's thread only to keep it when it cannot resume that lane: a resumed lane takes back what it held, and a session marks its lane's thread seen with no take (wiki tools/shipkit/threads-how-it-fits.md, The parties).`,
|
|
1117
|
+
examples: [['a thread its ended session left', 'sk thread take asset:start'], ['as a lane', 'SK_AGENT=L4 sk thread take screen:orders/list']],
|
|
1118
|
+
})
|
|
1119
|
+
ref = Option.String({ name: 'address | id' })
|
|
1120
|
+
as = Option.String('--as', { description: 'the lane that takes it (else SK_AGENT)' })
|
|
1121
|
+
|
|
1122
|
+
async execute(): Promise<number> {
|
|
1123
|
+
return run(this.context, async (h) => {
|
|
1124
|
+
const { appendMessage, readAll } = await import('../review/store.ts')
|
|
1125
|
+
const { holderOf, hearingOfThread, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1126
|
+
const { sessionLabel } = await import('../review/parties.ts')
|
|
1127
|
+
const id = await idOf(h.dir, this.ref)
|
|
1128
|
+
const before = threadOfItem(id, threadsOf(readAll(h.dir).items, h.say.spec))
|
|
1129
|
+
const head = before?.head.item.id ?? id
|
|
1130
|
+
const was = before ? holderOf(before) : null
|
|
1131
|
+
const { dropHanded, readParties, repoNameOf } = await import('../agent-time/registry.ts')
|
|
1132
|
+
const { liveWatchers } = await import('../review/watchers.ts')
|
|
1133
|
+
const { sessionId } = await import('../review/store.ts')
|
|
1134
|
+
const lane = laneOfCaller(this.as)
|
|
1135
|
+
appendMessage(h.dir, head, { who: lane ?? 'agent', op: 'take' })
|
|
1136
|
+
// taken here: the ended lane, resumed later, leaves it to its taker
|
|
1137
|
+
const self = sessionId()
|
|
1138
|
+
if (self) dropHanded(self, h.dir, head, lane)
|
|
1139
|
+
const after = threadOfItem(head, threadsOf(readAll(h.dir).items, h.say.spec))
|
|
1140
|
+
const now = after ? holderOf(after) : null
|
|
1141
|
+
const parties = await readParties({ sessions: [...new Set([was?.session, now?.session].filter((x): x is string => !!x))], watchers: liveWatchers(h.dir), self: sessionId() })
|
|
1142
|
+
const { dirname } = await import('node:path')
|
|
1143
|
+
const hearing = after ? hearingOfThread(after, parties, repoNameOf(dirname(dirname(h.dir)))) : null
|
|
1144
|
+
const wasText = was === null ? 'nobody held it' : `it was held by ${was.lane ?? sessionLabel(was.session, parties)}`
|
|
1145
|
+
h.out(`${this.ref}: yours now (${hearing?.chip ?? lane ?? 'this session'}), ${wasText}; ${hearing?.words ?? ''}`)
|
|
1146
|
+
if (hearing && hearing.light !== 'hears') h.err(`review: no watch of yours hears it now: sk thread watch --mine under a monitor`)
|
|
1147
|
+
return 0
|
|
1148
|
+
})
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
export class ThreadAssignCommand extends Command {
|
|
1153
|
+
static override paths = [['thread', 'assign']]
|
|
1154
|
+
static override usage = Command.Usage({
|
|
1155
|
+
category: 'Review',
|
|
1156
|
+
description: 'give a thread to a lane: it holds it, a trace line names who gave it',
|
|
1157
|
+
details: `${DETAILS}\n\nThe orchestrator's answer to the owner's « start a lane »: on a thread nobody holds, sk thread take it first; then SendMessage to a live lane, or start a sub-agent with the thread as its brief (nothing starts a process for you); then assign the thread to that lane. The lane holds it (a take under its name, the state left as it is), and its trace line reads « L65 took the thread: assigned by app main ». The request clears at the lane's first act there: tell it to say \`sk thread working <address> "…"\` first (wiki tools/shipkit/threads-how-it-fits.md, A lane he asks for).`,
|
|
1158
|
+
examples: [['a lane for the thread he asked one on', 'sk thread assign screen:orders/list L65']],
|
|
1159
|
+
})
|
|
1160
|
+
ref = Option.String({ name: 'address | id' })
|
|
1161
|
+
lane = Option.String()
|
|
1162
|
+
|
|
1163
|
+
async execute(): Promise<number> {
|
|
1164
|
+
return run(this.context, async (h) => {
|
|
1165
|
+
const { AGENT_RE } = await import('../review/model.ts')
|
|
1166
|
+
const lane = this.lane.trim()
|
|
1167
|
+
if (!AGENT_RE.test(lane) || lane === 'agent' || lane === 'owner' || lane === 'player') throw new Error(`« ${lane} » is no lane name: sk thread assign <address> L<n>`)
|
|
1168
|
+
const { appendMessage, readAll, sessionId } = await import('../review/store.ts')
|
|
1169
|
+
const { threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1170
|
+
const { sessionLabel } = await import('../review/parties.ts')
|
|
1171
|
+
const { dropHanded, readParties } = await import('../agent-time/registry.ts')
|
|
1172
|
+
const id = await idOf(h.dir, this.ref)
|
|
1173
|
+
const head = threadOfItem(id, threadsOf(readAll(h.dir).items, h.say.spec))?.head.item.id ?? id
|
|
1174
|
+
const self = sessionId()
|
|
1175
|
+
const by = laneOfCaller(undefined) ?? (self ? sessionLabel(self, await readParties({ sessions: [], self })) : 'a terminal')
|
|
1176
|
+
appendMessage(h.dir, head, { who: lane, op: 'take', note: `assigned by ${by}` })
|
|
1177
|
+
if (self) dropHanded(self, h.dir, head, lane)
|
|
1178
|
+
h.out(`${this.ref}: given to ${lane} (assigned by ${by}): its first act there (sk thread working ${this.ref} "…") clears his request`)
|
|
1179
|
+
return 0
|
|
1180
|
+
})
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
|
|
685
1184
|
export class ReviewReplyCommand extends Command {
|
|
686
1185
|
static override paths = [['review', 'reply']]
|
|
687
|
-
static essential = { args: '<id> <text>' }
|
|
688
|
-
static override usage = Command.Usage({ category: 'Review', description: "your message
|
|
689
|
-
id = Option.String()
|
|
1186
|
+
static essential = { args: '<address | id> <text>' }
|
|
1187
|
+
static override usage = Command.Usage({ category: 'Review', description: "your message in a thread: what you changed, the answer to his question", details: DETAILS })
|
|
1188
|
+
id = Option.String({ name: 'address | id' })
|
|
690
1189
|
text = Option.String()
|
|
691
1190
|
image = Option.String('--image', { description: 'an image beside the words' })
|
|
692
1191
|
as = Option.String('--as', { description: 'the lane that answers (else SK_AGENT)' })
|
|
1192
|
+
urgent = Option.Boolean('--urgent', false, { description: 'brings back a thread he set aside, at once: only under the bar of a ping (an incident, a hard block, a deadline before it comes back)' })
|
|
1193
|
+
replaces = Option.String('--replaces', { description: 'the id of your earlier words (or question, or change) these supersede: it folds to one line « superseded by … » and leaves the dock, its answers kept' })
|
|
1194
|
+
verdict = Option.Boolean('--verdict', false, { description: VERDICT_FLAG })
|
|
693
1195
|
|
|
694
1196
|
async execute(): Promise<number> {
|
|
695
1197
|
return run(this.context, async (h) => {
|
|
696
|
-
const {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
1198
|
+
const { agentName, appendMessage } = await import('../review/store.ts')
|
|
1199
|
+
if (this.replaces !== undefined) {
|
|
1200
|
+
if (this.image !== undefined) throw new Error('--replaces with --image: post the image as its own reply')
|
|
1201
|
+
const { textOf } = await import('../review/model.ts')
|
|
1202
|
+
const r = await replacing(h.dir, this.id, this.replaces, this.as)
|
|
1203
|
+
const t = textOf(this.text)
|
|
1204
|
+
if ('error' in t) throw new Error(t.error)
|
|
1205
|
+
const m = appendMessage(h.dir, r.id, { who: laneOfCaller(this.as) ?? agentName(), text: t.text, replaces: r.replaces, ...(this.verdict ? { asksVerdict: true as const } : {}) })
|
|
1206
|
+
h.out(`${r.id}: ${m.id} supersedes ${r.replaces}`)
|
|
1207
|
+
return 0
|
|
1208
|
+
}
|
|
1209
|
+
const id = await idOrOpen(h, this.id, this.text, this.as)
|
|
1210
|
+
const m = await wordsIn(h.dir, id, laneOfCaller(this.as) ?? agentName(), this.text, this.verdict, this.image)
|
|
1211
|
+
if (this.urgent) await urgentOn(h.dir, id, laneOfCaller(this.as) ?? agentName())
|
|
701
1212
|
h.out(`${id}: ${m.id}`)
|
|
702
1213
|
return 0
|
|
703
1214
|
})
|
|
@@ -706,40 +1217,58 @@ export class ReviewReplyCommand extends Command {
|
|
|
706
1217
|
|
|
707
1218
|
export class ReviewUpdateCommand extends Command {
|
|
708
1219
|
static override paths = [['review', 'update']]
|
|
709
|
-
static essential = { args: '<id>
|
|
1220
|
+
static essential = { args: '<address | id> [state] <text>' }
|
|
710
1221
|
static override usage = Command.Usage({
|
|
711
1222
|
category: 'Review',
|
|
712
|
-
description: "where a
|
|
713
|
-
details: `${DETAILS}\n\nsk
|
|
1223
|
+
description: "where a thread's work stands, no answer needed: broken, better, fixed or a plain line; a file",
|
|
1224
|
+
details: `${DETAILS}\n\nsk thread update <id> <broken|better|fixed> "<one line>" [<file> | <before> <after>]: the file (an image, a clip or a sound, as it is: no special file) becomes the version's next view, the line and the state go on its thread in time order. Two files make that view a before and after pair, as add --before --after does: two images of one size, two clips of one size and length, or two sounds, never one of each; the owner picks how he compares them (side by side, wipe, fade). broken or better holds the version « in progress » (not waiting on the owner's verdict, still new in the list), fixed asks the owner's verdict again on the same thread, even after an answer. The owner's hint on an update reaches watch and inbox as a reply « on update <k> ». Posted on the thread's newest version.`,
|
|
714
1225
|
examples: [
|
|
715
|
-
['still broken, the take as it is', 'SK_AGENT=L2 sk
|
|
716
|
-
['better, not done', 'SK_AGENT=L2 sk
|
|
717
|
-
['fixed: he answers again', 'SK_AGENT=L2 sk
|
|
718
|
-
['better, as a before and after he compares his way', 'SK_AGENT=L2 sk
|
|
1226
|
+
['still broken, the take as it is', 'SK_AGENT=L2 sk thread update <id> broken "her arm still crosses her leg at 2 s" take.mp4'],
|
|
1227
|
+
['better, not done', 'SK_AGENT=L2 sk thread update <id> better "the crossing is gone, the landing still snaps" take.mp4'],
|
|
1228
|
+
['fixed: he answers again', 'SK_AGENT=L2 sk thread update <id> fixed "no crossing, no snap over the whole clip" take.mp4'],
|
|
1229
|
+
['better, as a before and after he compares his way', 'SK_AGENT=L2 sk thread update <id> better "the snap is half as deep" before.mp4 after.mp4'],
|
|
719
1230
|
],
|
|
720
1231
|
})
|
|
721
|
-
id = Option.String()
|
|
1232
|
+
id = Option.String({ name: 'address | id' })
|
|
722
1233
|
state = Option.String()
|
|
723
|
-
|
|
724
|
-
|
|
1234
|
+
// the line and the files are one rest: clipanion never fills an optional positional that a rest follows
|
|
1235
|
+
rest = Option.Rest()
|
|
1236
|
+
get text(): string | undefined {
|
|
1237
|
+
return this.rest[0]
|
|
1238
|
+
}
|
|
1239
|
+
get files(): string[] {
|
|
1240
|
+
return this.rest.slice(1)
|
|
1241
|
+
}
|
|
725
1242
|
as = Option.String('--as', { description: 'the lane that posts (else SK_AGENT)' })
|
|
1243
|
+
keep = Option.Boolean('--keep', false, { description: 'its pictures as given: a png lands as a lossless webp otherwise, its pixels checked exact, and the version keeps only the webp' })
|
|
1244
|
+
verdict = Option.Boolean('--verdict', false, { description: `on a plain line only: ${VERDICT_FLAG}` })
|
|
726
1245
|
|
|
727
1246
|
async execute(): Promise<number> {
|
|
728
1247
|
return run(this.context, async (h) => {
|
|
729
1248
|
const { postUpdate, agentName, readAll } = await import('../review/store.ts')
|
|
730
1249
|
const { threadsOf } = await import('../review/threads.ts')
|
|
731
1250
|
const { threadOfId } = await import('../review/cells.ts')
|
|
732
|
-
const
|
|
1251
|
+
const { UPDATE_STATES } = await import('../review/model.ts')
|
|
1252
|
+
// fixed asks the version's verdict again, broken and better hold it in work: a verdict of their own would be two answers on one cell
|
|
1253
|
+
if (this.verdict && this.text !== undefined) throw new Error(`update ${this.state} --verdict: ${this.state === 'fixed' ? "fixed already asks the owner's verdict on the version" : `${this.state} holds the version in work, its hint box is the owner's answer`}; --verdict goes on a plain line`)
|
|
1254
|
+
// no state: a plain progress line, a reply on the newest version
|
|
1255
|
+
if (this.text === undefined) {
|
|
1256
|
+
if ((UPDATE_STATES as readonly string[]).includes(this.state)) throw new Error(`update <address | id> ${this.state} "<one line>": the line is missing`)
|
|
1257
|
+
const at = await idOrOpen(h, this.id, this.state, this.as)
|
|
1258
|
+
const on = threadOfId(at, threadsOf(readAll(h.dir).items))?.head.item.id ?? at
|
|
1259
|
+
const m = await wordsIn(h.dir, on, laneOfCaller(this.as) ?? agentName(), this.state, this.verdict)
|
|
1260
|
+
h.out(`${on}: ${m.id}, a line, no state`)
|
|
1261
|
+
return 0
|
|
1262
|
+
}
|
|
1263
|
+
const asked = await idOrOpen(h, this.id, this.text, this.as)
|
|
733
1264
|
// an update goes where he reads: the thread's newest version
|
|
734
1265
|
const id = threadOfId(asked, threadsOf(readAll(h.dir).items))?.head.item.id ?? asked
|
|
735
|
-
const
|
|
736
|
-
|
|
737
|
-
const r = await postUpdate(h.dir, id, { who: laneOfCaller(this.as) ?? agentName(), state: this.state, text: this.text, files: this.files })
|
|
738
|
-
const { viewLetter, stateOf } = await import('../review/model.ts')
|
|
1266
|
+
const r = await postUpdate(h.dir, id, { who: laneOfCaller(this.as) ?? agentName(), state: this.state, text: this.text, files: this.files, ...(this.keep ? { keep: true } : {}) })
|
|
1267
|
+
const { viewNo, stateOf } = await import('../review/model.ts')
|
|
739
1268
|
const { readItem } = await import('../review/store.ts')
|
|
740
1269
|
const x = readItem(h.dir, id)
|
|
741
1270
|
const now = x && stateOf(x, false).state === 'asks' ? "waits for the owner's verdict" : x && stateOf(x, false).state === 'draft' ? 'in progress, no verdict asked' : 'in work'
|
|
742
|
-
h.out(`${id}: ${r.tag}${r.view !== null ? `, view ${
|
|
1271
|
+
h.out(`${id}: ${r.tag}${r.view !== null ? `, view ${viewNo(r.view)}` : ''}${id !== asked ? ` (on the newest version, ${asked} is older)` : ''}; the version ${now}`)
|
|
743
1272
|
if (r.view !== null) for (const line of await (await import('../review/previews.ts')).playCopies(h.dir, r.item, r.view)) h.err(line)
|
|
744
1273
|
const { unheardLine } = await import('../review/model.ts')
|
|
745
1274
|
const { liveWatchers } = await import('../review/watchers.ts')
|
|
@@ -752,18 +1281,37 @@ export class ReviewUpdateCommand extends Command {
|
|
|
752
1281
|
|
|
753
1282
|
export class ReviewWithdrawCommand extends Command {
|
|
754
1283
|
static override paths = [['review', 'withdraw']]
|
|
755
|
-
static override usage = Command.Usage({
|
|
1284
|
+
static override usage = Command.Usage({
|
|
1285
|
+
category: 'Review',
|
|
1286
|
+
description: 'take back an unanswered version, or one open question or change by its message id, with the reason',
|
|
1287
|
+
details: `${DETAILS}\n\nA version (or a thread's card) withdrawn asks nothing more: its open questions and changes wait on nobody with it. A message id (sk thread show prints them) takes back that one question or change alone. --chat "<the owner's words>": the owner answered it in chat; the words are the reason, quoted, so it never stays open in the hub.`,
|
|
1288
|
+
examples: [
|
|
1289
|
+
['a version taken back', 'sk thread withdraw 20261120-101500-the-logo --why "a newer one follows"'],
|
|
1290
|
+
['he answered the question in chat', 'sk thread withdraw 20261120-223154-747-agent-vg49 --chat "B only, keep both kill matrices"'],
|
|
1291
|
+
],
|
|
1292
|
+
})
|
|
756
1293
|
ids = Option.Rest({ required: 1 })
|
|
757
|
-
why = Option.String('--why,--note', { required:
|
|
1294
|
+
why = Option.String('--why,--note', { required: false, description: 'why it goes (--note says the same, as on fixed, wontfix, blocked and drop)' })
|
|
1295
|
+
chat = Option.String('--chat', { required: false, description: 'the owner answered it in chat: the words become the reason, quoted' })
|
|
758
1296
|
|
|
759
1297
|
async execute(): Promise<number> {
|
|
760
1298
|
return run(this.context, async (h) => {
|
|
761
|
-
const { withdraw } = await import('../review/store.ts')
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
|
|
1299
|
+
const { answeredInChat, withdraw, withdrawObject } = await import('../review/store.ts')
|
|
1300
|
+
const { MESSAGE_RE } = await import('../review/model.ts')
|
|
1301
|
+
const why = this.chat?.trim() ? answeredInChat(this.chat) : this.why?.trim()
|
|
1302
|
+
if (!why) throw new Error('--why "<why it goes>", or --chat "<the owner\'s words>" when the owner answered it in chat')
|
|
1303
|
+
for (const ref of this.ids) {
|
|
1304
|
+
const msg = ref.includes('/') ? ref.slice(ref.indexOf('/') + 1) : ref
|
|
1305
|
+
if (MESSAGE_RE.test(msg)) {
|
|
1306
|
+
const r = withdrawObject(h.dir, msg, why)
|
|
1307
|
+
if ('refused' in r) throw new Error(r.refused)
|
|
1308
|
+
h.out(`${msg}: withdrawn (${why}); it waits on nobody now`)
|
|
1309
|
+
continue
|
|
1310
|
+
}
|
|
1311
|
+
const id = await idOf(h.dir, ref)
|
|
1312
|
+
const r = withdraw(h.dir, id, why)
|
|
765
1313
|
if ('refused' in r) throw new Error(r.refused)
|
|
766
|
-
h.out(r.already ? `${id}: withdrawn already (${r.already}), nothing to do` : `${id}: withdrawn`)
|
|
1314
|
+
h.out(r.already ? `${id}: withdrawn already (${r.already}), nothing to do` : `${id}: withdrawn, its open questions and changes with it`)
|
|
767
1315
|
}
|
|
768
1316
|
return 0
|
|
769
1317
|
})
|
|
@@ -772,7 +1320,7 @@ export class ReviewWithdrawCommand extends Command {
|
|
|
772
1320
|
|
|
773
1321
|
export class ReviewReopenCommand extends Command {
|
|
774
1322
|
static override paths = [['review', 'reopen']]
|
|
775
|
-
static override usage = Command.Usage({ category: 'Review', description: 'an answered
|
|
1323
|
+
static override usage = Command.Usage({ category: 'Review', description: 'an answered version waits for his answer again; the old verdict stays in the thread', details: DETAILS })
|
|
776
1324
|
ids = Option.Rest({ required: 1 })
|
|
777
1325
|
|
|
778
1326
|
async execute(): Promise<number> {
|
|
@@ -783,7 +1331,7 @@ export class ReviewReopenCommand extends Command {
|
|
|
783
1331
|
for (const ref of this.ids) {
|
|
784
1332
|
const id = await idOf(h.dir, ref)
|
|
785
1333
|
const v = reopen(h.dir, id)
|
|
786
|
-
if (!v) throw new Error(`${id}: no such
|
|
1334
|
+
if (!v) throw new Error(`${id}: no such version, or no answer to reopen`)
|
|
787
1335
|
await followAnswer(dirname(dirname(h.dir)), id, v.status)
|
|
788
1336
|
}
|
|
789
1337
|
h.out(`review: ${this.ids.length} reopened`)
|
|
@@ -794,11 +1342,13 @@ export class ReviewReopenCommand extends Command {
|
|
|
794
1342
|
|
|
795
1343
|
export class ReviewPickCommand extends Command {
|
|
796
1344
|
static override paths = [['review', 'pick']]
|
|
1345
|
+
/** for an older choice version: a question's pick is fixed when it is asked */
|
|
1346
|
+
static older = true
|
|
797
1347
|
static override usage = Command.Usage({
|
|
798
1348
|
category: 'Review',
|
|
799
|
-
description: "the option you suggest on a choice
|
|
800
|
-
details: `${DETAILS}\n\nsk
|
|
801
|
-
examples: [['suggest the second option', 'sk
|
|
1349
|
+
description: "the option you suggest on a choice he has not answered: the hub's « my pick » pill on it",
|
|
1350
|
+
details: `${DETAILS}\n\nsk thread pick <id> <view>: the view by its letter (B) or its label; one pick a version, a new one replaces it; for an older choice version (a question's pick is fixed at ask).`,
|
|
1351
|
+
examples: [['suggest the second option', 'sk thread pick <id> B'], ['by its label', 'sk thread pick <id> "Zen Garden"']],
|
|
802
1352
|
})
|
|
803
1353
|
id = Option.String({ required: true })
|
|
804
1354
|
view = Option.String({ required: true })
|
|
@@ -806,11 +1356,11 @@ export class ReviewPickCommand extends Command {
|
|
|
806
1356
|
async execute(): Promise<number> {
|
|
807
1357
|
return run(this.context, async (h) => {
|
|
808
1358
|
const { setAgentPick } = await import('../review/store.ts')
|
|
809
|
-
const {
|
|
1359
|
+
const { viewNo, viewName } = await import('../review/model.ts')
|
|
810
1360
|
const id = await idOf(h.dir, this.id)
|
|
811
1361
|
const item = setAgentPick(h.dir, id, this.view)
|
|
812
1362
|
const n = item.agentPick ?? 0
|
|
813
|
-
h.out(`${id}: my pick ${
|
|
1363
|
+
h.out(`${id}: my pick ${viewNo(n)} "${viewName(item.views[n], n)}"`)
|
|
814
1364
|
return 0
|
|
815
1365
|
})
|
|
816
1366
|
}
|
|
@@ -822,24 +1372,111 @@ type ActOp = 'fixed' | 'wontfix' | 'claim' | 'release' | 'blocked' | 'done' | 'd
|
|
|
822
1372
|
function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'optional'; text?: string; topic?: 'required' | 'optional'; named: boolean; examples: [string, string][] }) {
|
|
823
1373
|
return class extends Command {
|
|
824
1374
|
static override paths = [['review', op]]
|
|
825
|
-
static essential = op === '
|
|
1375
|
+
static essential = op === 'ask' ? { args: '<address | id> "<question>" --option … --pick <n>' } : undefined
|
|
1376
|
+
static gloss = op === 'done' ? 'the old name of fixed' : undefined
|
|
1377
|
+
static older = op === 'done' ? true : undefined
|
|
826
1378
|
static override usage = Command.Usage({ category: 'Review', description, details: `${DETAILS}\n\nTakes an item id or a player report's ref (live#3). ${o.named ? 'Who acts: --as <name>, else SK_AGENT.' : 'Who acts: --as, else SK_AGENT, else agent.'}`, examples: o.examples })
|
|
827
|
-
id = Option.String()
|
|
1379
|
+
id = Option.String({ name: 'address | id' })
|
|
828
1380
|
words = o.text !== undefined || o.topic !== undefined ? Option.String({ required: false, name: o.text ?? 'topic' }) : undefined
|
|
829
1381
|
note = o.note === 'required' ? Option.String('--note', { required: true, description: 'what was done, why not, or what is needed' }) : Option.String('--note', { description: 'what was done, or the reason' })
|
|
830
1382
|
commit = Option.String('--commit', { description: 'the commit that holds the fix' })
|
|
831
1383
|
as = Option.String('--as', { description: 'who acts (else SK_AGENT)' })
|
|
1384
|
+
options = op === 'ask' ? Option.Array('--option', { description: 'a question he answers in one click: each option (two or more), words, a file (a picture, a clip, a sound: its name the label), "<label>=<file>" or "<label>=<before>,<after>"; any agent asks this way, the dispatcher asks without' }) : undefined
|
|
1385
|
+
pick = op === 'ask' ? Option.String('--pick', { description: 'with --option: the option you pick, by its number from 1 (the house rule: a pick on every question)' }) : undefined
|
|
1386
|
+
checklist = op === 'ask' ? Option.Array('--checklist', { description: 'a checklist he ticks, line by line, over days: each line a step, words on one line (markdown: bold, a link, code)' }) : undefined
|
|
1387
|
+
confirm = op === 'ask' ? Option.Boolean('--confirm', false, { description: 'one step he does in the real world: he answers « done »' }) : undefined
|
|
1388
|
+
text = op === 'ask' ? Option.Boolean('--text', false, { description: 'a value he types: a line or a paragraph' }) : undefined
|
|
1389
|
+
url = op === 'ask' ? Option.Boolean('--url', false, { description: 'a link he pastes (a proof, a listing): the hub opens it once and says its status' }) : undefined
|
|
1390
|
+
secret = op === 'ask' ? Option.String('--secret', { description: 'a key he types into the vault under this name: the thread keeps « stored as <name> », you use it as $(sk secret get <name>) inside the command that needs it; typed in the hub on the Mac that runs it or on his phone over the tailnet' }) : undefined
|
|
1391
|
+
after = op === 'ask' ? Option.String('--after', { description: 'set the thread aside until then (2h, tomorrow, next-week, YYYY-MM-DD[THH:MM]): your question waits for that day; only when you post it' }) : undefined
|
|
1392
|
+
urgent = op === 'ask' ? Option.Boolean('--urgent', false, { description: 'brings back a thread he set aside, at once: only under the bar of a ping (an incident, a hard block, a deadline before it comes back)' }) : undefined
|
|
1393
|
+
login = op === 'ask' ? Option.Boolean('--login', false, { description: 'with --secret: a login, its account (the email or user name) typed and stored beside it' }) : undefined
|
|
1394
|
+
replaces = op === 'ask' ? Option.String('--replaces', { description: 'the id of your earlier question (or words) this one supersedes: it folds to one line « superseded by … » and leaves the dock, his answers on it kept' }) : undefined
|
|
1395
|
+
verdict = op === 'ask' ? Option.Boolean('--verdict', false, { description: "refused: a question waits for the owner's answer already, his answer is its verdict" }) : undefined
|
|
1396
|
+
|
|
1397
|
+
/** the thread item the question goes on and what it supersedes: never a new thread when it supersedes */
|
|
1398
|
+
async target(h: Here): Promise<{ id: string; replaces?: string }> {
|
|
1399
|
+
if (this.replaces === undefined) return { id: await idOrOpen(h, this.id, this.words ?? '', this.as) }
|
|
1400
|
+
return replacing(h.dir, this.id, this.replaces, this.as)
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
/** after a question: set aside until --after, or brought back by --urgent */
|
|
1404
|
+
async later(h: Here, id: string): Promise<void> {
|
|
1405
|
+
if (this.urgent) await urgentOn(h.dir, id, actor(this.as, false, op))
|
|
1406
|
+
if (this.after === undefined) return
|
|
1407
|
+
const { asideAt, snoozeThread } = await import('../review/snooze.ts')
|
|
1408
|
+
const until = asideAt(this.after)
|
|
1409
|
+
if (until === null) throw new Error(`--after ${this.after}: 2h, tomorrow, next-week, or YYYY-MM-DD[THH:MM]`)
|
|
1410
|
+
snoozeThread(h.dir, id, { until, who: actor(this.as, false, op) })
|
|
1411
|
+
h.out(` set aside until ${until.toLocaleString()}: out of his turn until then`)
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
/** the answer kind the flags name, null for none (a choice through --option, or the dispatcher's question) */
|
|
1415
|
+
kindFlags(): { kind: AnswerKind; label: string } | null {
|
|
1416
|
+
const named = [
|
|
1417
|
+
...((this.checklist?.length ?? 0) > 0 ? [{ kind: 'checklist' as const, label: '--checklist' }] : []),
|
|
1418
|
+
...(this.confirm ? [{ kind: 'confirm' as const, label: '--confirm' }] : []),
|
|
1419
|
+
...(this.text ? [{ kind: 'text' as const, label: '--text' }] : []),
|
|
1420
|
+
...(this.url ? [{ kind: 'url' as const, label: '--url' }] : []),
|
|
1421
|
+
...(this.secret !== undefined ? [{ kind: 'secret' as const, label: '--secret' }] : []),
|
|
1422
|
+
]
|
|
1423
|
+
if (named.length > 1 || (named.length === 1 && this.options !== undefined)) throw new Error(`one answer kind a question: ${[...named.map((k) => k.label), ...(this.options !== undefined ? ['--option'] : [])].join(' and ')} together; ask twice`)
|
|
1424
|
+
if (this.login && this.secret === undefined) throw new Error('--login goes with --secret <name>')
|
|
1425
|
+
return named[0] ?? null
|
|
1426
|
+
}
|
|
832
1427
|
|
|
833
1428
|
async execute(): Promise<number> {
|
|
834
1429
|
return run(this.context, async (h) => {
|
|
835
1430
|
const { act, readItem } = await import('../review/store.ts')
|
|
1431
|
+
if (op === 'done') h.err(`sk thread done is now sk thread fixed ${this.id} "<what changed>"`)
|
|
1432
|
+
if (this.verdict) throw new Error("ask --verdict: a question waits for the owner's answer already, his answer is its verdict; a thing made he approves goes in a reply --verdict")
|
|
1433
|
+
const k = op === 'ask' ? this.kindFlags() : null
|
|
1434
|
+
if (k !== null) {
|
|
1435
|
+
const { postAsk } = await import('../review/store.ts')
|
|
1436
|
+
const { askStateText } = await import('../review/answer-kinds.ts')
|
|
1437
|
+
if (!this.words?.trim()) throw new Error(`ask <address | id> "<what you ask>" ${k.label}`)
|
|
1438
|
+
if (k.kind === 'secret' && this.secret) {
|
|
1439
|
+
const who = await (await import('../secrets/who-reads.ts')).whoReads([this.secret], process.cwd())
|
|
1440
|
+
if (who[this.secret]?.registered !== true) throw new Error(`--secret ${this.secret}: no row in the secret registry, so the vault would refuse the value he types. Add its row first (the name, what it is for, its scope: wiki identities/_common/secrets-registry.md), then ask again`)
|
|
1441
|
+
}
|
|
1442
|
+
const { id, replaces } = await this.target(h)
|
|
1443
|
+
const m = await postAsk(h.dir, id, { who: actor(this.as, false, op), text: this.words, kind: k.kind, ...(k.kind === 'checklist' ? { options: this.checklist ?? [] } : {}), ...(k.kind === 'secret' ? { secret: { name: this.secret ?? '', login: this.login === true } } : {}), ...(replaces ? { replaces } : {}) })
|
|
1444
|
+
h.out(`${id} asked: ${askStateText(readItem(h.dir, id)?.thread ?? [m], m)}`)
|
|
1445
|
+
await this.later(h, id)
|
|
1446
|
+
if (k.kind === 'secret') h.out(` his answer reads « stored as ${m.ask?.secret?.name} »; then: sk secret get ${m.ask?.secret?.name}`)
|
|
1447
|
+
return 0
|
|
1448
|
+
}
|
|
1449
|
+
if (op === 'ask' && this.options !== undefined) {
|
|
1450
|
+
const { postAsk } = await import('../review/store.ts')
|
|
1451
|
+
if (!this.words?.trim()) throw new Error('ask <address | id> "<question>" --option "<a>" --option "<b>" --pick <n>')
|
|
1452
|
+
const { id, replaces } = await this.target(h)
|
|
1453
|
+
const pick = this.pick === undefined ? undefined : Number(this.pick) - 1
|
|
1454
|
+
if (pick === undefined) h.err('no --pick: the house rule wants your pick on every question')
|
|
1455
|
+
const m = await postAsk(h.dir, id, { who: actor(this.as, false, op), text: this.words, options: this.options.map(askOption), ...(pick !== undefined ? { pick } : {}), ...(replaces ? { replaces } : {}) })
|
|
1456
|
+
h.out(`${id} asked: ${m.ask?.options.map((o, i) => `${i + 1} ${o}${m.ask?.views?.[i] != null ? ' [media]' : ''}${m.ask?.pick === i ? ' (your pick)' : ''}`).join(' · ')}`)
|
|
1457
|
+
await this.later(h, id)
|
|
1458
|
+
return 0
|
|
1459
|
+
}
|
|
836
1460
|
const { stateOf } = await import('../review/model.ts')
|
|
837
1461
|
const { detail } = await import('../review/format.ts')
|
|
838
1462
|
if (this.words !== undefined && o.text === undefined && o.topic === undefined) throw new Error(`unexpected ${this.words}`)
|
|
839
1463
|
if (o.text && !this.words?.trim()) throw new Error(`${op} <id> "<${o.text}>"`)
|
|
840
|
-
if (o.topic === 'required' && !this.words) throw new Error(`${op} <id> <topic> (sk
|
|
1464
|
+
if (o.topic === 'required' && !this.words) throw new Error(`${op} <id> <topic> (sk thread topics)`)
|
|
841
1465
|
const id = await idOf(h.dir, this.id)
|
|
842
1466
|
const who = actor(this.as, o.named, op)
|
|
1467
|
+
if (op === 'wontfix') {
|
|
1468
|
+
// an ask's thread closes by its ask (wiki tools/shipkit/threads-page.md, Close and reopen), as the hub's close does
|
|
1469
|
+
const { isAskItem } = await import('../review/model.ts')
|
|
1470
|
+
const was = readItem(h.dir, id)
|
|
1471
|
+
if (was && isAskItem(was.item)) {
|
|
1472
|
+
const { moveAsk, rootOfStore } = await import('../review/close.ts')
|
|
1473
|
+
const { findAsk } = await import('../asks/ask-store.ts')
|
|
1474
|
+
const moved = moveAsk(h.dir, was.item.on!, 'wontfix', this.note ?? '')
|
|
1475
|
+
const a = findAsk(rootOfStore(h.dir), was.item.on!)
|
|
1476
|
+
h.out(`${a.address} ${moved ? 'declined' : `${a.status} already`}${a.why ? `: ${a.why}` : ''}`)
|
|
1477
|
+
return 0
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
843
1480
|
if (op === 'done') {
|
|
844
1481
|
// done is asked of a card he answered « fix »: closed already is the goal reached, unanswered is withdraw's
|
|
845
1482
|
const { readAll } = await import('../review/store.ts')
|
|
@@ -848,14 +1485,16 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
|
|
|
848
1485
|
const followed = followedIds(readAll(h.dir).items).has(id)
|
|
849
1486
|
const st = was ? stateOf(was, followed) : null
|
|
850
1487
|
if (st?.state === 'closed') {
|
|
851
|
-
h.out(`${id}: closed already (${st.why ?? 'closed'}${followed ? ', a newer
|
|
852
|
-
if (this.words || this.note) h.err(`your words are not posted: sk
|
|
1488
|
+
h.out(`${id}: closed already (${st.why ?? 'closed'}${followed ? ', a newer version follows it' : ''}), nothing to close`)
|
|
1489
|
+
if (this.words || this.note) h.err(`your words are not posted: sk thread reply ${id} "<text>"`)
|
|
853
1490
|
return 0
|
|
854
1491
|
}
|
|
855
1492
|
if (st?.state === 'asks' || st?.state === 'draft')
|
|
856
|
-
throw new Error(`${id}: done closes a
|
|
1493
|
+
throw new Error(`${id}: done closes a version the owner answered « fix »; this one ${st.state === 'asks' ? "waits on the owner's verdict" : 'is in progress'}: sk thread withdraw ${id} --why "<why>" takes it back`)
|
|
857
1494
|
}
|
|
1495
|
+
const holds = op === 'done' || op === 'wontfix' || op === 'release' || op === 'blocked' || op === 'fixed' ? await callerHolds(h.dir, id, this.as) : false
|
|
858
1496
|
act(h.dir, id, op, who, {
|
|
1497
|
+
holds,
|
|
859
1498
|
...(this.note ? { note: this.note } : {}),
|
|
860
1499
|
...(op === 'ask' && this.words ? { text: this.words } : {}),
|
|
861
1500
|
...(op === 'done' && this.words ? { note: this.words } : {}),
|
|
@@ -872,16 +1511,65 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
|
|
|
872
1511
|
}
|
|
873
1512
|
}
|
|
874
1513
|
|
|
875
|
-
export const
|
|
876
|
-
export const
|
|
877
|
-
export const
|
|
878
|
-
export const
|
|
879
|
-
export const
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
export
|
|
883
|
-
|
|
884
|
-
|
|
1514
|
+
export const ReviewWontfixCommand = actCommand('wontfix', 'close an item he raised as not done, with the reason', { note: 'required', named: false, examples: [['not done', 'sk thread wontfix <id> --note "the room is gone"']] })
|
|
1515
|
+
export const ReviewClaimCommand = actCommand('claim', 'take an item to work on it: the hub shows the thread in work by your lane', { named: true, examples: [['take it', 'sk thread claim <id> --as L12']] })
|
|
1516
|
+
export const ReviewReleaseCommand = actCommand('release', 'give back an item you claimed', { note: 'optional', named: true, examples: [['give it back', 'sk thread release <id> --as L12']] })
|
|
1517
|
+
export const ReviewBlockedCommand = actCommand('blocked', 'an item you claimed goes back to the owner with what is needed', { note: 'required', named: true, examples: [['his decision is needed', 'sk thread blocked <id> --note "which of the two doors?" --as L12']] })
|
|
1518
|
+
export const ReviewDoneCommand = actCommand('done', 'the older name of sk thread fixed on a version he answered « ok with a fix »', { text: 'what changed', named: false, examples: [['the fix made', 'sk thread fixed <id> "the sign moved one tile up"']] })
|
|
1519
|
+
|
|
1520
|
+
/** `fixed <address | id> ["<what was done>"]`: the one way to say it is fixed (review/threads.ts fixedPlan) */
|
|
1521
|
+
export class ReviewFixedCommand extends Command {
|
|
1522
|
+
static override paths = [['review', 'fixed']]
|
|
1523
|
+
static essential = { args: '<address | id> [what was done]' }
|
|
1524
|
+
static override usage = Command.Usage({
|
|
1525
|
+
category: 'Review',
|
|
1526
|
+
description: 'it is fixed: closes an open note of the owner, an « ok with a fix », or asks the verdict again',
|
|
1527
|
+
details: `${DETAILS}\n\nOn a note of the owner (its id): closes it. On a thread (its address or a version's id): the owner's one open note in it closes (two or more are named: give the note's id); else its version he answered « ok with a fix » closes; else a version he rejected or in work asks the owner's verdict again, as sk thread update <id> fixed "<line>" does (with a file, use that).`,
|
|
1528
|
+
examples: [
|
|
1529
|
+
["the owner's note, with its commit", 'sk thread fixed page:threads/lightbox "the bar is half as tall" --commit abc1234'],
|
|
1530
|
+
['an « ok with a fix » made with no new version', 'sk thread fixed <id> "the sign moved one tile up"'],
|
|
1531
|
+
],
|
|
1532
|
+
})
|
|
1533
|
+
id = Option.String({ name: 'address | id' })
|
|
1534
|
+
words = Option.String({ required: false, name: 'what was done' })
|
|
1535
|
+
note = Option.String('--note', { description: 'what was done (the same as the words)' })
|
|
1536
|
+
commit = Option.String('--commit', { description: 'the commit that holds the fix' })
|
|
1537
|
+
as = Option.String('--as', { description: 'who acts (else SK_AGENT)' })
|
|
1538
|
+
|
|
1539
|
+
async execute(): Promise<number> {
|
|
1540
|
+
return run(this.context, async (h) => {
|
|
1541
|
+
const { act, postUpdate, readAll } = await import('../review/store.ts')
|
|
1542
|
+
const { stateOf } = await import('../review/model.ts')
|
|
1543
|
+
const { fixedPlan, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1544
|
+
const id = await idOf(h.dir, this.id)
|
|
1545
|
+
const items = readAll(h.dir).items
|
|
1546
|
+
const x = items.find((y) => y.item.id === id)
|
|
1547
|
+
const t = threadOfItem(id, threadsOf(items, h.say.spec))
|
|
1548
|
+
if (!x || !t) throw new Error(`no item ${this.id}`)
|
|
1549
|
+
const { ID_RE } = await import('../review/model.ts')
|
|
1550
|
+
const plan = fixedPlan(t, x, { byAddress: !ID_RE.test(this.id) && this.id.includes(':') && !/^\w+#\d+$/.test(this.id) })
|
|
1551
|
+
if ('error' in plan) throw new Error(plan.error)
|
|
1552
|
+
const said = (this.words ?? this.note)?.trim()
|
|
1553
|
+
const who = actor(this.as, false, 'fixed')
|
|
1554
|
+
if (plan.op === 'update') {
|
|
1555
|
+
const r = await postUpdate(h.dir, plan.id, { who, state: 'fixed', text: said || 'fixed' })
|
|
1556
|
+
const { isOpening } = await import('../review/model.ts')
|
|
1557
|
+
h.out(`${plan.id}: ${r.tag}; ${isOpening(r.item) ? 'its work is done, nothing waits on the owner' : "the owner's verdict is asked again"}`)
|
|
1558
|
+
return 0
|
|
1559
|
+
}
|
|
1560
|
+
const holds = await callerHolds(h.dir, plan.id, this.as)
|
|
1561
|
+
act(h.dir, plan.id, plan.op, who, { ...(said ? { note: said } : {}), ...(this.commit ? { commit: this.commit } : {}), holds })
|
|
1562
|
+
const after = readAll(h.dir).items.find((y) => y.item.id === plan.id)
|
|
1563
|
+
const st = after ? stateOf(after, false) : null
|
|
1564
|
+
h.out(`${plan.id} ${plan.op === 'done' ? 'closed, « ok with a fix » done' : 'fixed'}: ${st ? `${st.state}${st.why ? ` (${st.why})` : ''}` : 'gone'}`)
|
|
1565
|
+
return 0
|
|
1566
|
+
})
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
export const ReviewDispatchCommand = actCommand('dispatch', 'the dispatcher sends a raised item to a topic', { note: 'optional', topic: 'required', named: true, examples: [['to a topic', 'sk thread dispatch <id> lieux --as orchestrator']] })
|
|
1570
|
+
export const ReviewAskCommand = actCommand('ask', 'a question he answers in one click, with your pick; it starts the thread when none owns the address', { text: 'question', named: true, examples: [['one click, your pick on the second', 'sk thread ask messages:tui/u1 "which hook line ?" --option "Run any workflow" --option "Your workflow, one command" --pick 2'], ["the dispatcher's question on a raised item (no --option)", 'sk thread ask <id> "which tower?" --as orchestrator']] })
|
|
1571
|
+
export const ReviewDropCommand = actCommand('drop', 'the dispatcher closes a raised item with the reason (a duplicate, already fixed)', { note: 'required', named: true, examples: [['a duplicate', 'sk thread drop <id> --note "same as <other id>" --as orchestrator']] })
|
|
1572
|
+
export const ReviewReassignCommand = actCommand('reassign', 'the dispatcher takes a claim back, or sends the item to another topic', { note: 'optional', topic: 'optional', named: true, examples: [['a stale claim', 'sk thread reassign <id> --as orchestrator']] })
|
|
885
1573
|
|
|
886
1574
|
export class ReviewDispatcherCommand extends Command {
|
|
887
1575
|
static override paths = [['review', 'dispatcher']]
|
|
@@ -889,7 +1577,7 @@ export class ReviewDispatcherCommand extends Command {
|
|
|
889
1577
|
category: 'Review',
|
|
890
1578
|
description: 'take the dispatcher role: one session at a time routes what is raised',
|
|
891
1579
|
details: `${DETAILS}\n\nRefused while another holder acted in the last 30 minutes, unless --take. Only in a repo whose review unit declares a dispatcher.`,
|
|
892
|
-
examples: [['take the role', 'sk
|
|
1580
|
+
examples: [['take the role', 'sk thread dispatcher --as orchestrator']],
|
|
893
1581
|
})
|
|
894
1582
|
as = Option.String('--as', { description: 'who takes it (else SK_AGENT)' })
|
|
895
1583
|
take = Option.Boolean('--take', false, { description: 'take it from an active holder' })
|
|
@@ -913,7 +1601,7 @@ export class ReviewNextCommand extends Command {
|
|
|
913
1601
|
category: 'Review',
|
|
914
1602
|
description: 'claim the oldest open item of a topic, or raised to a lane, and show it with the pages to read first',
|
|
915
1603
|
details: DETAILS,
|
|
916
|
-
examples: [['the next of a topic', 'sk
|
|
1604
|
+
examples: [['the next of a topic', 'sk thread next lieux --as L12'], ['the next raised to a lane', 'sk thread next --lane interaction --as interaction']],
|
|
917
1605
|
})
|
|
918
1606
|
topic = Option.String({ required: false })
|
|
919
1607
|
lane = Option.String('--lane', { description: 'the lane he or a rule raised it to' })
|
|
@@ -961,7 +1649,7 @@ export class ReviewBoardCommand extends Command {
|
|
|
961
1649
|
category: 'Review',
|
|
962
1650
|
description: 'every open raised item by state, topic and worker, stale claims marked; who is the dispatcher',
|
|
963
1651
|
details: DETAILS,
|
|
964
|
-
examples: [['what is open', 'sk
|
|
1652
|
+
examples: [['what is open', 'sk thread board'], ['one topic, closed ones too', 'sk thread board --topic lieux --all']],
|
|
965
1653
|
})
|
|
966
1654
|
topic = Option.String('--topic', { description: 'one topic' })
|
|
967
1655
|
all = Option.Boolean('--all', false, { description: 'the closed ones too' })
|
|
@@ -978,7 +1666,7 @@ export class ReviewBoardCommand extends Command {
|
|
|
978
1666
|
for (const b of all.broken) h.err(`review: FAIL ${b.id}: ${b.error}`)
|
|
979
1667
|
if (h.say.spec.dispatcher) {
|
|
980
1668
|
const role = roleOf(h.dir)
|
|
981
|
-
h.out(role ? `dispatcher: ${role.name} (since ${role.since.slice(0, 16)})` : 'dispatcher: nobody (sk
|
|
1669
|
+
h.out(role ? `dispatcher: ${role.name} (since ${role.since.slice(0, 16)})` : 'dispatcher: nobody (sk thread dispatcher --as <name>)')
|
|
982
1670
|
}
|
|
983
1671
|
const now = new Date()
|
|
984
1672
|
const followed = followedIds(all.items)
|
|
@@ -1000,7 +1688,7 @@ export class ReviewBoardCommand extends Command {
|
|
|
1000
1688
|
|
|
1001
1689
|
export class ReviewReadyCommand extends Command {
|
|
1002
1690
|
static override paths = [['review', 'ready']]
|
|
1003
|
-
static override usage = Command.Usage({ category: 'Review', description: 'a draft
|
|
1691
|
+
static override usage = Command.Usage({ category: 'Review', description: 'a draft version becomes one he answers: its last frame, or the image given, stays', details: DETAILS })
|
|
1004
1692
|
id = Option.String()
|
|
1005
1693
|
image = Option.String('--image', { description: 'the image that stays' })
|
|
1006
1694
|
|
|
@@ -1023,7 +1711,7 @@ export class ReviewDeleteCommand extends Command {
|
|
|
1023
1711
|
category: 'Review',
|
|
1024
1712
|
description: "a player's test report removed at its source and here, or an item the owner raised removed here",
|
|
1025
1713
|
details: DETAILS,
|
|
1026
|
-
examples: [['a test report', 'sk
|
|
1714
|
+
examples: [['a test report', 'sk thread delete live#3']],
|
|
1027
1715
|
})
|
|
1028
1716
|
refs = Option.Rest({ required: 1 })
|
|
1029
1717
|
|
|
@@ -1055,7 +1743,7 @@ export class ReviewMarksCommand extends Command {
|
|
|
1055
1743
|
category: 'Review',
|
|
1056
1744
|
description: "the owner's marks kept in the store: per subject its latest stars, mark and note",
|
|
1057
1745
|
details: DETAILS,
|
|
1058
|
-
examples: [['every mark', 'sk
|
|
1746
|
+
examples: [['every mark', 'sk thread marks'], ['one kind, for a script', 'sk thread marks --subject song --json']],
|
|
1059
1747
|
})
|
|
1060
1748
|
subject = Option.String('--subject', { description: 'one subject kind' })
|
|
1061
1749
|
json = Option.Boolean('--json', false, { description: 'every subject key, its latest mark and its history count' })
|
|
@@ -1086,11 +1774,11 @@ export class ReviewAnimCommand extends Command {
|
|
|
1086
1774
|
static override paths = [['review', 'anim']]
|
|
1087
1775
|
static override usage = Command.Usage({
|
|
1088
1776
|
category: 'Review',
|
|
1089
|
-
description: "a
|
|
1090
|
-
details: `${DETAILS}\n\nsk
|
|
1777
|
+
description: "a version's before and after as a looping animation to send: a cut, a fade or a wipe, mp4 or gif",
|
|
1778
|
+
details: `${DETAILS}\n\nsk thread anim <id> [--view n] | --before a.png --after b.png. Made once and kept under .shipkit/review/.anims/; --out <file | dir/> copies it out (default .shipkit/tmp/).`,
|
|
1091
1779
|
examples: [
|
|
1092
|
-
['a fade, mp4', 'sk
|
|
1093
|
-
['a wipe of the second view, gif', 'sk
|
|
1780
|
+
['a fade, mp4', 'sk thread anim <id>'],
|
|
1781
|
+
['a wipe of the second view, gif', 'sk thread anim <id> --view 1 --mode wipe --format gif'],
|
|
1094
1782
|
],
|
|
1095
1783
|
})
|
|
1096
1784
|
id = Option.String({ required: false })
|
|
@@ -1098,7 +1786,7 @@ export class ReviewAnimCommand extends Command {
|
|
|
1098
1786
|
mode = Option.String('--mode', 'fade', { description: 'cut, fade or wipe' })
|
|
1099
1787
|
format = Option.String('--format', 'mp4', { description: 'mp4 or gif' })
|
|
1100
1788
|
labels = Option.String('--labels', 'en', { description: 'the corner labels: en, fr or none' })
|
|
1101
|
-
before = Option.String('--before', { description: 'an image, with --after: no
|
|
1789
|
+
before = Option.String('--before', { description: 'an image, with --after: no thread' })
|
|
1102
1790
|
after = Option.String('--after', { description: 'an image, with --before' })
|
|
1103
1791
|
out = Option.String('--out', { description: 'where it goes' })
|
|
1104
1792
|
|
|
@@ -1131,12 +1819,12 @@ export class ReviewStageCommand extends Command {
|
|
|
1131
1819
|
static override paths = [['review', 'stage']]
|
|
1132
1820
|
static override usage = Command.Usage({
|
|
1133
1821
|
category: 'Review',
|
|
1134
|
-
description: "one media of a
|
|
1135
|
-
details: `${DETAILS}\n\nThe media copied in with its metadata left out, the repo's guard run first, the draft committed by its paths. Without --view, the newest version's first media. Without --kind, iteration: feature, a change users can use now, is picked by hand. --dry prints the draft as it would be written, then each account, its place, its count, what it skips. It never publishes: Publish stays his, in Communications. Page: wiki tools/shipkit/
|
|
1822
|
+
description: "one media of a version staged as a post: a draft group of the repo's social store, never posted",
|
|
1823
|
+
details: `${DETAILS}\n\nThe media copied in with its metadata left out, the repo's guard run first, the draft committed by its paths. Without --view, the newest version's first media. Without --kind, iteration: feature, a change users can use now, is picked by hand. --dry prints the draft as it would be written, then each account, its place, its count, what it skips. It never publishes: Publish stays his, in Communications. Page: wiki tools/shipkit/threads-raised-notes.md, A post staged from a version`,
|
|
1136
1824
|
examples: [
|
|
1137
|
-
['the first media, a safe post', 'sk
|
|
1138
|
-
["the second view's wipe, polished by an agent", 'sk
|
|
1139
|
-
['what it would be', 'sk
|
|
1825
|
+
['the first media, a safe post', 'sk thread stage <id> --text "Hands now pinch and lift." --rating safe'],
|
|
1826
|
+
["the second view's wipe, polished by an agent", 'sk thread stage <id> --view B --side wipe --text "…" --rating mild --polish'],
|
|
1827
|
+
['what it would be', 'sk thread stage <id> --text "…" --rating safe --dry'],
|
|
1140
1828
|
],
|
|
1141
1829
|
})
|
|
1142
1830
|
id = Option.String({ required: true })
|
|
@@ -1161,7 +1849,7 @@ export class ReviewStageCommand extends Command {
|
|
|
1161
1849
|
const { dirname, join } = await import('node:path')
|
|
1162
1850
|
const { isPostRating, POST_RATINGS } = await import('../identities/rating.ts')
|
|
1163
1851
|
const missing = [this.text === undefined ? '--text "<the post>"' : null, this.rating === undefined ? `--rating <${POST_RATINGS.join('|')}>` : null].filter((x) => x !== null)
|
|
1164
|
-
if (this.text === undefined || this.rating === undefined) throw new Error(`sk
|
|
1852
|
+
if (this.text === undefined || this.rating === undefined) throw new Error(`sk thread stage ${this.id} needs ${missing.join(' and ')}`)
|
|
1165
1853
|
const { stageInputOf, stageOfCard } = await import('../review/stage-card.ts')
|
|
1166
1854
|
const { askPolish, fitStage, stagedKind, stageDraft, stageDry } = await import('../social/stage.ts')
|
|
1167
1855
|
const { loadSocialUnit } = await import('../social/unit.ts')
|
|
@@ -1171,9 +1859,12 @@ export class ReviewStageCommand extends Command {
|
|
|
1171
1859
|
const s = stageOfCard(h.dir, id)
|
|
1172
1860
|
let pick: string | undefined
|
|
1173
1861
|
if (this.view) {
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1862
|
+
// a view's number, or the letter it had before; either alone or after its version's number
|
|
1863
|
+
const m = /^(?:(\d+)\.)?(\d+|[A-Z]+)$/i.exec(this.view)
|
|
1864
|
+
if (m == null) throw new Error(`--view ${this.view}: a view's number, or <version>.<number>`)
|
|
1865
|
+
const { viewNo, viewRef } = await import('../review/model.ts')
|
|
1866
|
+
const k = viewNo(viewRef(m[2]!))
|
|
1867
|
+
const tag = `${m[1] ?? Math.max(...s.media.map((x) => Number(x.label.split('.')[0])))}.${k}`
|
|
1177
1868
|
const of = s.media.filter((x) => x.label.startsWith(`${tag} `))
|
|
1178
1869
|
const tile = this.tile
|
|
1179
1870
|
const hit = tile ? of.find((x) => x.tile !== undefined && (x.label.endsWith(`/${tile}`) || x.label.endsWith(` ${tile}`))) : of.find((x) => (x.side ?? 'after') === (this.side ?? 'after'))
|
|
@@ -1202,8 +1893,8 @@ export class ReviewAutoCommand extends Command {
|
|
|
1202
1893
|
static override usage = Command.Usage({
|
|
1203
1894
|
category: 'Review',
|
|
1204
1895
|
description: "the repo's auto rules: period, last run and answer, last item, next run; `auto run <id>` runs one",
|
|
1205
|
-
details: `${DETAILS}\n\nsk
|
|
1206
|
-
examples: [['every rule', 'sk
|
|
1896
|
+
details: `${DETAILS}\n\nsk thread auto | sk thread auto run <id> [--dry]. The hub's daemon runs them on their clocks.`,
|
|
1897
|
+
examples: [['every rule', 'sk thread auto'], ['what one would raise', 'sk thread auto run veille --dry']],
|
|
1207
1898
|
})
|
|
1208
1899
|
verb = Option.String({ required: false })
|
|
1209
1900
|
rule = Option.String({ required: false })
|
|
@@ -1256,46 +1947,104 @@ export class ReviewWatchCommand extends Command {
|
|
|
1256
1947
|
category: 'Review',
|
|
1257
1948
|
description: 'one line per verdict, reply or raised note as it lands; every unseen one first; ends with its owner',
|
|
1258
1949
|
details: `${DETAILS}\n\nRun it under a monitor, unfiltered (a grep holds a burst's last line). It registers itself, so the hub shows who listens. It exits within 2 s once a process above it at start is gone or nothing reads its output. An item nobody takes prints 2 minutes after its last message, then every 2 hours.`,
|
|
1259
|
-
examples: [['the
|
|
1950
|
+
examples: [['the threads this session holds', 'sk thread watch --mine'], ["one lane's items", 'sk thread watch --lane interaction']],
|
|
1260
1951
|
})
|
|
1261
|
-
mine = Option.Boolean('--mine', false, { description: "only this Claude Code session
|
|
1262
|
-
session = Option.String('--session', { description: "only that session
|
|
1952
|
+
mine = Option.Boolean('--mine', false, { description: "only the threads this Claude Code session holds" })
|
|
1953
|
+
session = Option.String('--session', { description: "only the threads that session holds" })
|
|
1263
1954
|
lane = Option.String('--lane', { description: "only that lane's items" })
|
|
1264
1955
|
|
|
1265
1956
|
async execute(): Promise<number> {
|
|
1266
1957
|
return run(this.context, async (h) => {
|
|
1267
1958
|
const { existsSync, mkdirSync, watch } = await import('node:fs')
|
|
1268
1959
|
const { readAll, scanStamp } = await import('../review/store.ts')
|
|
1960
|
+
const { cardsInDb } = await import('../hq/switch.ts')
|
|
1269
1961
|
const { AGENT_RE, coversCard, laneOf, UNTAKEN_AGAIN_MS, untakenOf } = await import('../review/model.ts')
|
|
1270
1962
|
const { followedIds, unseen } = await import('../review/threads.ts')
|
|
1271
1963
|
const { raisedLine, untakenLine, watchLines } = await import('../review/format.ts')
|
|
1272
1964
|
const { exitWithOwner, liveWatchers, registerWatch } = await import('../review/watchers.ts')
|
|
1273
1965
|
const session = await sessionOf(this.mine, this.session)
|
|
1274
|
-
|
|
1966
|
+
// --mine under SK_AGENT is that lane's watch: a lane shares its session's id, its name tells them apart
|
|
1967
|
+
const lane = this.lane?.trim() || (this.mine ? laneOfCaller(undefined) : null)
|
|
1275
1968
|
if (lane !== null && !AGENT_RE.test(lane)) throw new Error(`--lane: « ${lane} » is no lane id (${AGENT_RE.source})`)
|
|
1276
|
-
const
|
|
1969
|
+
const { hears, holderOf, listenersOf, threadByItem, threadsOf } = await import('../review/threads.ts')
|
|
1970
|
+
let byItem = new Map<string, import('../review/threads.ts').Thread>()
|
|
1971
|
+
// who hears what: the registry, read again every 30 s, so a lane's threads reach its session's watch once it ends
|
|
1972
|
+
const { noteHanded, readParties, repoNameOf } = await import('../agent-time/registry.ts')
|
|
1973
|
+
const { laneAsksFor, resumeOf } = await import('../review/inbox-read.ts')
|
|
1974
|
+
const { dirname } = await import('node:path')
|
|
1975
|
+
const { sessionId } = await import('../review/store.ts')
|
|
1976
|
+
const by = sessionId()
|
|
1977
|
+
let parties: import('../review/parties.ts').Parties | null = null
|
|
1978
|
+
const mine = (x: Parameters<typeof coversCard>[1]): boolean => hears({ session, lane }, x, byItem, parties)
|
|
1277
1979
|
if (session === null && lane === null) {
|
|
1278
1980
|
const { bareWatchTaken } = await import('../review/model.ts')
|
|
1279
1981
|
const taken = bareWatchTaken(liveWatchers(h.dir), process.pid)
|
|
1280
1982
|
if (taken !== null) throw new Error(taken)
|
|
1281
1983
|
}
|
|
1282
|
-
registerWatch(h.dir, { session, lane })
|
|
1984
|
+
const beat = registerWatch(h.dir, { session, lane }, new Date(), by)
|
|
1283
1985
|
// before any await: a pull that hangs never keeps a watch alive past its owner
|
|
1284
1986
|
exitWithOwner()
|
|
1987
|
+
setInterval(() => beat(), 10_000)
|
|
1988
|
+
const known = async (): Promise<void> => {
|
|
1989
|
+
if (session === null && lane === null) return
|
|
1990
|
+
const all = readAll(h.dir)
|
|
1991
|
+
const ids = new Set(threadsOf(all.items, h.say.spec).flatMap((t) => [...(t.head.item.origin.by === 'agent' && t.head.item.origin.session ? [t.head.item.origin.session] : []), ...(holderOf(t)?.session ?? [])]))
|
|
1992
|
+
parties = await readParties({ sessions: [...ids, ...(session ? [session] : [])], watchers: liveWatchers(h.dir), self: by })
|
|
1993
|
+
// a lane's watch ends with its lane: its threads pass to its session, whose hook or watch hears them
|
|
1994
|
+
const me = lane !== null && by !== null ? parties.lanes.filter((l) => l.name === lane && l.session === by) : []
|
|
1995
|
+
if (me.length > 0 && !me.some((l) => l.live)) {
|
|
1996
|
+
h.err(`review watch: exits, its lane ${lane} ended: its threads pass to its session`)
|
|
1997
|
+
process.exit(0)
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
await known().catch(() => {})
|
|
2001
|
+
setInterval(() => void known().catch(() => {}), 30_000)
|
|
1285
2002
|
const shown = new Set<string>()
|
|
1286
|
-
|
|
2003
|
+
// a store refused for a while (a fold or a way back of the daemon file walks): one line, and the next poll
|
|
2004
|
+
// reads again; never a watch that dies and hears nothing more
|
|
2005
|
+
let refused: string | null = null
|
|
2006
|
+
const safely = (fn: () => void): void => {
|
|
2007
|
+
try {
|
|
2008
|
+
fn()
|
|
2009
|
+
if (refused !== null) h.err(`review: ok, the store reads again: this watch goes on`)
|
|
2010
|
+
refused = null
|
|
2011
|
+
} catch (e) {
|
|
2012
|
+
const why = (e as Error).message.split('\n')[0] ?? ''
|
|
2013
|
+
if (refused === null) h.err(`review: WARN the store does not read now (${why}): this watch reads again at its next poll`)
|
|
2014
|
+
refused = why
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
const tick = (): void => safely(read)
|
|
2018
|
+
const read = (): void => {
|
|
1287
2019
|
const all = readAll(h.dir)
|
|
2020
|
+
byItem = threadByItem(threadsOf(all.items, h.say.spec))
|
|
1288
2021
|
for (const b of all.broken) {
|
|
1289
2022
|
const key = `broken ${b.id} ${b.error}`
|
|
1290
2023
|
if (!shown.has(key)) h.err(`review: FAIL ${b.id}: ${b.error}`)
|
|
1291
2024
|
shown.add(key)
|
|
1292
2025
|
}
|
|
1293
|
-
for (
|
|
1294
|
-
|
|
1295
|
-
|
|
2026
|
+
// his request for a lane, first: a session's watch (or a bare one) is the orchestrator's ear
|
|
2027
|
+
if (lane === null && (parties !== null || session === null)) {
|
|
2028
|
+
for (const l of laneAsksFor({ repo: repoNameOf(dirname(dirname(h.dir))), root: dirname(dirname(h.dir)), dir: h.dir, here: true, ...all, say: h.say }, { session, lane: null }, parties ?? { sessions: [], lanes: [] })) {
|
|
2029
|
+
if (shown.has(l)) continue
|
|
2030
|
+
shown.add(l)
|
|
2031
|
+
h.out(l)
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
for (const x of unseen(all.items).filter(mine)) {
|
|
2035
|
+
const fresh = watchLines(x, all.items).filter((l) => !shown.has(l.key))
|
|
2036
|
+
for (const l of fresh) {
|
|
1296
2037
|
shown.add(l.key)
|
|
1297
2038
|
h.out(l.text)
|
|
1298
2039
|
}
|
|
2040
|
+
// a session's watch, his message on its ended lane's thread: the way back to that lane
|
|
2041
|
+
const t = byItem.get(x.item.id)
|
|
2042
|
+
const r = fresh.length > 0 && lane === null && t && parties ? resumeOf(h, t, parties) : null
|
|
2043
|
+
if (r) {
|
|
2044
|
+
h.out(` ${r.line}`)
|
|
2045
|
+
noteHanded(r.lane, r.session, r.thread)
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
1299
2048
|
for (const x of all.items.filter(mine)) {
|
|
1300
2049
|
const l = raisedLine(x)
|
|
1301
2050
|
if (l === null || shown.has(l.key)) continue
|
|
@@ -1308,7 +2057,7 @@ export class ReviewWatchCommand extends Command {
|
|
|
1308
2057
|
const watchers = liveWatchers(h.dir)
|
|
1309
2058
|
for (const x of all.items) {
|
|
1310
2059
|
if (lane !== null && laneOf(x) !== lane) continue
|
|
1311
|
-
const why = untakenOf(x, followed.has(x.item.id), watchers, now, h.say.spec.dispatcher)
|
|
2060
|
+
const why = untakenOf(x, followed.has(x.item.id), listenersOf(watchers, x, byItem).length > 0, now, h.say.spec.dispatcher)
|
|
1312
2061
|
if (why === null) continue
|
|
1313
2062
|
const round = Math.floor((now.getTime() - Date.parse(x.thread.at(-1)?.at ?? x.item.created)) / UNTAKEN_AGAIN_MS)
|
|
1314
2063
|
const key = `untaken ${x.item.id} ${why} ${round}`
|
|
@@ -1320,31 +2069,402 @@ export class ReviewWatchCommand extends Command {
|
|
|
1320
2069
|
tick()
|
|
1321
2070
|
// the grace and the reminder pass with time alone: one read a minute
|
|
1322
2071
|
setInterval(tick, 60_000)
|
|
1323
|
-
//
|
|
2072
|
+
// the store the switch names, read again at each poll (a process reads the switch at most once a second), so a
|
|
2073
|
+
// watch follows a move while it runs. The rows: their stamp is a query of a few µs, asked every 50 ms, read at
|
|
2074
|
+
// once. The files: a watch of the folder asks again (debounced), and a stat stamp every 5 s catches a missed event
|
|
1324
2075
|
let soon: ReturnType<typeof setTimeout> | null = null
|
|
1325
2076
|
const again = (): void => {
|
|
1326
2077
|
if (soon) clearTimeout(soon)
|
|
1327
2078
|
soon = setTimeout(() => {
|
|
1328
2079
|
soon = null
|
|
1329
2080
|
tick()
|
|
1330
|
-
}, 150)
|
|
2081
|
+
}, cardsInDb() ? 0 : 150)
|
|
2082
|
+
}
|
|
2083
|
+
let folderWatched = false
|
|
2084
|
+
const watchFolder = (): void => {
|
|
2085
|
+
if (folderWatched) return
|
|
2086
|
+
folderWatched = true
|
|
2087
|
+
if (!existsSync(h.dir)) mkdirSync(h.dir, { recursive: true })
|
|
2088
|
+
watch(h.dir, { recursive: true }, () => {
|
|
2089
|
+
if (!cardsInDb()) again()
|
|
2090
|
+
})
|
|
1331
2091
|
}
|
|
1332
|
-
if (!
|
|
1333
|
-
watch(h.dir, { recursive: true }, again)
|
|
2092
|
+
if (!cardsInDb()) watchFolder()
|
|
1334
2093
|
// the sources: pulled now and every 30 s, a new item lands and the tick prints it
|
|
1335
2094
|
await pull(h)
|
|
1336
2095
|
if (h.unit?.sources?.length) setInterval(() => void pull(h), 30_000)
|
|
1337
|
-
let stamp =
|
|
2096
|
+
let stamp = ''
|
|
2097
|
+
let scanned = Date.now()
|
|
1338
2098
|
setInterval(() => {
|
|
1339
|
-
const
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
2099
|
+
const rows = cardsInDb()
|
|
2100
|
+
// the files' stamp walks every card: once every 5 s, never at the rows' pace
|
|
2101
|
+
if (!rows) {
|
|
2102
|
+
watchFolder()
|
|
2103
|
+
if (Date.now() - scanned < 5000) return
|
|
2104
|
+
}
|
|
2105
|
+
scanned = Date.now()
|
|
2106
|
+
// a refused stamp, or one read again after a refusal: the read says it, once
|
|
2107
|
+
try {
|
|
2108
|
+
const now = scanStamp(h.dir)
|
|
2109
|
+
if (now !== stamp || refused !== null) again()
|
|
2110
|
+
stamp = now
|
|
2111
|
+
} catch {
|
|
2112
|
+
again()
|
|
2113
|
+
}
|
|
2114
|
+
}, 50)
|
|
1343
2115
|
return new Promise<number>(() => {})
|
|
1344
2116
|
})
|
|
1345
2117
|
}
|
|
1346
2118
|
}
|
|
1347
2119
|
|
|
2120
|
+
/** the review folders of this machine's house, its archived repos included: what a move carries */
|
|
2121
|
+
async function houseStores(): Promise<string[]> {
|
|
2122
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
2123
|
+
const { houseRepos } = await import('../serve/project-gutter.ts')
|
|
2124
|
+
const { homedir } = await import('node:os')
|
|
2125
|
+
const { storeDir } = await import('../review/store.ts')
|
|
2126
|
+
const house = houseRepos(findRepoRoot(process.cwd()), homedir())
|
|
2127
|
+
if (house.index == null) throw new Error(`${process.cwd()} is in no house repo: run it from the house checkout, whose repos it moves`)
|
|
2128
|
+
const { existsSync } = await import('node:fs')
|
|
2129
|
+
const repos = [...house.repos, ...house.archived].map((r) => r.path)
|
|
2130
|
+
// a lane's worktree holds the cards it sent there: they join their repo's rows
|
|
2131
|
+
const trees = repos.flatMap((r) => {
|
|
2132
|
+
const p = Bun.spawnSync(['git', '-C', r, 'worktree', 'list', '--porcelain'], { stdout: 'pipe', stderr: 'ignore' })
|
|
2133
|
+
return (p.stdout?.toString() ?? '').split('\n').flatMap((l) => (l.startsWith('worktree ') && l.slice(9) !== r ? [l.slice(9)] : []))
|
|
2134
|
+
})
|
|
2135
|
+
return [...repos, ...trees.filter((t) => existsSync(storeDir(t)))].map((r) => storeDir(r))
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
export class ReviewMoveCommand extends Command {
|
|
2139
|
+
static override paths = [['review', 'move']]
|
|
2140
|
+
static override usage = Command.Usage({
|
|
2141
|
+
category: 'Review',
|
|
2142
|
+
description: "this machine's threads into the daemon's database, or back into files",
|
|
2143
|
+
details:
|
|
2144
|
+
"The machine db switch cards-in-db picks where every thread of this machine is read and written: its repo's files (`.shipkit/review/<id>/`, off, the default), or the rows of the daemon's database (on). `--go` imports every version file of every house repo the rows lack (by id and rev), proves each is in the rows, turns the switch on, then reads the files once more after a second for a writer that had not seen it. With the switch hq-cards on, it first asks the hq: the hq and the files must hold the same cards, else nothing moves. The files stay where they are, untouched: the way back. `--back` is a look of the way back, `--back --go` first fetches from the Space any media file the spool let go (or refuses, naming how many it would lack), then writes every version of the rows into the files (the versions made since included), turns the switch off, and writes them out again after a second. During a move's lag (7 s) a reader in another process can miss a version a writer made on the side the move left; the second pass carries it, and none stays missed. Both keep the later of two heads and every message by its id, so a move stopped half way runs again. A version's media files stay in its folder. `--tidy` (a look, `--tidy --go` acts) removes a version's files from its repo only while the switch is on and once its rows hold all of them, the hq holds them (hq-cards on) and the Space each of its media files; a version whose rows differ stays, named; after it, `--back --go` writes the files again from the rows. It moves every house repo of the home it runs in, worktrees resolved to their checkout: a test names a scratch HOME. Page: wiki tools/shipkit/threads-store.md",
|
|
2145
|
+
examples: [['what the tidy would remove', 'sk thread move --tidy'], ['what a move would do', 'sk thread move'], ['move this machine', 'sk thread move --go'], ['what the way back would do', 'sk thread move --back'], ['go back to the files', 'sk thread move --back --go']],
|
|
2146
|
+
})
|
|
2147
|
+
go = Option.Boolean('--go', false, { description: 'do it: the move, or with --back the way back' })
|
|
2148
|
+
back = Option.Boolean('--back', false, { description: 'the way back: the rows into the files, the switch off' })
|
|
2149
|
+
tidy = Option.Boolean('--tidy', false, { description: 'remove the thread files the rows, the hq and the Space all hold' })
|
|
2150
|
+
|
|
2151
|
+
async execute(): Promise<number> {
|
|
2152
|
+
const out = (l: string): void => void this.context.stdout.write(`${l}\n`)
|
|
2153
|
+
const err = (l: string): void => void this.context.stderr.write(`${l}\n`)
|
|
2154
|
+
try {
|
|
2155
|
+
if (this.tidy && this.back) throw new Error('--tidy or --back, not both')
|
|
2156
|
+
const stores = await houseStores()
|
|
2157
|
+
const { moveBack, moveGo, tidyFiles } = await import('../review/move.ts')
|
|
2158
|
+
const dry = !this.go
|
|
2159
|
+
// one move or look of the cards job at a time: the job would send what the move is writing
|
|
2160
|
+
const { cardsLease } = await import('../hq/cards.ts')
|
|
2161
|
+
const { leaseHolder, tryLease } = await import('../core/locked-write.ts')
|
|
2162
|
+
const lease = dry ? null : tryLease(cardsLease(), 'review move')
|
|
2163
|
+
if (!dry && lease == null) throw new Error(`a look of the hq threads job or another move runs (pid ${leaseHolder(cardsLease())?.pid ?? '?'}): run it again once it ended`)
|
|
2164
|
+
try {
|
|
2165
|
+
const r = this.tidy ? await tidyFiles(stores, { dry, proof: await tidyProof(stores) }) : this.back ? await moveBack(stores, { dry }) : await moveGo(stores, { dry, hqDiff: hqDiffOf(stores) })
|
|
2166
|
+
for (const l of r.lines) (l.startsWith('WARN') ? err : out)(l)
|
|
2167
|
+
const { cardsInDb } = await import('../hq/switch.ts')
|
|
2168
|
+
const { BACK_FIRST } = await import('../review/move.ts')
|
|
2169
|
+
if (cardsInDb()) out(BACK_FIRST)
|
|
2170
|
+
if (dry) out(`a look: nothing ${this.tidy ? 'removed' : 'moved'}. sk thread move ${this.tidy ? '--tidy --go removes' : this.back ? '--back --go moves' : '--go moves'}`)
|
|
2171
|
+
return r.ok ? 0 : 1
|
|
2172
|
+
} finally {
|
|
2173
|
+
lease?.release()
|
|
2174
|
+
}
|
|
2175
|
+
} catch (e) {
|
|
2176
|
+
err(`FAIL: review move: ${e instanceof Error ? e.message : String(e)}`)
|
|
2177
|
+
return 1
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
/** what the tidy proves outside the store: the names of each repo's rows the hq lacks or holds at another rev (the
|
|
2183
|
+
* check hq-cards, the hq asked once), and the Space's word on each file */
|
|
2184
|
+
async function tidyProof(stores: readonly string[]): Promise<import('../review/move.ts').TidyProof> {
|
|
2185
|
+
const { cardsDiff, cardsOn, heldRepos } = await import('../hq/cards.ts')
|
|
2186
|
+
const { confirmedUp } = await import('../media-store/remote.ts')
|
|
2187
|
+
const up = (key: string, size: number): Promise<boolean> => confirmedUp(key, size)
|
|
2188
|
+
if (!cardsOn()) return { hqLacks: async () => ({ refused: 'the switch hq-cards is off: no hq holds them' }), up }
|
|
2189
|
+
const { myHq } = await import('../hq/hq-local.ts')
|
|
2190
|
+
const hq = myHq()
|
|
2191
|
+
if ('refused' in hq) return { hqLacks: async () => ({ refused: `the hq is not reached (${hq.refused})` }), up }
|
|
2192
|
+
const { dirname } = await import('node:path')
|
|
2193
|
+
const { held, left } = await heldRepos(stores.map((d) => ({ name: d, path: dirname(dirname(d)) })))
|
|
2194
|
+
const diff = await cardsDiff(hq, held)
|
|
2195
|
+
if ('refused' in diff) return { hqLacks: async () => ({ refused: `the hq refused the check: ${diff.refused}` }), up }
|
|
2196
|
+
const { repoIdOf } = await import('../review/card-db.ts')
|
|
2197
|
+
const byRepo = new Map(diff.map((d) => [d.repo, new Set([...d.onlyHere, ...d.differ])]))
|
|
2198
|
+
return {
|
|
2199
|
+
hqLacks: async (dir) => {
|
|
2200
|
+
const set = byRepo.get(repoIdOf(dir))
|
|
2201
|
+
if (set != null) return set
|
|
2202
|
+
return { refused: left.some((l) => dir.startsWith(l)) ? 'a repo with no remote: the hq carries none of its threads' : 'the hq holds no threads of this repo' }
|
|
2203
|
+
},
|
|
2204
|
+
up,
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
/** with the switch hq-cards on, what the hq and this machine's files do not hold alike, a line each: the move's
|
|
2209
|
+
* proof that nothing it leaves behind is missing elsewhere. Null with the switch off */
|
|
2210
|
+
function hqDiffOf(stores: readonly string[]): () => Promise<string[] | null> {
|
|
2211
|
+
return async () => {
|
|
2212
|
+
const { cardsDiff, cardsOn, heldRepos } = await import('../hq/cards.ts')
|
|
2213
|
+
if (!cardsOn()) return null
|
|
2214
|
+
const { myHq } = await import('../hq/hq-local.ts')
|
|
2215
|
+
const hq = myHq()
|
|
2216
|
+
if ('refused' in hq) return [`the hq is not reached (${hq.refused}): the check hq-cards cannot prove both sides equal`]
|
|
2217
|
+
const { dirname } = await import('node:path')
|
|
2218
|
+
const { held } = await heldRepos(stores.map((d) => ({ name: d, path: dirname(dirname(d)) })))
|
|
2219
|
+
const diff = await cardsDiff(hq, held)
|
|
2220
|
+
if ('refused' in diff) return [`the hq refused the check: ${diff.refused}`]
|
|
2221
|
+
return diff.flatMap((d) => (d.onlyHere.length + d.onlyHq.length + d.differ.length === 0 ? [] : [`${d.repo}: ${d.onlyHere.length} only here, ${d.onlyHq.length} only in the hq, ${d.differ.length} at two revs (${[...d.onlyHere, ...d.onlyHq, ...d.differ].slice(0, 3).join(', ')})`]))
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
export class ReviewExportCommand extends Command {
|
|
2226
|
+
static override paths = [['review', 'export']]
|
|
2227
|
+
static override usage = Command.Usage({
|
|
2228
|
+
category: 'Review',
|
|
2229
|
+
description: 'threads of this repo written as their files, one folder an item, into a folder',
|
|
2230
|
+
details: `${DETAILS}\n\nWith the switch cards-in-db on, an item is rows of the daemon's database; export writes it as the folder the files backend keeps (\`<to>/<id>/item.json\`, \`thread/<message>.json\`, and each media file this machine still holds; a file the disk let go is named, its key in the head's media). Nothing in the store changes.`,
|
|
2231
|
+
examples: [['one item', 'sk thread export 20261118-210000-the-gate --to /tmp/threads'], ['every item of the repo', 'sk thread export --all --to /tmp/threads']],
|
|
2232
|
+
})
|
|
2233
|
+
all = Option.Boolean('--all', false, { description: 'every item of the repo' })
|
|
2234
|
+
to = Option.String('--to', { required: true, description: 'the folder the items are written into' })
|
|
2235
|
+
ids = Option.Rest()
|
|
2236
|
+
|
|
2237
|
+
async execute(): Promise<number> {
|
|
2238
|
+
return run(this.context, async (h) => {
|
|
2239
|
+
const { cardsInDb } = await import('../hq/switch.ts')
|
|
2240
|
+
const { resolve } = await import('node:path')
|
|
2241
|
+
if (this.all === this.ids.length > 0) throw new Error('give item ids or --all')
|
|
2242
|
+
const to = resolve(this.to)
|
|
2243
|
+
if (to === resolve(h.dir)) throw new Error(`--to ${this.to}: the store itself; sk thread move --back --go writes the rows into the store`)
|
|
2244
|
+
const ids = this.all ? undefined : await Promise.all(this.ids.map((r) => idOf(h.dir, r)))
|
|
2245
|
+
let r: import('../review/move.ts').Moved
|
|
2246
|
+
if (cardsInDb()) r = (await import('../review/move.ts')).exportRows(h.dir, { to, ...(ids ? { ids } : {}) })
|
|
2247
|
+
else {
|
|
2248
|
+
// the files are the store: a copy of each folder is the export
|
|
2249
|
+
const { cpSync, existsSync } = await import('node:fs')
|
|
2250
|
+
const { cardIds } = await import('../review/store.ts')
|
|
2251
|
+
const { join } = await import('node:path')
|
|
2252
|
+
const want = ids ?? cardIds(h.dir)
|
|
2253
|
+
for (const id of want) if (!existsSync(join(to, id))) cpSync(join(h.dir, id), join(to, id), { recursive: true })
|
|
2254
|
+
r = { dir: h.dir, cards: want.length, heads: want.length, msgs: 0, gone: 0, same: 0, files: 0, kept: [], broken: [], read: [] }
|
|
2255
|
+
}
|
|
2256
|
+
h.out(`review: ${r.cards} items written into ${to} (${r.heads} heads, ${r.msgs} messages${r.media ? `, ${r.media.copied} media files` : ''})`)
|
|
2257
|
+
for (const k of r.kept) h.out(` kept: ${k}`)
|
|
2258
|
+
for (const b of r.broken) h.err(` does not read: ${b}`)
|
|
2259
|
+
if (r.media && r.media.missing.length > 0) h.out(` ${r.media.missing.length} media files this machine no longer holds (the Space has them by their key in the head): ${r.media.missing.slice(0, 5).join(', ')}`)
|
|
2260
|
+
return r.broken.length > 0 ? 1 : 0
|
|
2261
|
+
})
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
/** what `propose` was typed with: its positionals, the thread it goes in, who acts, and its fields in the order typed:
|
|
2266
|
+
* `--field <key>` opens a field, the value flags after it are that field's; with no `--field`, one field */
|
|
2267
|
+
export function proposeArgs(args: readonly string[], read: (file: string) => string): { positionals: string[]; into?: string; as?: string; replaces?: string; fields: import('../review/store.ts').ProposeInput[] } {
|
|
2268
|
+
const positionals: string[] = []
|
|
2269
|
+
const fields: { key?: string; before?: string; after?: string; type?: string }[] = []
|
|
2270
|
+
let into: string | undefined
|
|
2271
|
+
let as: string | undefined
|
|
2272
|
+
let replaces: string | undefined
|
|
2273
|
+
const cur = (flag: string): (typeof fields)[number] => {
|
|
2274
|
+
if (fields.length === 0) fields.push({})
|
|
2275
|
+
const f = fields.at(-1)!
|
|
2276
|
+
const name = flag.replace(/-file$/, '') as 'before' | 'after' | 'type'
|
|
2277
|
+
if (f[name] !== undefined) throw new Error(`--${flag} twice on ${f.key ? `--field ${f.key}` : 'one field'}: a change of several names each with --field <key>`)
|
|
2278
|
+
return f
|
|
2279
|
+
}
|
|
2280
|
+
for (let i = 0; i < args.length; i++) {
|
|
2281
|
+
const a = args[i]!
|
|
2282
|
+
if (!a.startsWith('--')) {
|
|
2283
|
+
positionals.push(a)
|
|
2284
|
+
continue
|
|
2285
|
+
}
|
|
2286
|
+
if (a === '--verdict') throw new Error("--verdict: a proposed change waits for the owner's answer already, the owner's apply or the owner's words are its verdict")
|
|
2287
|
+
const v = args[++i]
|
|
2288
|
+
if (v === undefined) throw new Error(`${a}: needs a value`)
|
|
2289
|
+
const flag = a.slice(2)
|
|
2290
|
+
if (flag === 'field') fields.push({ key: v })
|
|
2291
|
+
else if (flag === 'in') into = v
|
|
2292
|
+
else if (flag === 'as') as = v
|
|
2293
|
+
else if (flag === 'replaces') replaces = v
|
|
2294
|
+
else if (flag === 'before' || flag === 'after' || flag === 'type') cur(flag)[flag] = v
|
|
2295
|
+
else if (flag === 'before-file' || flag === 'after-file') cur(flag)[flag === 'before-file' ? 'before' : 'after'] = read(v)
|
|
2296
|
+
else throw new Error(`${a}: no such flag (sk thread propose --help)`)
|
|
2297
|
+
}
|
|
2298
|
+
return {
|
|
2299
|
+
positionals,
|
|
2300
|
+
...(into !== undefined ? { into } : {}),
|
|
2301
|
+
...(as !== undefined ? { as } : {}),
|
|
2302
|
+
...(replaces !== undefined ? { replaces } : {}),
|
|
2303
|
+
fields: fields.map((f) => {
|
|
2304
|
+
const at = f.key ? `--field ${f.key}: ` : ''
|
|
2305
|
+
if (f.after === undefined) throw new Error(`${at}--after "<value>" (or --after-file): the value you propose`)
|
|
2306
|
+
const [type, lang] = f.type === undefined ? [] : f.type.split(':', 2)
|
|
2307
|
+
if (lang !== undefined && type !== 'code') throw new Error(`${at}--type ${f.type}: a language goes with code alone, code:<lang>`)
|
|
2308
|
+
return { after: f.after, ...(f.key !== undefined ? { key: f.key } : {}), ...(f.before !== undefined ? { before: f.before } : {}), ...(type !== undefined ? { type: type as import('../review/model.ts').DiffType } : {}), ...(lang ? { lang } : {}) }
|
|
2309
|
+
}),
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
const PROPOSE_USAGE = `sk thread propose <address> ["<why>"] --before "<value>" --after "<value>"
|
|
2314
|
+
sk thread propose <address> ["<why>"] --field <key> --before … --after … [--field <key> …]
|
|
2315
|
+
|
|
2316
|
+
--before, --after the value as it is and as you propose it (--before-file, --after-file read a file)
|
|
2317
|
+
--field <key> opens one field of a change of several: the value flags after it are its own; he applies each alone
|
|
2318
|
+
--type <text|color|sound|code[:<lang>]> how the field draws (code:ts, code:glsl: its syntax colours, none for a language it does not know); else the repo's unit declares it for that kind, else its values say
|
|
2319
|
+
--in <id | address> the thread to post it in, when it is not the address's own
|
|
2320
|
+
--as <name> who acts (else SK_AGENT)
|
|
2321
|
+
--replaces <id> your earlier change (or question) this one supersedes: it folds, its answers kept`
|
|
2322
|
+
|
|
2323
|
+
/** `propose <address> --after "<value>"`: a change of an object, one field or several, he applies in one click a field */
|
|
2324
|
+
export class ThreadProposeCommand extends Command {
|
|
2325
|
+
static override paths = [['thread', 'propose']]
|
|
2326
|
+
static essential = { args: '<address> ["<why>"] --before … --after …' }
|
|
2327
|
+
static override usage = Command.Usage({
|
|
2328
|
+
category: 'Review',
|
|
2329
|
+
description: 'a change he applies a field at a click: words, a colour, code, a sound; you land it',
|
|
2330
|
+
details: `${DETAILS}\n\n${PROPOSE_USAGE}\n\nIt goes into the thread that owns the address, or the one above it. Each field draws by its type: words as a word diff, a colour (#rrggbb) as its swatch beside the old one, code as a hunk in syntax colours, a sound (two files) as an A/B player; several fields as one table. His « apply » reaches your watch as one line a field, \`<id> applied <field> of <address>: land <value>\`: you write it where the object lives and say so in the thread. Page: wiki tools/shipkit/threads.md, A proposed change`,
|
|
2331
|
+
examples: [
|
|
2332
|
+
['a phrasing', 'SK_AGENT=L12 sk thread propose messages:tui/u1 --before "Run any workflow" --after "Run your workflow from the terminal" "shorter, and says where"'],
|
|
2333
|
+
['a colour and a label, each applied alone', 'SK_AGENT=L12 sk thread propose screen:home/button "warmer, and says what it does" --field accent --before "#3a7bd5" --after "#e0569b" --field label --before "Run" --after "Run it now"'],
|
|
2334
|
+
['a snippet of code', 'SK_AGENT=L12 sk thread propose asset:shader/water --type code:glsl --before-file old.glsl --after-file new.glsl "calmer waves"'],
|
|
2335
|
+
['a sound, A/B', 'SK_AGENT=L12 sk thread propose asset:sfx/clash --before sfx/clash.flac --after sfx/clash-v2.flac "less harsh"'],
|
|
2336
|
+
],
|
|
2337
|
+
})
|
|
2338
|
+
address = Option.String()
|
|
2339
|
+
words = Option.String({ required: false })
|
|
2340
|
+
field = Option.Array('--field', { description: 'opens one field of a change of several: the value flags after it are its own; he applies each alone' })
|
|
2341
|
+
before = Option.Array('--before', { description: 'the value as it is' })
|
|
2342
|
+
after = Option.Array('--after', { description: 'the value you propose' })
|
|
2343
|
+
beforeFile = Option.Array('--before-file', { description: 'the value as it is, from a file' })
|
|
2344
|
+
afterFile = Option.Array('--after-file', { description: 'the value you propose, from a file' })
|
|
2345
|
+
type = Option.Array('--type', { description: 'how the field draws: text, color, code[:<lang>], sound, image, clip (else the unit or its values say)' })
|
|
2346
|
+
into = Option.String('--in', { description: 'the thread to post it in, by an id or an address, when it is not the address own' })
|
|
2347
|
+
as = Option.String('--as', { description: 'who acts (else SK_AGENT)' })
|
|
2348
|
+
replaces = Option.String('--replaces', { description: 'the id of your earlier change (or question) this one supersedes: it folds to one line « superseded by … » and leaves the dock' })
|
|
2349
|
+
|
|
2350
|
+
async execute(): Promise<number> {
|
|
2351
|
+
// the flags are declared for the help; the fields are read in the order typed, since --field opens each
|
|
2352
|
+
const raw = process.argv.slice(2)
|
|
2353
|
+
const at = raw.indexOf('propose')
|
|
2354
|
+
const args = at >= 0 ? raw.slice(at + 1) : [this.address, ...(this.words !== undefined ? [this.words] : [])]
|
|
2355
|
+
return run(this.context, async (h) => {
|
|
2356
|
+
const { readFileSync } = await import('node:fs')
|
|
2357
|
+
const { postPropose } = await import('../review/store.ts')
|
|
2358
|
+
const p = proposeArgs(args, (f) => readFileSync(f, 'utf8'))
|
|
2359
|
+
const [address, words, ...more] = p.positionals
|
|
2360
|
+
if (address === undefined) throw new Error(`the address of the object first:\n${PROPOSE_USAGE}`)
|
|
2361
|
+
if (more.length > 0) throw new Error(`unexpected ${more.map(quoted).join(' ')}: one address, then the words in quotes`)
|
|
2362
|
+
const { addressOrThrow } = await import('../review/model.ts')
|
|
2363
|
+
await declaredOrThrow(h, addressOrThrow(address))
|
|
2364
|
+
const r = p.replaces !== undefined ? await replacing(h.dir, p.into ?? address, p.replaces, p.as) : null
|
|
2365
|
+
const id = r !== null ? r.id : p.into !== undefined ? await idOf(h.dir, p.into) : await idOrOpen(h, address, words ?? `a change of ${address}`, p.as)
|
|
2366
|
+
const m = await postPropose(h.dir, id, { who: actor(p.as, false, 'propose'), text: words ?? `a change of ${address}`, on: address, fields: p.fields, ...(r !== null ? { replaces: r.replaces } : {}) })
|
|
2367
|
+
const fields = m.propose?.fields ?? [{ key: '', type: m.propose?.type }]
|
|
2368
|
+
h.out(`${id} proposed ${m.propose?.on}${fields.length > 1 ? ` (${fields.map((f) => `${f.key}${f.type ? ` ${f.type}` : ''}`).join(', ')})` : m.propose?.type ? ` (${m.propose.type})` : ''}: he applies it in the hub, a field at a time`)
|
|
2369
|
+
return 0
|
|
2370
|
+
})
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
/** `attach <thread> <address>`: the thread links one more object */
|
|
2375
|
+
export class ThreadAttachCommand extends Command {
|
|
2376
|
+
static override paths = [['thread', 'attach']]
|
|
2377
|
+
static override usage = Command.Usage({
|
|
2378
|
+
category: 'Review',
|
|
2379
|
+
description: 'a thread links one more object: its thread control finds the thread; never its own address',
|
|
2380
|
+
details: `${DETAILS}\n\nA link: many threads may link one object. Page: wiki tools/shipkit/threads.md`,
|
|
2381
|
+
examples: [['link a media', 'sk thread attach 20261119-233610-trailer-v15 media:thumbnail-v3']],
|
|
2382
|
+
})
|
|
2383
|
+
thread = Option.String()
|
|
2384
|
+
address = Option.String()
|
|
2385
|
+
as = Option.String('--as', { description: 'who acts (else SK_AGENT)' })
|
|
2386
|
+
verdict = Option.Boolean('--verdict', false, { description: `the linked object waits for the owner's verdict (a draft, a text, a diff): ${VERDICT_FLAG}` })
|
|
2387
|
+
|
|
2388
|
+
async execute(): Promise<number> {
|
|
2389
|
+
return run(this.context, async (h) => {
|
|
2390
|
+
const { attachTo, specOf } = await import('../review/store.ts')
|
|
2391
|
+
const id = await idOf(h.dir, this.thread)
|
|
2392
|
+
const { addressOrThrow } = await import('../review/model.ts')
|
|
2393
|
+
const a = addressOrThrow(this.address)
|
|
2394
|
+
await declaredOrThrow(h, a)
|
|
2395
|
+
if (this.verdict) {
|
|
2396
|
+
// a kind with actions of its own (a reflection: accept, rework, discard): they are the owner's answer on the link
|
|
2397
|
+
const { HOUSE_KINDS } = await import('../review/kinds.ts')
|
|
2398
|
+
const k = a.slice(0, a.indexOf(':'))
|
|
2399
|
+
if (Object.keys((specOf(h.dir).kinds[k] ?? HOUSE_KINDS[k])?.actions ?? {}).length > 0) throw new Error(`attach ${a} --verdict: the kind ${k} declares its own actions, which are the owner's answer on the link; attach it without --verdict`)
|
|
2400
|
+
}
|
|
2401
|
+
attachTo(h.dir, id, actor(this.as, false, 'attach'), this.address, new Date(), this.verdict ? { asksVerdict: true } : {})
|
|
2402
|
+
h.out(`${id} links ${this.address}${this.verdict ? ", waiting for the owner's verdict" : ''}`)
|
|
2403
|
+
return 0
|
|
2404
|
+
})
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
export class ReviewMigrateCommand extends Command {
|
|
2409
|
+
static override paths = [
|
|
2410
|
+
['thread', 'migrate'],
|
|
2411
|
+
['review', 'migrate'],
|
|
2412
|
+
]
|
|
2413
|
+
static override usage = Command.Usage({
|
|
2414
|
+
category: 'Review',
|
|
2415
|
+
description: "fold the threads that own one address into one; dry run, --go after a backup",
|
|
2416
|
+
details: `${DETAILS}\n\nA look unless --go: per store, the links it would write (address, version, the version it supersedes) and the threads before and after. --go first runs sk backup (the machine db, where the daemon's rows are, goes to the Space as a snapshot) and stops when it fails, then writes each link through the head's one rewrite path. Only a missing link is written: a second run finds nothing. His notes read in their thread already: none is written. With hq-cards on, each changed head goes to the hq like any changed head. Page: wiki tools/shipkit/threads-store.md, The one thread guard`,
|
|
2417
|
+
examples: [['what it would fold here', 'sk thread migrate'], ['every house store', 'sk thread migrate --all'], ['fold them', 'sk thread migrate --all --go']],
|
|
2418
|
+
})
|
|
2419
|
+
go = Option.Boolean('--go', false, { description: 'write the links, after a backup' })
|
|
2420
|
+
all = Option.Boolean('--all', false, { description: 'every house store of this machine, not only this repo' })
|
|
2421
|
+
|
|
2422
|
+
async execute(): Promise<number> {
|
|
2423
|
+
return run(this.context, async (h) => {
|
|
2424
|
+
const { dirname } = await import('node:path')
|
|
2425
|
+
const { openReview } = await import('../review/project.ts')
|
|
2426
|
+
const { foldStore } = await import('../review/thread-fold.ts')
|
|
2427
|
+
const { repoIdOf } = await import('../review/card-db.ts')
|
|
2428
|
+
const { cardsInDb } = await import('../hq/switch.ts')
|
|
2429
|
+
const { existsSync } = await import('node:fs')
|
|
2430
|
+
const dirs = this.all ? await houseStores() : [h.dir]
|
|
2431
|
+
const seen = new Set<string>()
|
|
2432
|
+
const stores = dirs.filter((d) => {
|
|
2433
|
+
const key = cardsInDb() ? repoIdOf(d) : d
|
|
2434
|
+
if (seen.has(key)) return false
|
|
2435
|
+
seen.add(key)
|
|
2436
|
+
return cardsInDb() || existsSync(d)
|
|
2437
|
+
})
|
|
2438
|
+
const plans = []
|
|
2439
|
+
for (const d of stores) {
|
|
2440
|
+
await openReview(dirname(dirname(d)))
|
|
2441
|
+
plans.push({ d, ...foldStore(d, { go: false }) })
|
|
2442
|
+
}
|
|
2443
|
+
const todo = plans.filter((p) => p.links.length > 0)
|
|
2444
|
+
for (const p of plans) h.out(`${p.d}: ${p.links.length} links, ${p.before} threads to ${p.after}`)
|
|
2445
|
+
for (const p of todo) for (const l of p.links) h.out(` ${l.address}: ${l.id} supersedes ${l.supersedes}`)
|
|
2446
|
+
if (todo.length === 0) {
|
|
2447
|
+
h.out('ok: every address is one thread, nothing to fold')
|
|
2448
|
+
return 0
|
|
2449
|
+
}
|
|
2450
|
+
if (!this.go) {
|
|
2451
|
+
h.out(`a look: nothing written. ${this.all ? 'sk thread migrate --all --go' : 'sk thread migrate --go'} backs up, then folds`)
|
|
2452
|
+
return 0
|
|
2453
|
+
}
|
|
2454
|
+
h.out('backup first: sk backup')
|
|
2455
|
+
const b = Bun.spawnSync(['sk', 'backup'], { stdout: 'pipe', stderr: 'pipe' })
|
|
2456
|
+
const said = `${b.stdout?.toString() ?? ''}${b.stderr?.toString() ?? ''}`.trim()
|
|
2457
|
+
for (const l of said.split('\n').slice(-3)) h.out(` ${l}`)
|
|
2458
|
+
if (b.exitCode !== 0) throw new Error('sk backup failed: nothing folded, the stores are as they were')
|
|
2459
|
+
for (const p of todo) {
|
|
2460
|
+
const r = foldStore(p.d, { go: true })
|
|
2461
|
+
h.out(`${p.d}: ${r.links.length} links written, ${r.before} threads to ${r.after}`)
|
|
2462
|
+
}
|
|
2463
|
+
return 0
|
|
2464
|
+
})
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
|
|
1348
2468
|
export const REVIEW_COMMANDS = [
|
|
1349
2469
|
ReviewLsCommand,
|
|
1350
2470
|
ReviewAddCommand,
|
|
@@ -1378,4 +2498,18 @@ export const REVIEW_COMMANDS = [
|
|
|
1378
2498
|
ReviewStageCommand,
|
|
1379
2499
|
ReviewAutoCommand,
|
|
1380
2500
|
ReviewWatchCommand,
|
|
2501
|
+
ReviewMoveCommand,
|
|
2502
|
+
ReviewExportCommand,
|
|
2503
|
+
ReviewMigrateCommand,
|
|
2504
|
+
ThreadProposeCommand,
|
|
2505
|
+
ThreadAttachCommand,
|
|
2506
|
+
ThreadTakeCommand,
|
|
2507
|
+
ThreadAssignCommand,
|
|
2508
|
+
ThreadWorkingCommand,
|
|
1381
2509
|
]
|
|
2510
|
+
|
|
2511
|
+
// every verb is `sk thread <verb>`, and `sk review <verb>` its older name (run() says the new form on stderr)
|
|
2512
|
+
for (const C of REVIEW_COMMANDS) {
|
|
2513
|
+
const paths = (C.paths ?? []).flatMap((p) => (p[0] === 'review' ? [['thread', ...p.slice(1)], p] : [p]))
|
|
2514
|
+
C.paths = paths.filter((p, i) => paths.findIndex((q) => q.join(' ') === p.join(' ')) === i)
|
|
2515
|
+
}
|