rvlib-shipkit 2.31.0 → 2.33.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 +51 -0
- package/package.json +1 -1
- package/src/advisors/acts.ts +16 -15
- package/src/advisors/advice.ts +56 -102
- package/src/advisors/advisor-view.ts +122 -76
- package/src/advisors/app-graph.ts +1 -1
- package/src/advisors/app.ts +3 -11
- package/src/advisors/cf-api.ts +1 -1
- package/src/advisors/dir-bucket.ts +4 -3
- package/src/advisors/edge/api.ts +20 -221
- package/src/advisors/edge/bucket.ts +2 -2
- package/src/advisors/edge/handler.ts +13 -155
- package/src/advisors/edge/here.ts +5 -5
- package/src/advisors/edge/pages.ts +12 -9
- package/src/advisors/edge/shell.ts +6 -5
- package/src/advisors/edge/sign-in.ts +101 -36
- package/src/advisors/edge/status.ts +19 -6
- package/src/advisors/edge/types.ts +36 -60
- package/src/advisors/expose.ts +29 -29
- package/src/advisors/here.ts +12 -12
- package/src/advisors/invite-send.ts +79 -35
- package/src/advisors/invite.ts +31 -8
- package/src/advisors/job.ts +24 -16
- package/src/advisors/login.ts +40 -15
- package/src/advisors/owner-store.ts +46 -22
- package/src/advisors/photos.ts +3 -3
- package/src/advisors/project.ts +27 -25
- package/src/advisors/reach.ts +89 -0
- package/src/advisors/rights.ts +1 -1
- package/src/advisors/routes.ts +55 -74
- package/src/advisors/scan.ts +0 -4
- package/src/advisors/setup-run.ts +14 -14
- package/src/advisors/share-trace.ts +3 -3
- package/src/advisors/{door-probe.ts → sign-in-probe.ts} +7 -6
- package/src/advisors/speaks.ts +29 -0
- package/src/advisors/sync.ts +97 -183
- package/src/advisors/tunnel.ts +6 -5
- package/src/advisors/users-listen.ts +92 -0
- package/src/advisors/users-router.ts +261 -87
- package/src/advisors/users-store.ts +81 -0
- package/src/agent-time/blocked-scan.ts +181 -0
- package/src/agent-time/registry.ts +12 -5
- package/src/agent-time/store.ts +9 -109
- package/src/asks/ask-bar-fold.ts +2 -1
- package/src/asks/ask-close.ts +2 -1
- package/src/asks/ask-doc.ts +2 -1
- package/src/asks/ask-migrate.ts +3 -2
- package/src/asks/ask-steps-fold.ts +2 -1
- package/src/asks/ask-store.ts +4 -3
- package/src/check.ts +3 -43
- package/src/checks/SK001-package-json-shape.check.ts +4 -55
- package/src/checks/SK004-gitignore-policy.check.ts +24 -69
- package/src/checks/SK013-one-way-in-policy.check.ts +3 -7
- package/src/checks/SK017-vscode-hub-task.check.ts +4 -4
- package/src/checks/SK019-tests-run-in-units.check.ts +3 -14
- package/src/checks/SK020-self-spawning-check.check.ts +5 -7
- package/src/checks/SK035-public-clean.check.ts +1 -1
- package/src/checks/SK039-vscode-watch-generated.check.ts +1 -1
- package/src/checks/SK042-post-kinds.check.ts +5 -14
- package/src/checks/SK054-agent-allow-list.check.ts +5 -74
- package/src/checks/SK055-retired-config-keys.check.ts +45 -0
- package/src/cli/cmd_Advisors.ts +11 -45
- package/src/cli/cmd_Asks.ts +3 -10
- package/src/cli/cmd_Backup.ts +25 -127
- package/src/cli/cmd_BackupTargets.ts +1 -1
- package/src/cli/cmd_Capacity.ts +6 -2
- package/src/cli/cmd_Checks.ts +0 -14
- package/src/cli/cmd_Ci.ts +2 -1
- package/src/cli/cmd_Db.ts +3 -82
- package/src/cli/cmd_Home.ts +4 -32
- package/src/cli/cmd_Hq.ts +0 -17
- package/src/cli/cmd_Releases.ts +57 -4
- package/src/cli/cmd_Review.ts +333 -354
- package/src/cli/cmd_Shot.ts +26 -4
- package/src/cli/cmd_SocialDrafts.ts +6 -13
- package/src/cli/cmd_ThreadSyncNeeds.ts +6 -2
- package/src/cli/cmd_Time.ts +1 -1
- package/src/cli/cmd_Trailer.ts +1 -1
- package/src/cli/inbox-hook-run.ts +5 -23
- package/src/cli/registry-heads.ts +5 -55
- package/src/cli/registry.ts +1 -5
- package/src/cli/review-here.ts +1 -1
- package/src/cli.ts +15 -4
- package/src/collections/collection-types.ts +1 -1
- package/src/collections/review.ts +5 -4
- package/src/core/admission.ts +268 -0
- package/src/core/agent-allow-policy.ts +32 -2
- package/src/core/agent-env.ts +8 -0
- package/src/core/allow-rows.ts +74 -0
- package/src/core/check-file-names.ts +19 -106
- package/src/core/code-lines.ts +36 -21
- package/src/core/footprint.ts +17 -13
- package/src/core/identities-root.ts +1 -4
- package/src/core/layout.ts +1 -2
- package/src/core/machine-db.ts +33 -208
- package/src/core/machine-layout.ts +14 -127
- package/src/core/machine-read.ts +5 -2
- package/src/core/mask-source.ts +60 -0
- package/src/core/memory-watch.ts +17 -14
- package/src/core/motherhome.ts +8 -35
- package/src/core/one-way-in-policy.ts +0 -3
- package/src/core/peer-sk.ts +8 -0
- package/src/core/repo-walk.ts +0 -9
- package/src/core/retention.ts +1 -9
- package/src/core/retired-checks.ts +2 -0
- package/src/core/tmux-policy.ts +1 -1
- package/src/core/tree-watch.ts +2 -2
- package/src/core/when.ts +7 -45
- package/src/gate/admit-heavy.ts +150 -0
- package/src/gate/check-runner.ts +6 -0
- package/src/gate/discover-checks.ts +42 -32
- package/src/gate/gate-checks.ts +21 -131
- package/src/gate/head-gate.ts +1 -1
- package/src/gate/job-run.ts +2 -1
- package/src/gate/pre-commit-discovery.ts +22 -28
- package/src/gate/run-check.ts +3 -4
- package/src/gate/run-ci.ts +4 -0
- package/src/gate/run-fix.ts +5 -17
- package/src/gate/run-fixers.ts +6 -42
- package/src/home/app-sign.ts +2 -2
- package/src/home/backup-status.ts +52 -92
- package/src/home/backup-verdict.ts +2 -2
- package/src/home/daemon-jobs.ts +51 -95
- package/src/home/database-words.ts +1 -2
- package/src/home/databases.ts +9 -25
- package/src/home/home-launchd.ts +0 -6
- package/src/home/home-paths.ts +8 -4
- package/src/home/home-routes.ts +3 -10
- package/src/home/home-state.ts +2 -14
- package/src/home/inbox-shape.ts +14 -15
- package/src/home/inbox.ts +1 -1
- package/src/home/machine-repair.ts +102 -103
- package/src/home/resume.ts +1 -15
- package/src/home/run-daemon.ts +7 -12
- package/src/home/space-page.ts +3 -2
- package/src/home/supervise.ts +3 -7
- package/src/hooks/commit-msg-run.ts +61 -0
- package/src/hooks/commit-run.ts +16 -166
- package/src/hooks/gate-outcome.ts +108 -0
- package/src/hooks/git-hook.ts +9 -9
- package/src/hooks/hook-config.ts +8 -8
- package/src/hooks/leak-guard.ts +1 -1
- package/src/hooks/pre-commit-checks.ts +1 -1
- package/src/hooks/run-hooks.ts +2 -6
- package/src/hooks/shared-file.ts +3 -2
- package/src/hq/daemon-db.ts +8 -8
- package/src/hq/door.ts +3 -16
- package/src/hq/hq-db.ts +4 -3
- package/src/hq/hq-local.ts +1 -2
- package/src/hq/hq-store.ts +0 -15
- package/src/hq/item-direct.ts +8 -10
- package/src/hq/item-fill.ts +37 -0
- package/src/hq/kinds/item-gone.ts +7 -10
- package/src/hq/kinds/item-msg.ts +12 -18
- package/src/hq/kinds/item.ts +13 -19
- package/src/hq/kinds/report.ts +3 -4
- package/src/hq/owner-switch.ts +3 -3
- package/src/hq/report.ts +5 -9
- package/src/hq/switch.ts +2 -11
- package/src/hq/thread-sync.ts +5 -17
- package/src/hq/{shapes-words.ts → threads-words.ts} +2 -12
- package/src/http/owner-word.ts +1 -1
- package/src/identities/machine.ts +16 -0
- package/src/init-repo.ts +0 -1
- package/src/ledger/check-stats.ts +6 -5
- package/src/ledger/db.ts +2 -4
- package/src/ledger/record-kept.ts +117 -48
- package/src/ledger/run-log.ts +21 -2
- package/src/ledger/slow-tests.ts +96 -0
- package/src/ledger/store.ts +3 -86
- package/src/ledger/suite-log.ts +8 -2
- package/src/media-store/backup/facts.ts +3 -37
- package/src/media-store/backup/keys.ts +1 -8
- package/src/media-store/backup/manifest.ts +6 -67
- package/src/media-store/backup/restore.ts +4 -13
- package/src/media-store/backup/retention.ts +13 -1
- package/src/media-store/backup/run.ts +6 -267
- package/src/media-store/backup/snapshot.ts +2 -38
- package/src/media-store/backup/sources.ts +3 -113
- package/src/media-store/backup/target-send.ts +5 -29
- package/src/media-store/db.ts +8 -7
- package/src/media-store/forget-one.ts +1 -1
- package/src/media-store/forget.ts +1 -80
- package/src/orchestrator/guards.ts +0 -1
- package/src/orchestrator/presence.ts +2 -2
- package/src/orchestrator/routes.ts +1 -1
- package/src/orchestrator/started.ts +0 -9
- package/src/orchestrator/talk-key.ts +3 -4
- package/src/orchestrator/unheard.ts +1 -1
- package/src/plan/planner.ts +3 -2
- package/src/recordings/edit.ts +3 -3
- package/src/recordings/marks-draw.ts +17 -6
- package/src/recordings/marks.ts +120 -9
- package/src/reflections/reflections-queue.ts +3 -10
- package/src/release/notes.ts +1 -1
- package/src/release/public-clean.ts +66 -6
- package/src/release/run-bump.ts +11 -0
- package/src/release/run-release.ts +4 -0
- package/src/releases/from-thread.ts +3 -3
- package/src/releases/model.ts +186 -36
- package/src/releases/store.ts +13 -3
- package/src/releases/validate.ts +83 -0
- package/src/repo-config.ts +36 -64
- package/src/review/answer-kinds.ts +63 -4
- package/src/review/blocked-guard.ts +11 -0
- package/src/review/blocked-object.ts +298 -0
- package/src/review/cells.ts +144 -230
- package/src/review/close.ts +39 -1
- package/src/review/doc-save.ts +3 -2
- package/src/review/draft-item.ts +1 -1
- package/src/review/events.ts +3 -7
- package/src/review/expect.ts +23 -39
- package/src/review/format.ts +79 -46
- package/src/review/glyphs.ts +1 -0
- package/src/review/hand-over.ts +3 -3
- package/src/review/heard.ts +1 -1
- package/src/review/holds-sync.ts +2 -1
- package/src/review/inbox-hook.ts +2 -2
- package/src/review/inbox-read.ts +39 -33
- package/src/review/instruction-guards.ts +12 -0
- package/src/review/instructions.ts +0 -1
- package/src/review/item-db.ts +13 -43
- package/src/review/item-hq.ts +2 -2
- package/src/review/item-rows.ts +3 -14
- package/src/review/kind-catalog.ts +3 -1
- package/src/review/kinds.ts +18 -8
- package/src/review/live-view.ts +3 -0
- package/src/review/media-kind.ts +1 -1
- package/src/review/mentions.ts +1 -2
- package/src/review/model.ts +158 -114
- package/src/review/move.ts +149 -0
- package/src/review/need-threads.ts +3 -2
- package/src/review/object-card.ts +11 -0
- package/src/review/object-read.ts +6 -1
- package/src/review/one-block.ts +1 -1
- package/src/review/owner-read.ts +1 -1
- package/src/review/phone-push.ts +10 -9
- package/src/review/previews.ts +32 -4
- package/src/review/push.ts +2 -2
- package/src/review/recap.ts +129 -0
- package/src/review/referring.ts +6 -3
- package/src/review/reflection-object.ts +4 -3
- package/src/review/routes.ts +51 -47
- package/src/review/secret-route.ts +3 -2
- package/src/review/settle.ts +0 -6
- package/src/review/snooze.ts +5 -3
- package/src/review/speaker.ts +68 -0
- package/src/review/start-title.ts +19 -0
- package/src/review/store-parties.ts +28 -0
- package/src/review/store.ts +94 -59
- package/src/review/{wakes.ts → thread-events.ts} +92 -7
- package/src/review/thread-md.ts +35 -14
- package/src/review/thread-state.ts +804 -0
- package/src/review/threads.ts +29 -347
- package/src/review/traces.ts +104 -7
- package/src/review/trailer-item.ts +1 -1
- package/src/review/unit.ts +7 -9
- package/src/review/verdict-items.ts +12 -10
- package/src/review/view-layout.ts +25 -1
- package/src/review/watch-feed.ts +1 -2
- package/src/review/working-guards.ts +2 -3
- package/src/rules/untrack-generated.ts +1 -15
- package/src/secrets/copy.ts +4 -4
- package/src/secrets/lapse.ts +2 -1
- package/src/serve/hub-app/advisor-app.tsx +4 -4
- package/src/serve/hub-app/advisor-face.tsx +9 -3
- package/src/serve/hub-app/advisor-host.ts +27 -27
- package/src/serve/hub-app/advisors-model.ts +17 -8
- package/src/serve/hub-app/advisors-rights.tsx +1 -1
- package/src/serve/hub-app/advisors-st.ts +15 -14
- package/src/serve/hub-app/advisors-view.tsx +13 -11
- package/src/serve/hub-app/app-bridge.ts +23 -3
- package/src/serve/hub-app/asks-page.tsx +1 -1
- package/src/serve/hub-app/auto-text.tsx +71 -16
- package/src/serve/hub-app/check-view.tsx +0 -8
- package/src/serve/hub-app/controls.css +14 -3
- package/src/serve/hub-app/database-view.tsx +1 -2
- package/src/serve/hub-app/dock-st.ts +1 -1
- package/src/serve/hub-app/git-view.tsx +3 -1
- package/src/serve/hub-app/hub.css +12 -5
- package/src/serve/hub-app/icons.tsx +1 -1
- package/src/serve/hub-app/inbox-view.tsx +1 -2
- package/src/serve/hub-app/live-sources.ts +2 -2
- package/src/serve/hub-app/main-panel.tsx +2 -1
- package/src/serve/hub-app/panel-repo.ts +0 -9
- package/src/serve/hub-app/pic.tsx +29 -12
- package/src/serve/hub-app/polled.ts +16 -2
- package/src/serve/hub-app/recordings-st.ts +23 -2
- package/src/serve/hub-app/recordings-view.tsx +68 -10
- package/src/serve/hub-app/ref-pill.ts +1 -1
- package/src/serve/hub-app/repo-st.ts +1 -2
- package/src/serve/hub-app/review/advisor-add.tsx +1 -1
- package/src/serve/hub-app/review/advisor-invite.tsx +1 -1
- package/src/serve/hub-app/review/draft-body.tsx +2 -2
- package/src/serve/hub-app/review/heard-line.tsx +1 -1
- package/src/serve/hub-app/review/instructions-view.tsx +1 -8
- package/src/serve/hub-app/review/kind-states.tsx +14 -9
- package/src/serve/hub-app/review/kit.tsx +4 -11
- package/src/serve/hub-app/review/lane-bar.tsx +3 -3
- package/src/serve/hub-app/review/lightbox.tsx +15 -11
- package/src/serve/hub-app/review/line-window.ts +4 -1
- package/src/serve/hub-app/review/live-bar-st.ts +2 -2
- package/src/serve/hub-app/review/live-view.tsx +57 -1
- package/src/serve/hub-app/review/object-panel.tsx +20 -8
- package/src/serve/hub-app/review/question-views.tsx +191 -53
- package/src/serve/hub-app/review/recap-bar.tsx +40 -0
- package/src/serve/hub-app/review/request-cell.tsx +48 -0
- package/src/serve/hub-app/review/review-cells.tsx +154 -96
- package/src/serve/hub-app/review/review-host.ts +8 -4
- package/src/serve/hub-app/review/review-kit.ts +17 -11
- package/src/serve/hub-app/review/review-list.tsx +30 -35
- package/src/serve/hub-app/review/review-st.ts +32 -42
- package/src/serve/hub-app/review/review-thread.tsx +139 -85
- package/src/serve/hub-app/review/review-views.tsx +127 -68
- package/src/serve/hub-app/review/share-lines.tsx +4 -4
- package/src/serve/hub-app/review/start-st.ts +2 -5
- package/src/serve/hub-app/review/superseded-runs.ts +4 -3
- package/src/serve/hub-app/review/thread-close.tsx +10 -7
- package/src/serve/hub-app/review/thread-st.ts +381 -202
- package/src/serve/hub-app/review/tone-bar.tsx +129 -0
- package/src/serve/hub-app/review/tones.ts +53 -0
- package/src/serve/hub-app/review/trailer-body.tsx +2 -2
- package/src/serve/hub-app/review/trailer-st.ts +3 -2
- package/src/serve/hub-app/review/trailer-voices-st.ts +3 -2
- package/src/serve/hub-app/review.css +189 -106
- package/src/serve/hub-app/search-view.tsx +1 -1
- package/src/serve/hub-app/social/social-model.ts +0 -4
- package/src/serve/hub-app/source-acts.ts +2 -1
- package/src/serve/hub-app/stores/stores-page.tsx +2 -2
- package/src/serve/hub-app/terminal-sources.tsx +2 -1
- package/src/serve/hub-app/thread-row.tsx +3 -4
- package/src/serve/hub-app/tree-build.ts +0 -4
- package/src/serve/hub-app/urls-view.tsx +2 -1
- package/src/serve/hub-app/view-layout.css +13 -3
- package/src/serve/hub-app/wikis-view.tsx +5 -2
- package/src/serve/hub-runtime.ts +7 -37
- package/src/serve/project-gutter-route.ts +6 -2
- package/src/serve/read-thread.ts +20 -2
- package/src/serve/read-worker.ts +9 -1
- package/src/serve/record-pages.ts +46 -0
- package/src/serve/serve-hub.ts +2 -2
- package/src/serve/terminal-host.ts +1 -1
- package/src/serve/terminal-route.ts +1 -3
- package/src/serve/tracked-watch.ts +1 -3
- package/src/setup-house.ts +2 -2
- package/src/shipkit-files.ts +1 -1
- package/src/shipkit.ts +1 -6
- package/src/shot/client.ts +2 -1
- package/src/shot/film-box.ts +0 -20
- package/src/shot/on-place.ts +141 -0
- package/src/social/drafts.ts +1 -1
- package/src/social/kinds.ts +6 -29
- package/src/social/load.ts +2 -2
- package/src/social/post-object.ts +3 -2
- package/src/social/release-stage.ts +1 -1
- package/src/social/stage.ts +2 -2
- package/src/stores/model.ts +4 -0
- package/src/stores/routes.ts +11 -3
- package/src/suite/judge-suites.ts +58 -0
- package/src/suite/red-alone.ts +54 -18
- package/src/suite/runner-shapes.ts +2 -2
- package/src/suite/suite-cli.ts +67 -14
- package/src/suite/test-units.ts +2 -1
- package/src/urls/fill.ts +1 -1
- package/src/urls/places.ts +1 -2
- package/src/vault/vault-config.ts +2 -2
- package/src/vault/vault-init.ts +1 -5
- package/src/wiki/graph-page.ts +14 -2
- package/src/advisors/copy-truth.ts +0 -49
- package/src/advisors/door-child.ts +0 -112
- package/src/advisors/door-serve.ts +0 -52
- package/src/advisors/door.ts +0 -118
- package/src/checks/SK016-legacy-check-shapes.check.ts +0 -189
- package/src/checks/SK029-explicit-check-files.check.ts +0 -112
- package/src/checks/SK048-one-local-file.check.ts +0 -36
- package/src/core/config-rewrite.ts +0 -111
- package/src/core/daemon-port.ts +0 -10
- package/src/core/legacy-shapes.ts +0 -263
- package/src/core/migrate-layout.ts +0 -638
- package/src/core/port-check-cli.ts +0 -52
- package/src/core/port-check-file.ts +0 -295
- package/src/core/port-check-files.ts +0 -31
- package/src/gate/discover-legacy-checks.ts +0 -26
- package/src/home/home-move.ts +0 -527
- package/src/home/machine-fold.ts +0 -810
- package/src/hq/item-shapes.ts +0 -54
- package/src/hq/kinds/items-read.ts +0 -4
- package/src/media-store/backup/daemon.ts +0 -220
- package/src/media-store/backup/kept.ts +0 -241
- package/src/media-store/backup/prune.ts +0 -359
- package/src/media-store/backup/secret.ts +0 -88
- package/src/media-store/backup/ssh-space.ts +0 -202
- package/src/media-store/backup/watch.ts +0 -117
- package/src/review/band.ts +0 -182
- package/src/review/folders.ts +0 -216
- package/src/review/hook-ask.ts +0 -58
- package/src/review/role.ts +0 -48
- package/src/review/thread-fold.ts +0 -64
- package/src/review/wait.ts +0 -91
- package/src/rules/rule.ts +0 -43
- package/src/serve/hook-thread.ts +0 -37
- package/src/serve/hook-work.ts +0 -92
- package/src/serve/hook-worker.ts +0 -57
- package/src/serve/hub-app/review/dock.tsx +0 -147
- package/src/serve/hub-app/review/faces.tsx +0 -18
- package/src/serve/hub-app/review/item-verdict.tsx +0 -112
- package/src/serve/hub-app/review/review-board.tsx +0 -48
- /package/src/{scaffold → core}/jsonc-spans.ts +0 -0
package/src/review/model.ts
CHANGED
|
@@ -73,6 +73,10 @@ export interface KindAction {
|
|
|
73
73
|
what?: string
|
|
74
74
|
/** the click opens a word box: the owner's words ride with the action */
|
|
75
75
|
words?: boolean
|
|
76
|
+
/** with `words`: the box starts with the text of the object's line that begins `<fill>:`, for him to edit */
|
|
77
|
+
fill?: string
|
|
78
|
+
/** a no (refuse, discard): once he chose it, it draws picked in red, a yes in green */
|
|
79
|
+
no?: true
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
/** an act of the owner on a version of a kind that answers its versions with its own acts (a draft: publish, drop,
|
|
@@ -116,6 +120,8 @@ export interface SpecKind {
|
|
|
116
120
|
questions?: Record<string, KindQuestion>
|
|
117
121
|
/** the buttons on an object of this kind, by name */
|
|
118
122
|
actions?: Record<string, KindAction>
|
|
123
|
+
/** its card where a message links it shows its words whole, not their one line: what the owner judges is in them */
|
|
124
|
+
whole?: true
|
|
119
125
|
/** its versions answered by these acts, by name, never by approve, fix, reject (review/settle.ts); none: the verdict */
|
|
120
126
|
acts?: Record<string, KindAct>
|
|
121
127
|
/** an object of this kind attached to a thread holds it open until its condition is met (review/holds.ts) */
|
|
@@ -136,8 +142,6 @@ export interface SpecTopic {
|
|
|
136
142
|
export interface Spec {
|
|
137
143
|
kinds: Record<string, SpecKind>
|
|
138
144
|
topics: Record<string, SpecTopic>
|
|
139
|
-
/** one session holds the dispatcher role and routes what is raised */
|
|
140
|
-
dispatcher: boolean
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
/** the kinds every repo has, whatever its unit declares */
|
|
@@ -147,7 +151,7 @@ import { HOUSE_KINDS as BUILTIN_KINDS } from './kinds.ts'
|
|
|
147
151
|
import { settlingOf } from './settle.ts'
|
|
148
152
|
import { IN_BACKGROUND, WATCH } from './inbox-hook.ts'
|
|
149
153
|
|
|
150
|
-
export const NO_SPEC: Spec = { kinds: {}, topics: {}
|
|
154
|
+
export const NO_SPEC: Spec = { kinds: {}, topics: {} }
|
|
151
155
|
|
|
152
156
|
/** the words the list's subject filter shows; a kind no unit names shows its own name */
|
|
153
157
|
export const subjectLabel = (kind: string, spec: Spec = NO_SPEC): string => (spec.kinds[kind] ?? BUILTIN_KINDS[kind])?.label ?? kind
|
|
@@ -172,7 +176,7 @@ const canonical = new Map<string, string | null>()
|
|
|
172
176
|
|
|
173
177
|
/** an address in its one form, null when it is none (wiki tools/shipkit/threads-store.md, Addresses): trimmed and
|
|
174
178
|
* lowercased, no space around the colon, no empty or trailing `/`; a cut's file is its cut, a bare kept version the main
|
|
175
|
-
* cut (`trailer:x/v15`)
|
|
179
|
+
* cut (`trailer:x/v15`). Every address written, read or compared goes through it */
|
|
176
180
|
export function canonicalAddress(raw: string): string | null {
|
|
177
181
|
const held = canonical.get(raw)
|
|
178
182
|
if (held !== undefined) return held
|
|
@@ -192,9 +196,6 @@ export function canonicalAddress(raw: string): string | null {
|
|
|
192
196
|
// an ask is named by its file: `ask:<id>.md` and `ask:<id>` are one thread
|
|
193
197
|
if (kind === 'ask') key = key.replace(/\.md$/, '')
|
|
194
198
|
let out: string | null = `${kind}:${key}`
|
|
195
|
-
if (out === 'page:review' || out.startsWith('page:review/')) out = `page:threads${out.slice('page:review'.length)}`
|
|
196
|
-
// a conversation in words is one kind: a thread an advisor's proposal opened was `topic:<slug>`
|
|
197
|
-
if (out.startsWith('topic:')) out = `talk:${out.slice('topic:'.length)}`
|
|
198
199
|
if (!/^[a-z][a-z0-9-]*$/.test(kind) || key === '' || /\s/.test(key) || !ADDRESS_RE.test(out)) out = null
|
|
199
200
|
canonical.set(raw, out)
|
|
200
201
|
return out
|
|
@@ -665,17 +666,6 @@ export const viewTag = (n: number, i: number): string => `${n}.${viewNo(i)}`
|
|
|
665
666
|
/** a view's name as the page and the CLI show it: its label, or « view 2 » */
|
|
666
667
|
export const viewName = (v: ReviewView | undefined, i: number): string => v?.label || `view ${viewNo(i)}`
|
|
667
668
|
|
|
668
|
-
/** a view named by its label, else by its number (`2`), else by the letter it had before (`B`); throws naming every view
|
|
669
|
-
* when none matches */
|
|
670
|
-
export function viewIndexOf(views: readonly { label: string }[], ref: string): number {
|
|
671
|
-
const r = ref.trim()
|
|
672
|
-
const byLabel = views.findIndex((v) => v.label === r)
|
|
673
|
-
if (r !== '' && byLabel >= 0) return byLabel
|
|
674
|
-
const n = viewRef(r)
|
|
675
|
-
if (n >= 0 && n < views.length) return n
|
|
676
|
-
throw new Error(`« ${ref} » names no view: ${views.map((v, i) => `${viewNo(i)}${v.label ? ` "${v.label}"` : ''}`).join(', ')}`)
|
|
677
|
-
}
|
|
678
|
-
|
|
679
669
|
/** every media file an item's views name: images, pairs, clips and their posters, sounds and their waveforms, tiles */
|
|
680
670
|
export function viewFilesOf(i: Item): string[] {
|
|
681
671
|
return i.views.flatMap((v) => {
|
|
@@ -722,13 +712,58 @@ export interface Rect {
|
|
|
722
712
|
nodes?: string[]
|
|
723
713
|
}
|
|
724
714
|
|
|
725
|
-
/**
|
|
726
|
-
*
|
|
727
|
-
|
|
715
|
+
/** the owner's five tones, or no answer (wiki tools/shipkit/threads.md, The five tones): ok, ok with a fix, rework (redo
|
|
716
|
+
* it, same direction), wrong direction (stop, rethink, ask before building), your call (the agent decides if it still
|
|
717
|
+
* holds), no answer (that request leaves his turn, nothing else changes, no agent wakes). `approved-with-fix` counts as
|
|
718
|
+
* approved: its comment and rectangles are a small follow up; `archived` is set aside with no verdict, so it asks
|
|
719
|
+
* nothing of the agent */
|
|
720
|
+
export const STATUSES = ['approved', 'approved-with-fix', 'rework', 'wrong-direction', 'your-call', 'no-answer', 'archived'] as const
|
|
728
721
|
export type ReviewStatus = (typeof STATUSES)[number]
|
|
729
722
|
|
|
723
|
+
/** a status an older store wrote, read as the tone it meant and never written again: « rejected » asked a new version
|
|
724
|
+
* in the same thread, which is a rework */
|
|
725
|
+
const LEGACY_STATUS: Readonly<Record<string, ReviewStatus>> = { rejected: 'rework' }
|
|
726
|
+
|
|
727
|
+
/** a stored status as this code reads it: an old word as its tone, any other value as it is */
|
|
728
|
+
export const statusRead = (s: unknown): unknown => (typeof s === 'string' ? (LEGACY_STATUS[s] ?? s) : s)
|
|
729
|
+
|
|
730
|
+
/** a message read from the store with its old status words as their tones: its verdict and its reactions' */
|
|
731
|
+
export function upgradeMessage(m: Message): Message {
|
|
732
|
+
const v = m.verdict === undefined ? undefined : (statusRead(m.verdict) as ReviewStatus)
|
|
733
|
+
const old = (r: ReviewReaction): boolean => r.status !== undefined && statusRead(r.status) !== r.status
|
|
734
|
+
if (v === m.verdict && !(m.reactions ?? []).some(old)) return m
|
|
735
|
+
return {
|
|
736
|
+
...m,
|
|
737
|
+
...(v !== undefined ? { verdict: v } : {}),
|
|
738
|
+
...(m.reactions ? { reactions: m.reactions.map((r) => (old(r) ? { ...r, status: statusRead(r.status) as ReviewStatus } : r)) } : {}),
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
730
742
|
export const isApproved = (s: ReviewStatus): boolean => s === 'approved' || s === 'approved-with-fix'
|
|
731
743
|
|
|
744
|
+
/** the tones that give the version back to its agent with work owed: every one but ok and archived */
|
|
745
|
+
export const OWES_WORK: ReadonlySet<ReviewStatus> = new Set(['approved-with-fix', 'rework', 'wrong-direction', 'your-call'])
|
|
746
|
+
|
|
747
|
+
/** the tones a choice question takes besides a pick and a pick with a remark: « none of these » (a rework, the owner's
|
|
748
|
+
* words), « your call » (the agent's pick if it still holds), « no answer »; `wrong-direction` the hub no longer offers on a
|
|
749
|
+
* question, kept to read and write the rows that hold it */
|
|
750
|
+
export const QUESTION_TONES = ['rework', 'wrong-direction', 'your-call', 'no-answer'] as const satisfies readonly ReviewStatus[]
|
|
751
|
+
export type QuestionTone = (typeof QUESTION_TONES)[number]
|
|
752
|
+
|
|
753
|
+
/** what a tone that owes work asks of the agent, as its watch and the inbox say it: ` (<ask>)`, '' for ok or archived */
|
|
754
|
+
export const toneAskTail = (s: ReviewStatus, id: string): string => (OWES_WORK.has(s) ? ` (${TONE_ASKS[s].replace('<id>', id)})` : '')
|
|
755
|
+
|
|
756
|
+
/** what each tone asks of the agent, as its watch and the inbox say it */
|
|
757
|
+
export const TONE_ASKS: Record<ReviewStatus, string> = {
|
|
758
|
+
approved: 'nothing owed: he is ok with it',
|
|
759
|
+
'approved-with-fix': 'fix what the owner says and keep the rest, then sk thread fixed',
|
|
760
|
+
rework: 'redo it in the same direction, then post the next version',
|
|
761
|
+
'wrong-direction': 'stop: the direction is wrong; rethink it and, unless the owner named the new one, ask (sk thread ask) before you build again',
|
|
762
|
+
'your-call': 'decide yourself: if the ask still holds, do what you judge best, else drop it; then say what you chose (sk thread fixed <id> "<what you chose>")',
|
|
763
|
+
'no-answer': 'nothing owed: he left it unanswered',
|
|
764
|
+
archived: 'nothing owed: set aside',
|
|
765
|
+
}
|
|
766
|
+
|
|
732
767
|
/** the owner's reaction to one view, to one tile of a gallery view, or to one message of a draft version; one per view,
|
|
733
768
|
* tile or message */
|
|
734
769
|
export interface ReviewReaction {
|
|
@@ -740,8 +775,6 @@ export interface ReviewReaction {
|
|
|
740
775
|
comment: string
|
|
741
776
|
/** his score of the view, 1 to STARS */
|
|
742
777
|
stars?: number
|
|
743
|
-
/** a variant tile he keeps for its row: at most one a row */
|
|
744
|
-
picked?: true
|
|
745
778
|
}
|
|
746
779
|
|
|
747
780
|
/** a state change, a read mark (`seen`, with the ids it read in `of`), a take (`take`: an agent holds the thread
|
|
@@ -753,6 +786,11 @@ export const handedOver = (m: Pick<Message, 'op' | 'from'>): boolean => m.op ===
|
|
|
753
786
|
|
|
754
787
|
export const OPS = ['dispatch', 'ask', 'answer', 'reassign', 'claim', 'release', 'blocked', 'fixed', 'done', 'wontfix', 'drop', 'withdraw', 'reopen', 'ready', 'seen', 'take', 'working'] as const
|
|
755
788
|
export type Op = (typeof OPS)[number]
|
|
789
|
+
/** the ops old threads hold and nothing writes now (the dispatcher's routing, its question and his answer to it, a
|
|
790
|
+
* worker's block): read as history by stateOf, never an act */
|
|
791
|
+
export type HistoryOp = 'dispatch' | 'ask' | 'answer' | 'reassign' | 'blocked' | 'drop'
|
|
792
|
+
/** the ops an act writes */
|
|
793
|
+
export type ActOp = Exclude<Op, HistoryOp>
|
|
756
794
|
|
|
757
795
|
/** what an agent's update says of the work, at a glance: still broken, better, or fixed (it asks the owner's verdict again) */
|
|
758
796
|
export const UPDATE_STATES = ['broken', 'better', 'fixed'] as const
|
|
@@ -798,7 +836,7 @@ export interface Message {
|
|
|
798
836
|
op?: Op
|
|
799
837
|
/** the op's reason or answer */
|
|
800
838
|
note?: string
|
|
801
|
-
/** `dispatch
|
|
839
|
+
/** `dispatch`, in an old thread: where it went */
|
|
802
840
|
topic?: string
|
|
803
841
|
/** `seen`: the messages it read */
|
|
804
842
|
of?: string[]
|
|
@@ -837,14 +875,22 @@ export interface Message {
|
|
|
837
875
|
/** the owner's own save of the thread's object from the hub's editor (review/doc-save.ts saveDoc): `of` the version it
|
|
838
876
|
* made (an item, or an ask's instructions message), or the version waiting on the owner's verdict that the save went over;
|
|
839
877
|
* its line of what changed in `text`, its changed lines in `diff` (`- ` gone, `+ ` new). His act, never the agent's:
|
|
840
|
-
* it wakes the thread's holder (
|
|
878
|
+
* it wakes the thread's holder (thread-events.ts `edit`). His saves of one burst are one wake (doc-save.ts ownerEdit): `base`
|
|
841
879
|
* the text before a burst's first save; a later save of it lands beside that first edit, its diff from `base`, and
|
|
842
|
-
* `folds` names the edit it takes the place of, a trace from then on (
|
|
880
|
+
* `folds` names the edit it takes the place of, a trace from then on (thread-events.ts `edit-folded`) */
|
|
843
881
|
edit?: { of: string; diff: string[]; base?: string; folds?: string }
|
|
844
882
|
/** a thread set aside until `until` (an ISO time), his from the hub or an agent's when it posts; null brings it back */
|
|
845
883
|
snooze?: { until: string | null }
|
|
846
884
|
/** an agent's message that brings back a thread set aside (wiki tools/shipkit/threads-asks.md, Snooze) */
|
|
847
885
|
urgent?: true
|
|
886
|
+
/** the thread renamed on purpose (`sk thread rename`, his edit of the head's title): its name before and after */
|
|
887
|
+
rename?: { from: string; to: string }
|
|
888
|
+
/** the thread moved whole from one repo's store to another's (review/move.ts), by the owner: the repo names, the
|
|
889
|
+
* trace line on both sides; the acts before it hold nothing, so the repo it came to hears it */
|
|
890
|
+
moved?: { from: string; to: string }
|
|
891
|
+
/** an agent's `done` that closes the thread it finished (`sk thread close`, review/close.ts agentClose): `thread` on
|
|
892
|
+
* its head, the trace line; `version` on a version that waited on the owner's verdict, which then needs none */
|
|
893
|
+
closes?: 'thread' | 'version'
|
|
848
894
|
/** his answer to the question or the proposal `re` names: the option he clicked, or « apply » (an edit his `text`) */
|
|
849
895
|
answer?: MessageAnswer
|
|
850
896
|
/** the agent's object of the same thread (a question, a change, its words) this newer one supersedes, by its message
|
|
@@ -859,6 +905,11 @@ export interface Message {
|
|
|
859
905
|
/** an agent's message that waits for the owner's verdict; the owner's answer is the owner's message with `verdict` and `re` naming it
|
|
860
906
|
* (review/verdict-items.ts) */
|
|
861
907
|
asksVerdict?: true
|
|
908
|
+
/** an agent's recap of the thread (review/recap.ts): its four sections in `text`, asking the owner's verdict; once he
|
|
909
|
+
* accepts it, readers start at it */
|
|
910
|
+
recap?: true
|
|
911
|
+
/** the owner asks the thread's holder for a recap (the hub's « recap »): the owner's words in `text`, a word that asks work */
|
|
912
|
+
recapAsk?: true
|
|
862
913
|
/** the machine's: an attached object's hold flipped (review/holds.ts), its words in `text` */
|
|
863
914
|
hold?: { address: string; held: boolean; sha?: string; ahead?: number }
|
|
864
915
|
/** the owner's close of a held thread: the holds it releases, by address */
|
|
@@ -873,7 +924,7 @@ export interface Message {
|
|
|
873
924
|
/** an agent's words past the wall bound on purpose (review/reply-guards.ts): why, drawn as a quiet mark under them */
|
|
874
925
|
long?: string
|
|
875
926
|
/** on a `working`: the agent promises the thread's next version by `until` (an ISO time); the version before it asks
|
|
876
|
-
* no verdict while the promise stands, and a promise past its time reads late (review/
|
|
927
|
+
* no verdict while the promise stands, and a promise past its time reads late (review/thread-state.ts ThreadState next) */
|
|
877
928
|
next?: { until: string }
|
|
878
929
|
/** the send's own id, made by the page that sent it: a send again with the same id is that message, never a second
|
|
879
930
|
* one (store.ts addMessage) */
|
|
@@ -917,8 +968,23 @@ export interface MessageAsk {
|
|
|
917
968
|
choices?: (StepChoice | null)[]
|
|
918
969
|
/** a secret's name in the house secret manager; `login`: an account goes with it */
|
|
919
970
|
secret?: { name: string; login?: true }
|
|
971
|
+
/** a choice that is one row of a question with a row per thing (`sk thread ask --row`): the rows share `group` and
|
|
972
|
+
* draw as one question, row `i` of `n` names its thing in `label`; each row is answered alone */
|
|
973
|
+
row?: AskRow
|
|
974
|
+
/** a question that suggests moving the thread to the repo `to` (`sk thread suggest-move`): his click on option 0
|
|
975
|
+
* moves it there (review/move.ts moveOnAnswer), option 1 keeps it */
|
|
976
|
+
move?: { to: string }
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
export interface AskRow {
|
|
980
|
+
group: string
|
|
981
|
+
i: number
|
|
982
|
+
n: number
|
|
983
|
+
label: string
|
|
920
984
|
}
|
|
921
985
|
|
|
986
|
+
export const ROW_GROUP_RE = /^[\w-]{4,64}$/
|
|
987
|
+
|
|
922
988
|
/** how one field of a proposed change draws: a house kind (review/kinds.ts) */
|
|
923
989
|
export { DIFF_TYPES, type DiffType } from './kinds.ts'
|
|
924
990
|
import { DIFF_TYPES, sniffKind, type DiffType } from './kinds.ts'
|
|
@@ -983,33 +1049,11 @@ export function appliedFields(thread: readonly Message[], m: Message): Map<strin
|
|
|
983
1049
|
return out
|
|
984
1050
|
}
|
|
985
1051
|
|
|
986
|
-
/**
|
|
987
|
-
*
|
|
988
|
-
const takesWords = (m: Message): boolean =>
|
|
989
|
-
partyOf(m.who) === 'agent' && m.step === undefined && m.instructions === undefined && (m.propose !== undefined || m.asksVerdict === true || (m.ask !== undefined && !['checklist', 'secret', 'file'].includes(m.ask.kind ?? 'choice')))
|
|
990
|
-
|
|
991
|
-
const asksHim = (m: Message | undefined): boolean => m !== undefined && partyOf(m.who) === 'agent' && (m.ask !== undefined || m.propose !== undefined || m.asksVerdict === true)
|
|
992
|
-
|
|
993
|
-
/** his first plain words on the item after `m` (no click, no verdict, naming no other object it asks), before any answer
|
|
994
|
-
* that names `m`: his answer to it in words (wiki tools/shipkit/threads-asks.md, Words answer it). Derived, never stored,
|
|
995
|
-
* so every thread reads it alike; a click of his after them still wins. Words of a player or an advisor never answer */
|
|
996
|
-
export function wordsAnswerOf(thread: readonly Message[], m: Message): Message | undefined {
|
|
997
|
-
if (!takesWords(m)) return undefined
|
|
998
|
-
const i = thread.findIndex((y) => y.id === m.id)
|
|
999
|
-
if (i < 0) return undefined
|
|
1000
|
-
for (const y of thread.slice(i + 1)) {
|
|
1001
|
-
if (y.re === m.id && partyOf(y.who) === 'owner') return undefined
|
|
1002
|
-
if (y.who !== 'owner' || y.op !== undefined || y.answer !== undefined || y.verdict !== undefined || y.rate !== undefined || y.edit !== undefined || y.carried !== undefined || y.action !== undefined || y.askState !== undefined || y.snooze !== undefined || y.laneAsk !== undefined || !y.text?.trim()) continue
|
|
1003
|
-
if (y.re !== undefined && asksHim(thread.find((z) => z.id === y.re))) continue
|
|
1004
|
-
return y
|
|
1005
|
-
}
|
|
1006
|
-
return undefined
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
/** a proposal waits on him until each of its fields is applied, or a message of the owner's with words names it */
|
|
1052
|
+
/** a proposal waits on the owner until each of its fields is applied, or the owner's words in its own box name it (`re`); a plain reply
|
|
1053
|
+
* of his after it answers nothing (wiki tools/shipkit/threads-asks.md, Answered in its control only) */
|
|
1010
1054
|
export function proposeOpen(thread: readonly Message[], m: Message): boolean {
|
|
1011
1055
|
if (!m.propose) return false
|
|
1012
|
-
if (thread.some((y) => y.re === m.id && y.answer === undefined && partyOf(y.who) === 'owner')
|
|
1056
|
+
if (thread.some((y) => y.re === m.id && y.answer === undefined && partyOf(y.who) === 'owner')) return false
|
|
1013
1057
|
return appliedFields(thread, m).size < proposeFields(m.propose).length
|
|
1014
1058
|
}
|
|
1015
1059
|
|
|
@@ -1256,7 +1300,7 @@ function verdictOfItem(x: ReviewItem): Verdict | null {
|
|
|
1256
1300
|
settled = flip ? n : null
|
|
1257
1301
|
if (flip) [m, text, rects] = [undefined, undefined, undefined]
|
|
1258
1302
|
} else if (n.op === 'reopen' || isFixedUpdate(n)) [m, text, rects, settled] = [undefined, undefined, undefined, null]
|
|
1259
|
-
else if (isVersionVerdict(n)) {
|
|
1303
|
+
else if (isVersionVerdict(n) && n.verdict !== 'no-answer') {
|
|
1260
1304
|
if (m?.verdict !== n.verdict) [text, rects] = [undefined, undefined]
|
|
1261
1305
|
m = n
|
|
1262
1306
|
settled = null
|
|
@@ -1279,6 +1323,17 @@ function verdictOfItem(x: ReviewItem): Verdict | null {
|
|
|
1279
1323
|
}
|
|
1280
1324
|
}
|
|
1281
1325
|
|
|
1326
|
+
/** his « no answer » on the version, while it stands: no verdict, reopen or fixed update came after it. It takes the
|
|
1327
|
+
* verdict request off his turn and nothing else: the version keeps its state and its verdict, the thread stays open */
|
|
1328
|
+
export function leftUnansweredOf(x: ReviewItem): Message | null {
|
|
1329
|
+
let left: Message | null = null
|
|
1330
|
+
for (const n of x.thread) {
|
|
1331
|
+
if (n.op === 'reopen' || isFixedUpdate(n)) left = null
|
|
1332
|
+
else if (isVersionVerdict(n)) left = n.verdict === 'no-answer' ? n : null
|
|
1333
|
+
}
|
|
1334
|
+
return left
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1282
1337
|
/** a person's delete of their own words: a `withdraw` that names them in `re`, written by their author (the owner, or
|
|
1283
1338
|
* an advisor by their id); an agent's withdraw is never one (review/supersede.ts) */
|
|
1284
1339
|
export const deletes = (w: Message, m: Message): boolean =>
|
|
@@ -1307,14 +1362,18 @@ export const itemWithdrawOf = (x: ReviewItem): Message | undefined => x.thread.f
|
|
|
1307
1362
|
export const withdrawnOf = (x: ReviewItem): string | undefined => itemWithdrawOf(x)?.note
|
|
1308
1363
|
|
|
1309
1364
|
/** what the list says of an item: an agent's version by the owner's verdict, what he or a player raised by its state */
|
|
1310
|
-
export type ShownStatus = 'pending' | 'wip' | ReviewStatus | 'superseded' | 'withdrawn' | 'raised' | 'fixed' | 'wontfix' | 'rated'
|
|
1365
|
+
export type ShownStatus = 'pending' | 'wip' | ReviewStatus | 'superseded' | 'withdrawn' | 'raised' | 'fixed' | 'wontfix' | 'rated' | 'closed'
|
|
1311
1366
|
|
|
1312
1367
|
export const STATUS_LABEL: Record<ShownStatus, string> = {
|
|
1313
1368
|
pending: 'waiting',
|
|
1369
|
+
closed: 'no verdict needed',
|
|
1314
1370
|
wip: 'in progress',
|
|
1315
1371
|
approved: 'approved',
|
|
1316
1372
|
'approved-with-fix': 'ok with a fix',
|
|
1317
|
-
|
|
1373
|
+
rework: 'rework',
|
|
1374
|
+
'wrong-direction': 'wrong direction',
|
|
1375
|
+
'your-call': 'your call',
|
|
1376
|
+
'no-answer': 'no answer',
|
|
1318
1377
|
archived: 'not doing it',
|
|
1319
1378
|
superseded: 'replaced',
|
|
1320
1379
|
withdrawn: 'withdrawn',
|
|
@@ -1372,7 +1431,7 @@ export const ownSave = (i: Pick<Item, 'saved'>): boolean => i.saved?.by === 'own
|
|
|
1372
1431
|
export const asksNoVerdict = (i: Item): boolean => isOpening(i) || ownSave(i)
|
|
1373
1432
|
|
|
1374
1433
|
/** where an item starts: an agent's version asks for the owner's verdict (a draft waits); what he raises from a tool that named
|
|
1375
|
-
* its topic (the trailer view: `film`) is open, else
|
|
1434
|
+
* its topic (the trailer view: `film`) is open, else new, for any worker to claim; an auto rule's item is open */
|
|
1376
1435
|
const startOf = (i: Item): ItemState =>
|
|
1377
1436
|
ownSave(i)
|
|
1378
1437
|
? { state: 'closed', why: 'fixed' }
|
|
@@ -1403,6 +1462,8 @@ function stateOfItem(x: ReviewItem, superseded: boolean): ItemState {
|
|
|
1403
1462
|
given = s
|
|
1404
1463
|
continue
|
|
1405
1464
|
}
|
|
1465
|
+
// his « no answer » on a version changes nothing of its state (leftUnansweredOf)
|
|
1466
|
+
if (m.verdict === 'no-answer' && isVersionVerdict(m)) continue
|
|
1406
1467
|
if (m.verdict !== undefined && isVersionVerdict(m)) {
|
|
1407
1468
|
const v = m.verdict
|
|
1408
1469
|
// « fix » and « no » owe the lane work: reading the verdict is never doing it (done, wontfix or a new version closes it)
|
|
@@ -1425,7 +1486,7 @@ function stateOfItem(x: ReviewItem, superseded: boolean): ItemState {
|
|
|
1425
1486
|
} else if (s.state === 'asks') s = { ...keep, state: 'draft' }
|
|
1426
1487
|
continue
|
|
1427
1488
|
}
|
|
1428
|
-
// the owner's words on a question answer it:
|
|
1489
|
+
// the owner's words on a question of an old thread answer it: the item is new again
|
|
1429
1490
|
if (m.op === undefined && partyOf(m.who) === 'owner' && m.text !== undefined && s.state === 'question') {
|
|
1430
1491
|
s = { ...keep, state: 'new' }
|
|
1431
1492
|
continue
|
|
@@ -1458,7 +1519,7 @@ function stateOfItem(x: ReviewItem, superseded: boolean): ItemState {
|
|
|
1458
1519
|
s = { ...keep, state: 'closed', why: 'fixed' }
|
|
1459
1520
|
break
|
|
1460
1521
|
case 'done':
|
|
1461
|
-
s = { ...keep, state: 'closed', why:
|
|
1522
|
+
s = { ...keep, state: 'closed', why: ((v) => (v === 'approved-with-fix' || v === 'your-call' ? v : 'fixed'))(verdictOf(x)?.status) }
|
|
1462
1523
|
break
|
|
1463
1524
|
case 'wontfix':
|
|
1464
1525
|
s = { ...keep, state: 'closed', why: 'wontfix' }
|
|
@@ -1486,16 +1547,10 @@ function stateOfItem(x: ReviewItem, superseded: boolean): ItemState {
|
|
|
1486
1547
|
/** a version in work: a draft on a live shot, or an agent's version its latest update calls still broken or better */
|
|
1487
1548
|
export const inWork = (x: ReviewItem): boolean => stateOf(x, false).state === 'draft'
|
|
1488
1549
|
|
|
1489
|
-
/** the states each
|
|
1490
|
-
const FROM: Record<Exclude<
|
|
1491
|
-
dispatch: ['new', 'blocked'],
|
|
1492
|
-
ask: ['new', 'blocked'],
|
|
1493
|
-
answer: ['question'],
|
|
1494
|
-
reassign: ['open', 'claimed'],
|
|
1495
|
-
drop: ['new', 'question', 'open', 'blocked'],
|
|
1550
|
+
/** the states each act leaves from; a raised item still new is claimed, fixed or closed as it is */
|
|
1551
|
+
const FROM: Record<Exclude<ActOp, 'seen' | 'take' | 'working'>, readonly State[]> = {
|
|
1496
1552
|
claim: ['open', 'claimed', 'closed', 'blocked'],
|
|
1497
1553
|
release: ['claimed'],
|
|
1498
|
-
blocked: ['claimed'],
|
|
1499
1554
|
fixed: ['open', 'claimed', 'blocked'],
|
|
1500
1555
|
done: ['claimed'],
|
|
1501
1556
|
wontfix: ['open', 'claimed', 'blocked'],
|
|
@@ -1503,39 +1558,30 @@ const FROM: Record<Exclude<Op, 'seen' | 'take' | 'working'>, readonly State[]> =
|
|
|
1503
1558
|
reopen: ['closed', 'claimed'],
|
|
1504
1559
|
ready: ['draft'],
|
|
1505
1560
|
}
|
|
1506
|
-
const
|
|
1507
|
-
const WORKER_OPS = new Set<Op>(['release', 'blocked', 'fixed', 'done', 'wontfix'])
|
|
1561
|
+
const WORKER_OPS = new Set<Op>(['release', 'fixed', 'done', 'wontfix'])
|
|
1508
1562
|
|
|
1509
|
-
/** null when `who` may do `op` on an item in state `s`, else why not.
|
|
1510
|
-
*
|
|
1511
|
-
*
|
|
1512
|
-
|
|
1513
|
-
export function allowed(s: ItemState, op: Op, who: string, dispatcher: string | null, routed = true, holds = false): string | null {
|
|
1563
|
+
/** null when `who` may do `op` on an item in state `s`, else why not. A worker takes a raised item as it is and acts on
|
|
1564
|
+
* its own claim, the owner may act over a claim; `holds`: the caller holds the item's thread or is the session of the
|
|
1565
|
+
* lane that does */
|
|
1566
|
+
export function allowed(s: ItemState, op: ActOp, who: string, holds = false): string | null {
|
|
1514
1567
|
if (op === 'seen' || op === 'take' || op === 'working') return op !== 'seen' && who === 'owner' ? `an agent ${op === 'take' ? 'takes a thread' : 'says it is on it'}, never the owner` : null
|
|
1515
|
-
if (op === '
|
|
1516
|
-
if (
|
|
1517
|
-
if (!routed) return 'this repo routes nothing: its review unit declares no dispatcher'
|
|
1518
|
-
if (dispatcher === null) return 'nobody holds the dispatcher role: sk thread dispatcher --as <name>'
|
|
1519
|
-
if (who !== dispatcher) return `only the dispatcher (${dispatcher}) may ${op}`
|
|
1520
|
-
}
|
|
1521
|
-
if (!routed && s.state === 'new' && (op === 'claim' || op === 'fixed' || op === 'wontfix')) return op === 'claim' && who === 'owner' ? 'a worker claims, never the owner' : null
|
|
1522
|
-
if (op === 'claim' && (who === 'owner' || who === dispatcher)) return `a worker claims, never ${who === 'owner' ? 'the owner' : 'the dispatcher'}`
|
|
1568
|
+
if (op === 'claim' && who === 'owner') return 'a worker claims, never the owner'
|
|
1569
|
+
if (s.state === 'new' && (op === 'claim' || op === 'fixed' || op === 'wontfix')) return null
|
|
1523
1570
|
// `holds`: the caller holds the thread or is its holder's session (review/parties.ts maySee), so a lane's claim never
|
|
1524
1571
|
// locks its session out of its own thread
|
|
1525
1572
|
if (WORKER_OPS.has(op) && who !== 'owner' && !holds && s.worker !== undefined && s.worker !== who) return `claimed by ${s.worker}, not by ${who}`
|
|
1526
1573
|
if (op === 'claim' && s.state === 'claimed' && s.since !== undefined && s.worker !== who) return `already claimed by ${s.worker}: release it first (--as ${s.worker})`
|
|
1527
|
-
if (op === 'claim' && s.state === 'blocked' && s.worker !== undefined && s.worker !== who) return `blocked by ${s.worker}, who takes it back (--as ${s.worker})
|
|
1528
|
-
if (op === 'claim' && s.state === 'closed' &&
|
|
1529
|
-
return `claim needs open, or a thread he answered « fix » or «
|
|
1574
|
+
if (op === 'claim' && s.state === 'blocked' && s.worker !== undefined && s.worker !== who) return `blocked by ${s.worker}, who takes it back (--as ${s.worker})`
|
|
1575
|
+
if (op === 'claim' && s.state === 'closed' && !OWES_WORK.has(s.why as ReviewStatus))
|
|
1576
|
+
return `claim needs open, or a thread he answered « fix », « rework », « wrong direction » or « your call », it is closed (${s.why})`
|
|
1530
1577
|
if (!FROM[op].includes(s.state)) {
|
|
1531
1578
|
if (op === 'claim' && s.state === 'claimed') return `already claimed by ${s.worker ?? 'an agent'}`
|
|
1532
|
-
if (op === 'claim' && s.state === 'new') return 'not dispatched yet: only the dispatcher sends an item to a topic'
|
|
1533
1579
|
return `${op} needs ${FROM[op].join(' or ')}, it is ${s.state}${s.why ? ` (${s.why})` : ''}`
|
|
1534
1580
|
}
|
|
1535
1581
|
return null
|
|
1536
1582
|
}
|
|
1537
1583
|
|
|
1538
|
-
/** a claim with no message for this long is stale:
|
|
1584
|
+
/** a claim with no message for this long is stale: a watch says so, a rework stops showing */
|
|
1539
1585
|
export const STALE_CLAIM_MS = 2 * 60 * 60 * 1000
|
|
1540
1586
|
|
|
1541
1587
|
/** how long a `working` line says an agent is on it with nothing since (wiki tools/shipkit/threads-how-it-fits.md, Read
|
|
@@ -1584,14 +1630,14 @@ export const coversItem = (f: WatchFilter, x: ReviewItem): boolean =>
|
|
|
1584
1630
|
(f.session === null || (x.item.origin.by === 'agent' && x.item.origin.session === f.session)) && (f.lane === null || laneOf(x) === f.lane)
|
|
1585
1631
|
|
|
1586
1632
|
/** why a bare watch may not start: another one lives in the repo, so a verdict would reach two sessions. null when
|
|
1587
|
-
* none does. A repo keeps one
|
|
1633
|
+
* none does. A repo keeps one; every other session watches its own items or its lane's */
|
|
1588
1634
|
export function bareWatchTaken(live: readonly Watcher[], self: number): string | null {
|
|
1589
1635
|
const other = live.find((w) => w.pid !== self && w.lane === null && w.session === null)
|
|
1590
|
-
return other ? `a watch of every thread already runs (pid ${other.pid}): a repo keeps one
|
|
1636
|
+
return other ? `a watch of every thread already runs (pid ${other.pid}): a repo keeps one. Yours: sk thread watch --mine, or --lane <id>` : null
|
|
1591
1637
|
}
|
|
1592
1638
|
|
|
1593
|
-
/** what `
|
|
1594
|
-
* unfiltered watch (
|
|
1639
|
+
/** what `sk thread post` says when no live watch of the item's own session will read his answer, else null: an
|
|
1640
|
+
* unfiltered watch (another session) hears it for someone else. A lane never arms a watch, its session
|
|
1595
1641
|
* hears its threads (wiki tools/shipkit/threads-essentials.md), so a lane is told nothing */
|
|
1596
1642
|
export function unheardLine(item: Item, watchers: readonly Watcher[]): string | null {
|
|
1597
1643
|
const o = item.origin
|
|
@@ -1609,12 +1655,12 @@ export const UNTAKEN_AGAIN_MS = STALE_CLAIM_MS
|
|
|
1609
1655
|
|
|
1610
1656
|
/** why an item waits on the agents and nobody holds it, else null; `superseded`: a later version follows it; `heard`: a
|
|
1611
1657
|
* live watch hears its thread's holder (threads.ts listenersOf) */
|
|
1612
|
-
export function untakenOf(x: ReviewItem, superseded: boolean, heard: boolean, now: Date
|
|
1658
|
+
export function untakenOf(x: ReviewItem, superseded: boolean, heard: boolean, now: Date): string | null {
|
|
1613
1659
|
if (superseded) return null
|
|
1614
1660
|
const quiet = now.getTime() - Date.parse(x.thread.at(-1)?.at ?? x.item.created)
|
|
1615
1661
|
if (quiet < UNTAKEN_GRACE_MS) return null
|
|
1616
1662
|
const s = stateOf(x, false)
|
|
1617
|
-
if (s.state === 'new') return
|
|
1663
|
+
if (s.state === 'new') return 'raised, nobody claimed it'
|
|
1618
1664
|
if (s.state === 'open') return `raised${s.topic ? ` on ${s.topic}` : ''}, nobody claimed it`
|
|
1619
1665
|
if (s.state !== 'claimed') return null
|
|
1620
1666
|
if (s.since !== undefined) return quiet > STALE_CLAIM_MS ? `${s.worker ?? 'its'} claim went stale` : null
|
|
@@ -1793,9 +1839,8 @@ export function messageProblems(v: unknown, name: string): string[] {
|
|
|
1793
1839
|
const out: string[] = []
|
|
1794
1840
|
if (v.id !== name) out.push(`id: ${String(v.id)} is not its file name ${name}`)
|
|
1795
1841
|
if (typeof v.at !== 'string' || typeof v.who !== 'string' || v.who === '') out.push('at, who: texts')
|
|
1796
|
-
if ('seen' in v) out.push('seen: a message of the old shape, before the one store')
|
|
1797
1842
|
if (v.op !== undefined && !OPS.includes(v.op as Op)) out.push(`op: one of ${OPS.join(', ')}`)
|
|
1798
|
-
if (v.verdict !== undefined && !STATUSES.includes(v.verdict as ReviewStatus)) out.push(`verdict: one of ${STATUSES.join(', ')}`)
|
|
1843
|
+
if (v.verdict !== undefined && !STATUSES.includes(statusRead(v.verdict) as ReviewStatus)) out.push(`verdict: one of ${STATUSES.join(', ')}`)
|
|
1799
1844
|
for (const k of ['text', 'image', 'note']) if (v[k] !== undefined && typeof v[k] !== 'string') out.push(`${k}: a text`)
|
|
1800
1845
|
if (v.files !== undefined && !(Array.isArray(v.files) && v.files.length >= 1 && v.files.length <= MESSAGE_FILES_MAX && v.files.every((f, i) => !fileProblem(f, name, i))))
|
|
1801
1846
|
out.push(`files: 1 to ${MESSAGE_FILES_MAX} of { file: <id>-f<n>.<ext> in order, name: a clean file name, size, type }`)
|
|
@@ -1822,12 +1867,16 @@ export function messageProblems(v: unknown, name: string): string[] {
|
|
|
1822
1867
|
if (!texts || (a.options as unknown[]).length < 2 || (a.pick !== undefined && !(index(a.pick) && (a.pick as number) < (a.options as unknown[]).length)))
|
|
1823
1868
|
out.push('ask: { options: two texts or more, pick?: an option index }')
|
|
1824
1869
|
else if (a.views !== undefined && !(Array.isArray(a.views) && a.views.length === (a.options as unknown[]).length && a.views.every((x) => x === null || index(x)))) out.push('ask: views, one view index or null an option')
|
|
1870
|
+
else if (a.row !== undefined && !(obj(a.row) && typeof a.row.group === 'string' && ROW_GROUP_RE.test(a.row.group) && index(a.row.i) && Number.isInteger(a.row.n) && (a.row.i as number) < (a.row.n as number) && typeof a.row.label === 'string' && a.row.label.trim() !== ''))
|
|
1871
|
+
out.push('ask: row, { group, i, n: i below n, label: the thing it picks for }')
|
|
1872
|
+
else if (a.move !== undefined && !(obj(a.move) && typeof a.move.to === 'string' && /^[\w.-]+$/.test(a.move.to) && (a.options as unknown[]).length === 2)) out.push('ask: move, { to: a repo name }, on a choice of two options: move, keep')
|
|
1825
1873
|
} else if (kind === 'checklist') {
|
|
1826
1874
|
if (!texts || (a.options as unknown[]).length < 1 || (a.done !== undefined && !(Array.isArray(a.done) && a.done.every((x) => index(x) && (x as number) < (a.options as unknown[]).length))))
|
|
1827
1875
|
out.push('ask: a checklist, { options: its lines, one or more, done?: line indexes }')
|
|
1828
1876
|
else if (a.choices !== undefined && !(Array.isArray(a.choices) && a.choices.length === (a.options as unknown[]).length && v.instructions !== undefined && a.choices.every((c) => c === null || (obj(c) && Array.isArray(c.options) && c.options.length >= 2 && c.options.every((o) => typeof o === 'string' && o.trim() !== '') && (c.pick === undefined || (index(c.pick) && (c.pick as number) < c.options.length))))))
|
|
1829
1877
|
out.push("ask: choices, an instructions' steps only, one { options: two texts or more, pick? } or null a step")
|
|
1830
1878
|
} else if (!(Array.isArray(a.options) && a.options.length === 0)) out.push(`ask: a ${kind} question holds no options`)
|
|
1879
|
+
if (kind !== 'choice' && obj(a) && a.row !== undefined) out.push('ask: row, on a choice only')
|
|
1831
1880
|
if (kind === 'secret' && !(obj(a) && obj(a.secret) && typeof a.secret.name === 'string' && SECRET_NAME.test(a.secret.name) && (a.secret.login === undefined || a.secret.login === true)))
|
|
1832
1881
|
out.push('ask: a secret question names its secret, { secret: { name, login? } }')
|
|
1833
1882
|
if (typeof v.text !== 'string') out.push('ask: its question in text')
|
|
@@ -1869,6 +1918,8 @@ export function messageProblems(v: unknown, name: string): string[] {
|
|
|
1869
1918
|
if (v.replaces !== undefined && !(typeof v.replaces === 'string' && MESSAGE_RE.test(v.replaces))) out.push('replaces: the id of a message of the thread')
|
|
1870
1919
|
if (v.hold !== undefined && !(obj(v.hold) && typeof v.hold.address === 'string' && typeof v.hold.held === 'boolean' && (v.hold.sha === undefined || typeof v.hold.sha === 'string') && (v.hold.ahead === undefined || typeof v.hold.ahead === 'number') && typeof v.text === 'string')) out.push('hold: { address, held, sha?, ahead? } and its words in text')
|
|
1871
1920
|
if (v.laneAsk !== undefined && !(obj(v.laneAsk) && typeof v.laneAsk.for === 'string' && (v.laneAsk.session === undefined || typeof v.laneAsk.session === 'string') && v.who === 'owner')) out.push("laneAsk: { for, session? }, the owner's")
|
|
1921
|
+
if (v.recap !== undefined && !(v.recap === true && v.asksVerdict === true && typeof v.text === 'string' && v.who !== 'owner' && v.who !== 'player')) out.push("recap: true, an agent's words that ask the owner's verdict")
|
|
1922
|
+
if (v.recapAsk !== undefined && !(v.recapAsk === true && v.who === 'owner' && typeof v.text === 'string')) out.push("recapAsk: true, the owner's words")
|
|
1872
1923
|
if (v.unhold !== undefined && !(Array.isArray(v.unhold) && v.unhold.length > 0 && v.unhold.every((a) => typeof a === 'string'))) out.push('unhold: the addresses it releases')
|
|
1873
1924
|
if (v.askBar !== undefined && !(Array.isArray(v.askBar) && v.askBar.length > 0 && v.askBar.every((f) => typeof f === 'string' && MESSAGE_RE.test(f)))) out.push('askBar: the ids of messages of the thread')
|
|
1874
1925
|
if (v.instructions !== undefined) {
|
|
@@ -1881,7 +1932,10 @@ export function messageProblems(v: unknown, name: string): string[] {
|
|
|
1881
1932
|
}
|
|
1882
1933
|
if (v.to !== undefined && !(Array.isArray(v.to) && v.to.length > 0 && v.to.every(mentionOk) && typeof v.text === 'string' && v.who === 'owner')) out.push("to: the owner's words, one or more { name, lane, session? }, { name, session } or { name, advisor }")
|
|
1883
1934
|
if (v.mute !== undefined && !(typeof v.mute === 'boolean' && v.who === 'owner')) out.push("mute: true or false, the owner's")
|
|
1884
|
-
if (v.
|
|
1935
|
+
if (v.rename !== undefined && !(obj(v.rename) && typeof v.rename.from === 'string' && typeof v.rename.to === 'string' && v.rename.to.trim() !== '')) out.push('rename: { from, to: the new name }')
|
|
1936
|
+
if (v.moved !== undefined && !(obj(v.moved) && word(v.moved.from) && word(v.moved.to))) out.push('moved: { from, to: repo names }')
|
|
1937
|
+
if (v.closes !== undefined && !((v.closes === 'thread' || v.closes === 'version') && v.op === 'done')) out.push("closes: 'thread' or 'version', on a done")
|
|
1938
|
+
if (v.op === undefined && v.verdict === undefined && v.rate === undefined && typeof v.text !== 'string' && !Array.isArray(v.rects) && v.snooze === undefined && v.askState === undefined && v.urgent === undefined && v.askBar === undefined && v.unhold === undefined && v.laneAsk === undefined && v.act === undefined && v.mute === undefined && v.rename === undefined && v.moved === undefined)
|
|
1885
1939
|
out.push('a message says something: text, rects, verdict, rate or op')
|
|
1886
1940
|
return out
|
|
1887
1941
|
}
|
|
@@ -1989,7 +2043,7 @@ function trailerRect(r: Record<string, unknown>, t: ItemTrailer, i: number, erro
|
|
|
1989
2043
|
export function verdictMessageOf(body: unknown, item: Item): { ok: true; message: Pick<Message, 'verdict' | 'text' | 'rects' | 'reactions' | 'pick'> } | { ok: false; errors: string[] } {
|
|
1990
2044
|
if (!obj(body)) return { ok: false, errors: ['not an object'] }
|
|
1991
2045
|
const errors: string[] = []
|
|
1992
|
-
if (!STATUSES.includes(body.status as ReviewStatus)) errors.push(`status: one of ${STATUSES.join(', ')}`)
|
|
2046
|
+
if (!STATUSES.includes(statusRead(body.status) as ReviewStatus)) errors.push(`status: one of ${STATUSES.join(', ')}`)
|
|
1993
2047
|
if (body.comment !== undefined && typeof body.comment !== 'string') errors.push('comment: a text')
|
|
1994
2048
|
const rects = body.rects ?? []
|
|
1995
2049
|
if (!Array.isArray(rects)) errors.push('rects: a list')
|
|
@@ -2045,14 +2099,14 @@ export function verdictMessageOf(body: unknown, item: Item): { ok: true; message
|
|
|
2045
2099
|
if (pick !== undefined) {
|
|
2046
2100
|
if (!isChoice(item)) errors.push('pick: only on a choice version')
|
|
2047
2101
|
else if (!(typeof pick === 'number' && Number.isInteger(pick) && pick >= 0 && pick < views.length)) errors.push(`pick: the index of one of the version's ${views.length} views`)
|
|
2048
|
-
else if (!isApproved(body.status as ReviewStatus)) errors.push('pick: goes with approved or approved-with-fix;
|
|
2102
|
+
else if (!isApproved(statusRead(body.status) as ReviewStatus)) errors.push('pick: goes with approved or approved-with-fix; no option right is a rework or a wrong direction')
|
|
2049
2103
|
}
|
|
2050
2104
|
if (errors.length > 0) return { ok: false, errors }
|
|
2051
2105
|
const comment = typeof body.comment === 'string' ? body.comment : ''
|
|
2052
2106
|
return {
|
|
2053
2107
|
ok: true,
|
|
2054
2108
|
message: {
|
|
2055
|
-
verdict: body.status as ReviewStatus,
|
|
2109
|
+
verdict: statusRead(body.status) as ReviewStatus,
|
|
2056
2110
|
...(comment ? { text: comment } : {}),
|
|
2057
2111
|
...(out.length > 0 ? { rects: out } : {}),
|
|
2058
2112
|
...(reactions.length > 0 ? { reactions } : {}),
|
|
@@ -2072,7 +2126,6 @@ function reactionsOf(v: unknown, views: readonly ReviewView[], errors: string[],
|
|
|
2072
2126
|
}
|
|
2073
2127
|
const out: ReviewReaction[] = []
|
|
2074
2128
|
const seen = new Set<string>()
|
|
2075
|
-
const rowsPicked = new Set<string>()
|
|
2076
2129
|
for (const [i, r] of v.entries()) {
|
|
2077
2130
|
if (obj(r) && (draft || r.post !== undefined)) {
|
|
2078
2131
|
const q = postReaction(r, i, draft, seen, errors)
|
|
@@ -2087,7 +2140,7 @@ function reactionsOf(v: unknown, views: readonly ReviewView[], errors: string[],
|
|
|
2087
2140
|
const tiles = isGallery(on) ? on.gallery.length : 0
|
|
2088
2141
|
const tile = r.tile
|
|
2089
2142
|
if (tile !== undefined && !(typeof tile === 'number' && Number.isInteger(tile) && tile >= 0 && tile < tiles)) errors.push(`reactions[${i}].tile: the index of one tile of a gallery view`)
|
|
2090
|
-
if (r.status !== undefined && !STATUSES.includes(r.status as ReviewStatus)) errors.push(`reactions[${i}].status: one of ${STATUSES.join(', ')}`)
|
|
2143
|
+
if (r.status !== undefined && !STATUSES.includes(statusRead(r.status) as ReviewStatus)) errors.push(`reactions[${i}].status: one of ${STATUSES.join(', ')}`)
|
|
2091
2144
|
if (r.comment !== undefined && typeof r.comment !== 'string') errors.push(`reactions[${i}].comment: a text`)
|
|
2092
2145
|
const stars = r.stars
|
|
2093
2146
|
// a choice scores its options, a gallery each of its tiles
|
|
@@ -2097,23 +2150,14 @@ function reactionsOf(v: unknown, views: readonly ReviewView[], errors: string[],
|
|
|
2097
2150
|
const key = `${String(r.view)}/${String(tile ?? '')}`
|
|
2098
2151
|
if (seen.has(key)) errors.push(`reactions[${i}]: a second reaction on the same view or tile`)
|
|
2099
2152
|
seen.add(key)
|
|
2100
|
-
// a variant he keeps: one tile a row
|
|
2101
|
-
const group = typeof tile === 'number' && isGallery(on) ? on.gallery[tile]?.group : undefined
|
|
2102
|
-
const picked = r.picked
|
|
2103
|
-
if (picked !== undefined) {
|
|
2104
|
-
if (picked !== true || group === undefined) errors.push(`reactions[${i}].picked: true, only on a tile of a row of variants`)
|
|
2105
|
-
else if (rowsPicked.has(`${String(r.view)}/${group}`)) errors.push(`reactions[${i}].picked: one tile a row, and ${group} has one already`)
|
|
2106
|
-
else rowsPicked.add(`${String(r.view)}/${group}`)
|
|
2107
|
-
}
|
|
2108
2153
|
const comment = typeof r.comment === 'string' ? r.comment.trim() : ''
|
|
2109
|
-
if (r.status === undefined && comment === '' && stars === undefined
|
|
2154
|
+
if (r.status === undefined && comment === '' && stars === undefined) continue
|
|
2110
2155
|
out.push({
|
|
2111
2156
|
view: r.view as number,
|
|
2112
2157
|
...(typeof tile === 'number' ? { tile } : {}),
|
|
2113
|
-
...(r.status !== undefined ? { status: r.status as ReviewStatus } : {}),
|
|
2158
|
+
...(r.status !== undefined ? { status: statusRead(r.status) as ReviewStatus } : {}),
|
|
2114
2159
|
comment,
|
|
2115
2160
|
...(typeof stars === 'number' ? { stars } : {}),
|
|
2116
|
-
...(picked === true && group !== undefined ? { picked: true as const } : {}),
|
|
2117
2161
|
})
|
|
2118
2162
|
}
|
|
2119
2163
|
return out
|
|
@@ -2125,16 +2169,16 @@ function postReaction(r: Record<string, unknown>, i: number, draft: boolean, see
|
|
|
2125
2169
|
const bad: string[] = []
|
|
2126
2170
|
if (!draft) bad.push(`reactions[${i}].post: only on a draft version`)
|
|
2127
2171
|
else if (typeof r.post !== 'string' || !POST_KEY.test(r.post)) bad.push(`reactions[${i}].post: the key of one message of the draft, <account> or <account>/<name>`)
|
|
2128
|
-
if (r.status !== undefined && !STATUSES.includes(r.status as ReviewStatus)) bad.push(`reactions[${i}].status: one of ${STATUSES.join(', ')}`)
|
|
2172
|
+
if (r.status !== undefined && !STATUSES.includes(statusRead(r.status) as ReviewStatus)) bad.push(`reactions[${i}].status: one of ${STATUSES.join(', ')}`)
|
|
2129
2173
|
if (r.comment !== undefined && typeof r.comment !== 'string') bad.push(`reactions[${i}].comment: a text`)
|
|
2130
|
-
for (const k of ['tile', 'stars'
|
|
2174
|
+
for (const k of ['tile', 'stars']) if (r[k] !== undefined) bad.push(`reactions[${i}].${k}: none on a message of a draft`)
|
|
2131
2175
|
const key = `post/${String(r.post)}`
|
|
2132
2176
|
if (seen.has(key)) bad.push(`reactions[${i}]: a second reaction on the same message`)
|
|
2133
2177
|
seen.add(key)
|
|
2134
2178
|
errors.push(...bad)
|
|
2135
2179
|
const comment = typeof r.comment === 'string' ? r.comment.trim() : ''
|
|
2136
2180
|
if (bad.length > 0 || (r.status === undefined && comment === '')) return null
|
|
2137
|
-
return { view: 0, post: r.post as string, ...(r.status !== undefined ? { status: r.status as ReviewStatus } : {}), comment }
|
|
2181
|
+
return { view: 0, post: r.post as string, ...(r.status !== undefined ? { status: statusRead(r.status) as ReviewStatus } : {}), comment }
|
|
2138
2182
|
}
|
|
2139
2183
|
|
|
2140
2184
|
/** a draft version's message as the page and the CLI name it: the name the version pinned, else its key (one the draft gained since) */
|