rvlib-shipkit 2.31.0 → 2.32.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 +31 -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 +98 -73
- 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 +26 -198
- 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 +25 -23
- 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 +92 -182
- package/src/advisors/tunnel.ts +6 -5
- package/src/advisors/users-listen.ts +92 -0
- package/src/advisors/users-router.ts +257 -85
- 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_Checks.ts +0 -14
- 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_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 +2 -2
- package/src/collections/collection-types.ts +1 -1
- package/src/collections/review.ts +5 -4
- 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/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/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/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/discover-checks.ts +42 -32
- package/src/gate/gate-checks.ts +21 -131
- package/src/gate/pre-commit-discovery.ts +16 -25
- package/src/gate/run-check.ts +0 -4
- 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 +4 -11
- package/src/home/space-page.ts +3 -2
- package/src/home/supervise.ts +3 -7
- package/src/hooks/hook-config.ts +6 -7
- package/src/hooks/leak-guard.ts +1 -1
- package/src/hooks/run-hooks.ts +0 -5
- 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/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 +29 -64
- package/src/review/answer-kinds.ts +61 -4
- package/src/review/blocked-guard.ts +11 -0
- package/src/review/blocked-object.ts +298 -0
- package/src/review/cells.ts +116 -229
- 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 +49 -19
- 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.ts +86 -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 +798 -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/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/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 +181 -54
- 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 +2 -2
- package/src/serve/hub-app/review/review-kit.ts +17 -11
- package/src/serve/hub-app/review/review-list.tsx +23 -31
- package/src/serve/hub-app/review/review-st.ts +30 -40
- package/src/serve/hub-app/review/review-thread.tsx +139 -85
- package/src/serve/hub-app/review/review-views.tsx +124 -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 +372 -201
- package/src/serve/hub-app/review/tone-bar.tsx +126 -0
- package/src/serve/hub-app/review/tones.ts +35 -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 +180 -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/film-box.ts +0 -20
- 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/threads.ts
CHANGED
|
@@ -9,47 +9,25 @@ import {
|
|
|
9
9
|
addressesOf,
|
|
10
10
|
ownAddressOf,
|
|
11
11
|
parentAddress,
|
|
12
|
-
inWork,
|
|
13
|
-
isOpening,
|
|
14
|
-
asksNoVerdict,
|
|
15
|
-
moveOf,
|
|
16
12
|
isReply,
|
|
17
|
-
itemWithdrawOf,
|
|
18
13
|
partyOf,
|
|
19
14
|
proposeFields,
|
|
20
|
-
proposeOpen,
|
|
21
|
-
reworkOf,
|
|
22
15
|
stateOf,
|
|
23
|
-
subjectKey,
|
|
24
16
|
takenBackOf,
|
|
25
|
-
updatesOf,
|
|
26
17
|
verdictOf,
|
|
27
|
-
isVersionVerdict,
|
|
28
|
-
withdrawnOf,
|
|
29
18
|
type Message,
|
|
30
19
|
type ReviewItem,
|
|
31
|
-
type ShownStatus,
|
|
32
20
|
type Spec,
|
|
33
|
-
type Subject,
|
|
34
21
|
NO_SPEC,
|
|
35
|
-
byMachine,
|
|
36
22
|
isAskItem,
|
|
37
|
-
isClosedAskState,
|
|
38
|
-
handedOver,
|
|
39
23
|
agentsNamed,
|
|
40
24
|
toAcknowledge,
|
|
41
25
|
type Mention,
|
|
42
26
|
} from './model.ts'
|
|
43
27
|
import { addressKindProblem } from './kinds.ts'
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import { moveOf as bandMoveOf, turnAfterMoves, type Turn } from './band.ts'
|
|
47
|
-
import { askOpen } from './answer-kinds.ts'
|
|
48
|
-
import { wakeOf, wakingUnread } from './wakes.ts'
|
|
49
|
-
import { currentInstructions, replacersOf } from './supersede.ts'
|
|
50
|
-
import { openVerdictAsks } from './verdict-items.ts'
|
|
28
|
+
import { openingOf, wakingUnread } from './thread-events.ts'
|
|
29
|
+
import { currentInstructions } from './supersede.ts'
|
|
51
30
|
import { hearingOf, heardBy, maySee, NO_PARTIES, sessionLabel, type Hearing, type Holder, type Me, type Parties } from './parties.ts'
|
|
52
|
-
import { slugWords } from '../core/slug.ts'
|
|
53
31
|
|
|
54
32
|
/** one thread of versions: a head no later item supersedes, then the chain it supersedes back to the first, and the
|
|
55
33
|
* raised items any of them answers */
|
|
@@ -69,7 +47,7 @@ export const membersOf = (t: Thread): ReviewItem[] => [...t.versions, ...t.answe
|
|
|
69
47
|
|
|
70
48
|
const answersOf = (x: ReviewItem): readonly string[] => (x.item.origin.by === 'agent' ? (x.item.answers ?? []) : [])
|
|
71
49
|
|
|
72
|
-
const newest = (a: ReviewItem, b: ReviewItem): number => b.item.created.localeCompare(a.item.created) || b.item.id.localeCompare(a.item.id)
|
|
50
|
+
export const newest = (a: ReviewItem, b: ReviewItem): number => b.item.created.localeCompare(a.item.created) || b.item.id.localeCompare(a.item.id)
|
|
73
51
|
export const oldest = (a: ReviewItem, b: ReviewItem): number => a.item.created.localeCompare(b.item.created) || a.item.id.localeCompare(b.item.id)
|
|
74
52
|
|
|
75
53
|
function answeredBy(versions: readonly ReviewItem[], byId: ReadonlyMap<string, ReviewItem>): ReviewItem[] {
|
|
@@ -81,10 +59,6 @@ function answeredBy(versions: readonly ReviewItem[], byId: ReadonlyMap<string, R
|
|
|
81
59
|
.sort(oldest)
|
|
82
60
|
}
|
|
83
61
|
|
|
84
|
-
/** the raised item's opening: his or the player's words and rectangles that raised it, none on an agent item */
|
|
85
|
-
export const openingOf = (x: ReviewItem): Message | undefined =>
|
|
86
|
-
x.item.origin.by === 'agent' ? undefined : x.thread.find((m) => m.op === undefined && partyOf(m.who) === 'owner' && (m.text !== undefined || m.rects !== undefined))
|
|
87
|
-
|
|
88
62
|
/** the links of one list of items, built once per list: every reader of a 3000 item store walks them per item */
|
|
89
63
|
interface Links {
|
|
90
64
|
byId: Map<string, ReviewItem>
|
|
@@ -221,7 +195,7 @@ export function threadsNaming(raw: string, items: readonly ReviewItem[], spec: S
|
|
|
221
195
|
/** the newest version answering this raised item, null when none does */
|
|
222
196
|
export const answererOf = (id: string, items: readonly ReviewItem[]): ReviewItem | null => linksOf(items).answerers.get(id)?.[0] ?? null
|
|
223
197
|
|
|
224
|
-
const supersederOf = (id: string, items: readonly ReviewItem[]): ReviewItem | null => linksOf(items).superseders.get(id)?.[0] ?? null
|
|
198
|
+
export const supersederOf = (id: string, items: readonly ReviewItem[]): ReviewItem | null => linksOf(items).superseders.get(id)?.[0] ?? null
|
|
225
199
|
|
|
226
200
|
/** a later version follows the item: a new version of it, or a version answering it (stateOf's `superseded`) */
|
|
227
201
|
export const isFollowed = (id: string, items: readonly ReviewItem[]): boolean => supersederOf(id, items) !== null || answererOf(id, items) !== null
|
|
@@ -235,16 +209,30 @@ export function firstTitleOf(t: Thread): string {
|
|
|
235
209
|
return (opened ?? first).item.title
|
|
236
210
|
}
|
|
237
211
|
|
|
238
|
-
/** a thread's name
|
|
239
|
-
*
|
|
240
|
-
|
|
212
|
+
/** a thread's name before `before` (an ISO time; none: now): the newest rename on purpose (a version posted with
|
|
213
|
+
* `--rename`, or a `sk thread rename` and his edit of the head's title), else its first title; any other version's
|
|
214
|
+
* title is its own caption, so the name never moves by accident */
|
|
215
|
+
export function nameAt(t: Thread, before?: string): string {
|
|
216
|
+
const renames: { at: string; to: string }[] = []
|
|
217
|
+
for (const x of t.versions) if (x.item.rename === true) renames.push({ at: x.item.created, to: x.item.title })
|
|
218
|
+
for (const x of membersOf(t)) for (const m of x.thread) if (m.rename !== undefined) renames.push({ at: m.at, to: m.rename.to })
|
|
219
|
+
const ms = (iso: string): number => Date.parse(iso) || 0
|
|
220
|
+
const cut = before === undefined ? Infinity : ms(before)
|
|
221
|
+
return renames.filter((r) => ms(r.at) < cut).sort((a, b) => ms(a.at) - ms(b.at)).at(-1)?.to ?? firstTitleOf(t)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** the title a thread shows: an ask's newest instructions, else its name (nameAt) */
|
|
225
|
+
export const threadTitle = (t: Thread): string => currentInstructions(membersOf(t))?.instructions.title ?? nameAt(t)
|
|
241
226
|
|
|
242
|
-
/** the
|
|
243
|
-
export const
|
|
227
|
+
/** the ask a thread is about: its first version, an ask's item, whatever version came after it; null on another thread */
|
|
228
|
+
export const askItemOf = (t: Thread): ReviewItem | null => {
|
|
229
|
+
const first = t.versions.at(-1) ?? t.head
|
|
230
|
+
return isAskItem(first.item) ? first : null
|
|
231
|
+
}
|
|
244
232
|
|
|
245
233
|
/** the ask facts that stand on an ask's thread: its newest instructions', else its head's; null on another thread */
|
|
246
234
|
export const askFactsOf = (t: Thread): Omit<NonNullable<ReviewItem['item']['ask']>, 'created' | 'pinged'> | null =>
|
|
247
|
-
|
|
235
|
+
((a) => (a?.item.ask !== undefined ? (currentInstructions(membersOf(t))?.instructions.ask ?? a.item.ask) : null))(askItemOf(t))
|
|
248
236
|
|
|
249
237
|
/** the members of the thread an item reads in, null when none */
|
|
250
238
|
export const membersOfItem = (items: readonly ReviewItem[]) => (id: string): ReviewItem[] | null => {
|
|
@@ -264,44 +252,6 @@ export const threadsOfId = (tid: string, threads: readonly Thread[]): Thread[] =
|
|
|
264
252
|
export const threadOfItem = (id: string, threads: readonly Thread[]): Thread | null =>
|
|
265
253
|
threads.find((t) => t.head.item.id === id) ?? threads.find((t) => membersOf(t).some((x) => x.item.id === id)) ?? null
|
|
266
254
|
|
|
267
|
-
/** a thread still needs someone: its head pending, or answered with work owed (« fix » until `done` or a new version,
|
|
268
|
-
* « no » until a new version or `wontfix`; reading the verdict is never doing it; an approval needs nothing), or a
|
|
269
|
-
* lane reworking it; what he or a player raised, until it is closed */
|
|
270
|
-
export function isActive(t: Thread, now = new Date()): boolean {
|
|
271
|
-
return heldOpen(membersOf(t)).length > 0 || owesWork(t, now)
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/** an agent owes the thread its next move, the objects that hold it open aside */
|
|
275
|
-
function owesWork(t: Thread, now: Date): boolean {
|
|
276
|
-
// his request for a lane waits on the orchestrator until an agent acts in the thread (review/lane-ask.ts)
|
|
277
|
-
if (laneAskOf(membersOf(t)) !== null) return true
|
|
278
|
-
if (openAsksOf(t).length > 0 || openItemVerdictsOf(t).length > 0) return true
|
|
279
|
-
if (t.answers.some((x) => t.joined.has(x.item.id) && stateOf(x, false).state !== 'closed')) return true
|
|
280
|
-
if (t.versions.some((x) => wakingUnread(x).some((m) => m !== openingOf(x)))) return true
|
|
281
|
-
if (t.answers.some((x) => wakingUnread(x).some((m) => m !== openingOf(x)))) return true
|
|
282
|
-
// read is not done: his word that asks work, read by an agent with no act since, stays owed
|
|
283
|
-
if (readNoAct(t) !== null) return true
|
|
284
|
-
if (t.head.item.origin.by !== 'agent') return stateOf(t.head, false).state !== 'closed'
|
|
285
|
-
// opened with words: in work while the agent's latest update says so; a plain word owes nothing, a withdraw ends it
|
|
286
|
-
// until a newer update
|
|
287
|
-
if (isOpening(t.head.item)) {
|
|
288
|
-
const u = updatesOf(t.head).at(-1)
|
|
289
|
-
const w = itemWithdrawOf(t.head)
|
|
290
|
-
if (w !== undefined && (u === undefined || u.at <= w.at)) return false
|
|
291
|
-
const last = u?.update?.state
|
|
292
|
-
// his close of an ask settles what the machine left open: nobody holds a machine's line to close it
|
|
293
|
-
const closed = isAskItem(t.head.item) ? askStateOf(t) : null
|
|
294
|
-
if (u !== undefined && byMachine(u) && closed !== null && isClosedAskState(closed.state) && closed.at >= u.at) return false
|
|
295
|
-
return last === 'broken' || last === 'better'
|
|
296
|
-
}
|
|
297
|
-
if (reworkOf(t.head, false, now)) return true
|
|
298
|
-
const f = verdictOf(t.head)
|
|
299
|
-
if (!f) return withdrawnOf(t.head) === undefined
|
|
300
|
-
// his approval with a note or rectangles: owed until an agent reads it, then done (a bare one owes nothing)
|
|
301
|
-
if (f.status === 'approved' && !f.seen && (f.comment.trim() !== '' || f.rects.length > 0)) return true
|
|
302
|
-
return stateOf(t.head, false).state !== 'closed'
|
|
303
|
-
}
|
|
304
|
-
|
|
305
255
|
/** the thread's conversation: every version's and every answered item's replies, oldest first, each with the item it
|
|
306
256
|
* sits on; an answered item's opening words show with the item, not here */
|
|
307
257
|
export function conversationOf(t: Thread): (Message & { on: string })[] {
|
|
@@ -311,102 +261,6 @@ export function conversationOf(t: Thread): (Message & { on: string })[] {
|
|
|
311
261
|
.sort((a, b) => a.at.localeCompare(b.at) || a.id.localeCompare(b.id))
|
|
312
262
|
}
|
|
313
263
|
|
|
314
|
-
/** an agent's promise of the thread's next version (`sk thread working <address> "…" --next <by>`): who, when said, by
|
|
315
|
-
* when, the number it will take. It stands until a version comes after it or his close; past `until` it is late, never
|
|
316
|
-
* gone, so a promise not kept stays in sight */
|
|
317
|
-
export interface NextVersion {
|
|
318
|
-
who: string
|
|
319
|
-
session?: string
|
|
320
|
-
at: string
|
|
321
|
-
until: string
|
|
322
|
-
n: number
|
|
323
|
-
line: string
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/** the promise that stands on a thread, null when none */
|
|
327
|
-
export function nextVersionOf(t: Thread): NextVersion | null {
|
|
328
|
-
let best: Message | null = null
|
|
329
|
-
for (const x of membersOf(t)) for (const m of x.thread) if (m.next !== undefined && m.op === 'working' && partyOf(m.who) === 'agent' && (best === null || m.at >= best.at)) best = m
|
|
330
|
-
if (best === null) return null
|
|
331
|
-
const at = best.at
|
|
332
|
-
if (membersOf(t).some((x) => x.item.origin.by === 'agent' && x.item.created > at)) return null
|
|
333
|
-
const closed = closedAt(t)
|
|
334
|
-
if (closed !== null && closed >= at) return null
|
|
335
|
-
return { who: best.who, ...(best.session ? { session: best.session } : {}), at, until: best.next!.until, n: t.versions.length + 1, line: best.note ?? '' }
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
/** the thread's head version waits for the owner's verdict now: it asks one (waits) and no promised next version replaces it */
|
|
339
|
-
export const headWaits = (t: Thread): boolean => waits(t.head) && nextVersionOf(t) === null
|
|
340
|
-
|
|
341
|
-
/** a head waits for the owner's verdict: an agent's version, none yet, not withdrawn, not a draft */
|
|
342
|
-
export const waits = (x: ReviewItem): boolean => x.item.origin.by === 'agent' && (!asksNoVerdict(x.item) || x.item.asksVerdict === true) && !inWork(x) && verdictOf(x) === null && withdrawnOf(x) === undefined
|
|
343
|
-
|
|
344
|
-
/** the active pending heads first in the order they were sent, then every other thread, newest first */
|
|
345
|
-
export function orderedThreads(items: readonly ReviewItem[]): Thread[] {
|
|
346
|
-
const all = threadsOf(items)
|
|
347
|
-
const first = (x: ReviewItem): boolean => waits(x) || (x.item.origin.by === 'agent' && inWork(x))
|
|
348
|
-
const pending = all.filter((t) => first(t.head)).sort((a, b) => oldest(a.head, b.head))
|
|
349
|
-
const rest = all.filter((t) => !first(t.head)).sort((a, b) => newest(a.head, b.head))
|
|
350
|
-
return [...pending, ...rest]
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
const STOP = new Set(['a', 'an', 'the', 'of', 'on', 'in', 'at', 'to', 'and', 'with', 'by', 'de', 'la', 'le', 'les', 'du', 'des', 'au', 'aux', 'l', 'd', 'et', 'en'])
|
|
354
|
-
|
|
355
|
-
/** two titles share most of their words (Dice over the words, stop words aside): a new version sent without --supersedes */
|
|
356
|
-
export function closeTitles(a: string, b: string): boolean {
|
|
357
|
-
const wa = new Set(slugWords(a).filter((w) => !STOP.has(w)))
|
|
358
|
-
const wb = new Set(slugWords(b).filter((w) => !STOP.has(w)))
|
|
359
|
-
if (wa.size === 0 || wb.size === 0) return false
|
|
360
|
-
const common = [...wa].filter((w) => wb.has(w)).length
|
|
361
|
-
return (2 * common) / (wa.size + wb.size) >= 0.6
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/** the head of an active thread that already covers this subject, null when none. Subjects first: two that each name
|
|
365
|
-
* one thing are one subject exactly when they name the same; else the same topic and a subject its kind calls near;
|
|
366
|
-
* else a close title */
|
|
367
|
-
export function coveringHead(item: { title: string; topic?: string; subject: Subject }, items: readonly ReviewItem[], spec: Spec = NO_SPEC): { head: ReviewItem; by: 'subject' | 'near' | 'title' } | null {
|
|
368
|
-
const key = subjectKey(item.subject, spec)
|
|
369
|
-
const comparable = threadsOf(items)
|
|
370
|
-
.filter((t) => isActive(t))
|
|
371
|
-
.filter((t) => {
|
|
372
|
-
const k = subjectKey(t.head.item.subject, spec)
|
|
373
|
-
return key === null || k === null || k === key
|
|
374
|
-
})
|
|
375
|
-
const same = key === null ? undefined : comparable.find((t) => subjectKey(t.head.item.subject, spec) === key)
|
|
376
|
-
if (same) return { head: same.head, by: 'subject' }
|
|
377
|
-
const near = spec.kinds[item.subject.kind]?.near
|
|
378
|
-
const close = near
|
|
379
|
-
? comparable.find((t) => t.head.item.topic === item.topic && t.head.item.subject.kind === item.subject.kind && near(item.subject, t.head.item.subject))
|
|
380
|
-
: undefined
|
|
381
|
-
if (close) return { head: close.head, by: 'near' }
|
|
382
|
-
const title = comparable.find((t) => closeTitles(item.title, t.head.item.title))
|
|
383
|
-
return title ? { head: title.head, by: 'title' } : null
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/** what the list says of a version: the owner's verdict, else withdrawn, a draft, replaced, or waiting for him */
|
|
387
|
-
export function statusOf(x: ReviewItem, items: readonly ReviewItem[]): ShownStatus {
|
|
388
|
-
if (x.item.origin.by !== 'agent') {
|
|
389
|
-
// a report a version answers shows the bug's status: its version's, at the newest version
|
|
390
|
-
let item = answererOf(x.item.id, items)
|
|
391
|
-
const seen = new Set<string>()
|
|
392
|
-
for (let next = item; next && !seen.has(next.item.id); next = supersederOf(next.item.id, items)) {
|
|
393
|
-
seen.add(next.item.id)
|
|
394
|
-
item = next
|
|
395
|
-
}
|
|
396
|
-
if (item) return statusOf(item, items)
|
|
397
|
-
const st = stateOf(x, false)
|
|
398
|
-
if (st.state !== 'closed') return 'raised'
|
|
399
|
-
return st.why === 'wontfix' || st.why === 'dropped' ? 'wontfix' : st.why === 'rated' ? 'rated' : 'fixed'
|
|
400
|
-
}
|
|
401
|
-
const v = verdictOf(x)
|
|
402
|
-
if (v) return v.status
|
|
403
|
-
if (withdrawnOf(x) !== undefined) return 'withdrawn'
|
|
404
|
-
if (inWork(x)) return 'wip'
|
|
405
|
-
// a thread opened with words that its agent called fixed, or the owner's own save: nothing waits
|
|
406
|
-
if (asksNoVerdict(x.item)) return 'fixed'
|
|
407
|
-
return supersederOf(x.item.id, items) ? 'superseded' : 'pending'
|
|
408
|
-
}
|
|
409
|
-
|
|
410
264
|
/** the latest thing on `x` the agent has not seen: its verdict, a reply of the owner, or a verdict he took back; `to`:
|
|
411
265
|
* the owner's words one reader gets (wordReaches) */
|
|
412
266
|
const lastUnseen = (x: ReviewItem, answered: boolean, to?: WordTo): string => {
|
|
@@ -430,141 +284,6 @@ export function unseen(items: readonly ReviewItem[], to?: WordTo): ReviewItem[]
|
|
|
430
284
|
.map((u) => u.x)
|
|
431
285
|
}
|
|
432
286
|
|
|
433
|
-
/** an open ask's thread is counted as its ask, once (the asks badge, its needs pings: wiki tools/shipkit/threads-asks.md,
|
|
434
|
-
* An ask's thread); a closed ask is counted nowhere, so its thread counts as any other: a question after the close waits */
|
|
435
|
-
export const countedAsItsAsk = (t: Thread): boolean => isAskItem(t.head.item) && !isClosedAskState(askStateOf(t)?.state)
|
|
436
|
-
|
|
437
|
-
export type { Turn } from './band.ts'
|
|
438
|
-
|
|
439
|
-
/** each question and proposed change of the agents that no message of his answers yet (`re` names it) and no newer
|
|
440
|
-
* object supersedes (review/supersede.ts), oldest first; his close moots the ones before it (an ask's close too), never
|
|
441
|
-
* one an agent asks after it (afterClose) */
|
|
442
|
-
export function openAsksOf(t: Thread): (Message & { on: string })[] {
|
|
443
|
-
const members = membersOf(t)
|
|
444
|
-
const gone = replacersOf(members)
|
|
445
|
-
const out = members.flatMap((x) => {
|
|
446
|
-
return x.thread.filter((m) => partyOf(m.who) === 'agent' && !gone.has(m.id) && (m.propose !== undefined ? proposeOpen(x.thread, m) : askOpen(x.thread, m))).map((m) => ({ ...m, on: x.item.id }))
|
|
447
|
-
})
|
|
448
|
-
return afterClose(t, out).sort((a, b) => a.at.localeCompare(b.at))
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
/** each message of the thread that asks the owner's verdict and has none, oldest first, the ones before his close moot */
|
|
452
|
-
export function openItemVerdictsOf(t: Thread): (Message & { on: string })[] {
|
|
453
|
-
const members = membersOf(t)
|
|
454
|
-
return afterClose(t, openVerdictAsks(members, new Set(replacersOf(members).keys())))
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
/** when he closed the thread: his act after which its head stays closed (his OK or archive, his close), null while it is
|
|
458
|
-
* open or when an agent or the machine closed it (a reflection's thread `fixed` by the machine moots nothing); an ask's thread
|
|
459
|
-
* closes by its ask. A reopen or a new version opens the head, and its requests wait again (wiki
|
|
460
|
-
* tools/shipkit/threads-how-it-fits.md, The model) */
|
|
461
|
-
export function closedAt(t: Thread): string | null {
|
|
462
|
-
const x = t.head
|
|
463
|
-
if (isAskItem(x.item)) {
|
|
464
|
-
const a = askStateOf(t)
|
|
465
|
-
return a !== null && isClosedAskState(a.state) ? a.at : null
|
|
466
|
-
}
|
|
467
|
-
if (stateOf(x, false).state !== 'closed') return null
|
|
468
|
-
for (let i = x.thread.length - 1; i >= 0; i--) {
|
|
469
|
-
if (stateOf({ ...x, thread: x.thread.slice(0, i) }, false).state === 'closed') continue
|
|
470
|
-
const m = x.thread[i]!
|
|
471
|
-
return partyOf(m.who) === 'owner' ? m.at : null
|
|
472
|
-
}
|
|
473
|
-
return null
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
/** closed as the thread's page says it (« closed · <why> »): its head's state; an ask's thread by its ask */
|
|
477
|
-
export const isClosedThread = (t: Thread): boolean => (isAskItem(t.head.item) ? isClosedAskState(askStateOf(t)?.state) : stateOf(t.head, false).state === 'closed')
|
|
478
|
-
|
|
479
|
-
/** a request written before his close is moot: it waits on nobody, its cell reads « closed, not answered » */
|
|
480
|
-
export const isMoot = (t: Thread, m: Pick<Message, 'at'>): boolean => {
|
|
481
|
-
const cut = closedAt(t)
|
|
482
|
-
return cut !== null && m.at <= cut
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
/** his word asks the agent for something: words he wrote (a reply, a note, an action with words), an « ok with a fix »,
|
|
486
|
-
* a rejection with words, a verdict he took back until his next verdict on the version answers it. An approval (its note is read, never owed an act: 😐 asks for work),
|
|
487
|
-
* an archive, a bare rejection, his answer to a question, a set aside, a close ask nothing more */
|
|
488
|
-
function asks(x: ReviewItem, m: Message): boolean {
|
|
489
|
-
if (m === openingOf(x)) return true
|
|
490
|
-
if (m.verdict !== undefined) return m.verdict === 'approved-with-fix' || (m.verdict === 'rejected' && (!!m.text?.trim() || (m.rects?.length ?? 0) > 0))
|
|
491
|
-
if (m.op === 'reopen') return x.item.origin.by === 'agent' && !x.thread.slice(x.thread.indexOf(m) + 1).some(isVersionVerdict)
|
|
492
|
-
if (m.op !== undefined || m.answer !== undefined || m.snooze !== undefined || m.askState !== undefined || m.askBar !== undefined) return false
|
|
493
|
-
return m.action !== undefined || !!m.text?.trim() || (m.rects?.length ?? 0) > 0 || m.image !== undefined || (m.files?.length ?? 0) > 0
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/** his newest word that asks something (a tick inside an unfinished list is no word: review/wakes.ts; a plain approval
|
|
497
|
-
* after it asks nothing and leaves it owed), read by an agent, with no agent act in the thread since that word (a version,
|
|
498
|
-
* a message, a close, a `working`; never a read or a take): still owed, so a turn's end holds on it as on an unseen
|
|
499
|
-
* one. An act before the read counts: an agent that acted, then marked it read, owes nothing */
|
|
500
|
-
export function readNoAct(t: Thread): { who: string; at: string; word: Message } | null {
|
|
501
|
-
const members = membersOf(t)
|
|
502
|
-
const all = members.flatMap((x) => x.thread.map((m) => ({ x, m })))
|
|
503
|
-
const his = all.filter(({ x, m }) => partyOf(m.who) === 'owner' && m.op !== 'seen' && m.laneAsk === undefined && wakeOf(x, m) !== 'trace' && asks(x, m)).reduce<{ x: ReviewItem; m: Message } | null>((a, b) => (a === null || b.m.at >= a.m.at ? b : a), null)
|
|
504
|
-
if (his === null) return null
|
|
505
|
-
const read = all.filter(({ m }) => m.op === 'seen' && partyOf(m.who) === 'agent' && m.of?.includes(his.m.id)).reduce<Message | null>((a, { m }) => (a === null || m.at >= a.at ? m : a), null)
|
|
506
|
-
if (read === null) return null
|
|
507
|
-
// a take by a lane (an assign, a lane's own take) puts a named agent on his word; a session's bare take does not
|
|
508
|
-
const act = (m: Message): boolean => m.op !== 'seen' && (m.op !== 'take' || m.who !== 'agent')
|
|
509
|
-
const acted = all.some(({ m }) => partyOf(m.who) === 'agent' && act(m) && m.at >= his.m.at) || members.some((x) => x.item.origin.by === 'agent' && x.item.created >= his.m.at)
|
|
510
|
-
return acted ? null : { who: read.who, at: read.at, word: his.m }
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
/** his newest word that asks something with no agent answer since: a version, a reply, an update, a question, a
|
|
514
|
-
* change, a close; a `working`, a read, a take, a hand-over answer nothing (band.ts AFTER_MOVE). Null when answered */
|
|
515
|
-
export function unansweredWord(t: Thread): Message | null {
|
|
516
|
-
const members = membersOf(t)
|
|
517
|
-
const all = members.flatMap((x) => x.thread.map((m) => ({ x, m })))
|
|
518
|
-
const his = all.filter(({ x, m }) => partyOf(m.who) === 'owner' && m.op !== 'seen' && m.laneAsk === undefined && wakeOf(x, m) !== 'trace' && asks(x, m)).reduce<{ x: ReviewItem; m: Message } | null>((a, b) => (a === null || b.m.at >= a.m.at ? b : a), null)
|
|
519
|
-
if (his === null) return null
|
|
520
|
-
const answered = all.some(({ x, m }) => m.at >= his.m.at && partyOf(m.who) === 'agent' && !byMachine(m) && bandMoveOf(x, m) === 'agent-answer') || members.some((x) => x.item.origin.by === 'agent' && x.item.created >= his.m.at)
|
|
521
|
-
return answered ? null : his.m
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
const afterClose = <M extends Pick<Message, 'at'>>(t: Thread, ms: M[]): M[] => (ms.length === 0 ? ms : ms.filter((m) => !isMoot(t, m)))
|
|
525
|
-
|
|
526
|
-
/** yours: a version waits for the owner's verdict, a question or a proposed change for the owner's answer, a note the
|
|
527
|
-
* owner raised is the owner's move, or only an object whose move is the owner's holds it open (a branch to merge);
|
|
528
|
-
* agents: an agent owes the next move; done: nothing is owed */
|
|
529
|
-
export function turnOf(t: Thread, now = new Date()): Turn {
|
|
530
|
-
// the owner's words after what waits on the owner pass the ball to the agents (band.ts AFTER_MOVE)
|
|
531
|
-
const base = turnAfterMoves(baseTurnOf(t, now), membersOf(t))
|
|
532
|
-
return base === 'yours' && asideUntil(t, now) !== null ? 'aside' : base
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
/** the newest ask state written in the thread with its time, null on a thread that is no ask's or never said one */
|
|
536
|
-
export function askStateOf(t: Thread): (NonNullable<Message['askState']> & { at: string }) | null {
|
|
537
|
-
let last: (NonNullable<Message['askState']> & { at: string }) | null = null
|
|
538
|
-
for (const x of membersOf(t)) for (const m of x.thread) if (m.askState && (last === null || m.at >= last.at)) last = { ...m.askState, at: m.at }
|
|
539
|
-
return last
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
/** when a thread set aside comes back, null when it is not set aside now: the newest « set aside » still ahead, unless
|
|
543
|
-
* he acted on the thread after it, or an agent sent an urgent message after it */
|
|
544
|
-
export function asideUntil(t: Thread, now = new Date()): string | null {
|
|
545
|
-
let snooze: { at: string; until: string | null } | null = null
|
|
546
|
-
const msgs = membersOf(t).flatMap((x) => x.thread)
|
|
547
|
-
for (const m of msgs) if (m.snooze && (snooze === null || m.at >= snooze.at)) snooze = { at: m.at, until: m.snooze.until }
|
|
548
|
-
if (snooze === null || snooze.until === null || Date.parse(snooze.until) <= now.getTime()) return null
|
|
549
|
-
const after = msgs.filter((m) => m.at > snooze!.at)
|
|
550
|
-
if (after.some((m) => m.urgent === true && partyOf(m.who) === 'agent')) return null
|
|
551
|
-
if (after.some((m) => partyOf(m.who) === 'owner' && m.op !== 'seen' && m.snooze === undefined && m.mute === undefined && m.carried === undefined)) return null
|
|
552
|
-
return snooze.until
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
function baseTurnOf(t: Thread, now: Date): 'yours' | 'agents' | 'done' {
|
|
556
|
-
if (headWaits(t) || openAsksOf(t).length > 0 || openItemVerdictsOf(t).length > 0) return 'yours'
|
|
557
|
-
// an open ask with nothing open: its bar waits on him (« done ✓ », his hands until its check passes); the owner's
|
|
558
|
-
// words as the newest move pass it to the agents (band.ts AFTER_MOVE, in turnOf)
|
|
559
|
-
if (isAskItem(t.head.item) && !isClosedAskState(askStateOf(t)?.state)) return 'yours'
|
|
560
|
-
const notes = [...(t.head.item.origin.by === 'agent' ? [] : [t.head]), ...t.answers.filter((x) => t.joined.has(x.item.id))]
|
|
561
|
-
if (notes.some((x) => moveOf(stateOf(x, false).state) === 'owner')) return 'yours'
|
|
562
|
-
// a promised next version: the agents owe it, late or not
|
|
563
|
-
if (nextVersionOf(t) !== null || owesWork(t, now)) return 'agents'
|
|
564
|
-
const held = heldOpen(membersOf(t))
|
|
565
|
-
if (held.length === 0) return 'done'
|
|
566
|
-
return held.some((h) => holdMoveOf(h) === 'owner') ? 'yours' : 'agents'
|
|
567
|
-
}
|
|
568
287
|
|
|
569
288
|
/** the agent that holds a thread: its newest act in it (a version, an update, a reply, a question, a claim, a take;
|
|
570
289
|
* never a read mark), by its lane and its session. Null on a thread no agent touched. Who hears it and who may mark
|
|
@@ -587,6 +306,9 @@ export function holderOf(t: Thread): Holder | null {
|
|
|
587
306
|
}
|
|
588
307
|
|
|
589
308
|
function holderOfActs(members: readonly ReviewItem[]): Holder | null {
|
|
309
|
+
// a move to another repo lets its holder go: only the acts after it hold, so the repo it came to hears it
|
|
310
|
+
let moved = ''
|
|
311
|
+
for (const x of members) for (const m of x.thread) if (m.moved !== undefined && m.at > moved) moved = m.at
|
|
590
312
|
const acts: Holder[] = []
|
|
591
313
|
for (const x of members) {
|
|
592
314
|
const o = x.item.origin
|
|
@@ -595,7 +317,7 @@ function holderOfActs(members: readonly ReviewItem[]): Holder | null {
|
|
|
595
317
|
if (partyOf(m.who) === 'agent' && m.op !== 'seen') acts.push({ ...(m.who !== 'agent' ? { lane: m.who } : {}), ...(m.session ? { session: m.session } : {}), at: m.at, ...(m.op === 'take' && m.from ? { from: m.from } : {}) })
|
|
596
318
|
}
|
|
597
319
|
// an act that names nobody (an older message of an unnamed agent) holds nothing; on one instant the later written wins
|
|
598
|
-
return acts.filter((a) => a.lane !== undefined || a.session !== undefined).reduce<Holder | null>((best, a) => (best === null || a.at >= best.at ? a : best), null)
|
|
320
|
+
return acts.filter((a) => (a.lane !== undefined || a.session !== undefined) && a.at > moved).reduce<Holder | null>((best, a) => (best === null || a.at >= best.at ? a : best), null)
|
|
599
321
|
}
|
|
600
322
|
|
|
601
323
|
/** `me` holds it by the act alone, no registry at hand: its lane when the holder names one, else its session */
|
|
@@ -613,7 +335,7 @@ export const hearingOfThread = (t: Thread, p: Parties, repo: string): Hearing =>
|
|
|
613
335
|
|
|
614
336
|
/** a watch or an inbox with this filter hears what lands on `x`. With the registry: the party that hears the thread
|
|
615
337
|
* now (its holder, else its parent session for it); with none, its holder by the act alone. A bare filter hears every
|
|
616
|
-
* thread
|
|
338
|
+
* thread; a thread nobody holds, its maker's. And each agent one of his unseen words names, for that
|
|
617
339
|
* word (wordReaches) */
|
|
618
340
|
export function hears(f: WatchFilter, x: ReviewItem, byItem: ReadonlyMap<string, Thread>, p: Parties | null = null): boolean {
|
|
619
341
|
return hearsHolder(f, x, byItem, p) || wakingUnread(x).some((m) => agentsNamed(m).length > 0 && wordReaches(f, x, m, byItem, p))
|
|
@@ -719,46 +441,6 @@ export function seenRefusal(x: ReviewItem, t: Thread | null, me: Me, p: Parties
|
|
|
719
441
|
return `${x.item.id} is held by ${holder} (${hearing.words}): that agent marks it seen, or its session; to act on it yourself, sk thread take ${address}, then mark it seen`
|
|
720
442
|
}
|
|
721
443
|
|
|
722
|
-
/** what moved since the owner's last act in the store (a verdict, a word, a note, an answer; never a read: the hub marks
|
|
723
|
-
* what he sees read a moment after the page opens, which would empty the line): the threads an agent wrote in since,
|
|
724
|
-
* and how many of them are his turn. Null before his first act. The line he reads on waking */
|
|
725
|
-
export function sinceHeLeft(items: readonly ReviewItem[], now = new Date()): { at: string; moved: number; yours: number } | null {
|
|
726
|
-
let at = ''
|
|
727
|
-
for (const x of items) {
|
|
728
|
-
if (x.item.origin.by === 'owner' && x.item.created > at) at = x.item.created
|
|
729
|
-
for (const m of x.thread) if (m.who === 'owner' && m.op !== 'seen' && m.at > at) at = m.at
|
|
730
|
-
}
|
|
731
|
-
if (at === '') return null
|
|
732
|
-
const moved = threadsOf(items).filter((t) => membersOf(t).some((x) => (x.item.origin.by === 'agent' && x.item.created > at) || x.thread.some((m) => partyOf(m.who) === 'agent' && m.op !== 'seen' && !handedOver(m) && m.at > at)))
|
|
733
|
-
return { at, moved: moved.length, yours: moved.filter((t) => turnOf(t, now) === 'yours').length }
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
/** his notes of a thread still open, oldest first: its head when he raised it, and the notes that joined by their
|
|
737
|
-
* address alone */
|
|
738
|
-
export const openNotesOf = (t: Thread): ReviewItem[] =>
|
|
739
|
-
[...(t.head.item.origin.by === 'agent' ? [] : [t.head]), ...t.answers.filter((x) => t.joined.has(x.item.id))].filter((x) => stateOf(x, false).state !== 'closed').sort(oldest)
|
|
740
|
-
|
|
741
|
-
/** the item words by address answer (`sk thread reply <address>`): his newest open note, the one he waits on, else
|
|
742
|
-
* the thread's head */
|
|
743
|
-
export const replyTargetOf = (t: Thread): string => (openNotesOf(t).at(-1) ?? t.head).item.id
|
|
744
|
-
|
|
745
|
-
/** what « it is fixed » does on a thread (`sk thread fixed`): `asked` a note of the owner, by its id, closes it; else the owner's one open note in
|
|
746
|
-
* the thread closes (two or more are named, one picked by its id); else the newest version he answered « ok with a fix »
|
|
747
|
-
* closes (done), and one he rejected or that is in work asks the owner's verdict again (an update `fixed`) */
|
|
748
|
-
export function fixedPlan(t: Thread, asked: ReviewItem, o: { byAddress?: boolean } = {}): { op: 'fixed' | 'done' | 'update'; id: string } | { error: string } {
|
|
749
|
-
// an address names the thread, never its head note: a closed note heading it stands for nothing
|
|
750
|
-
if (asked.item.origin.by !== 'agent' && !o.byAddress) return { op: 'fixed', id: asked.item.id }
|
|
751
|
-
const notes = openNotesOf(t)
|
|
752
|
-
if (notes.length === 1) return { op: 'fixed', id: notes[0]!.item.id }
|
|
753
|
-
if (notes.length > 1) return { error: `${notes.length} open notes of his in this thread: sk thread fixed <id> "<what was done>" on the one you fixed: ${notes.map((x) => `${x.item.id} "${x.item.title}"`).join('; ')}` }
|
|
754
|
-
const h = t.head
|
|
755
|
-
const st = stateOf(h, false)
|
|
756
|
-
if (st.state === 'claimed' && verdictOf(h)?.status === 'approved-with-fix') return { op: 'done', id: h.item.id }
|
|
757
|
-
if (st.state === 'claimed' || st.state === 'draft') return { op: 'update', id: h.item.id }
|
|
758
|
-
if (st.state === 'asks') return { error: `${h.item.id} waits on the verdict of the owner already: nothing to say fixed` }
|
|
759
|
-
return { error: `${h.item.id} is closed already (${st.why ?? 'closed'}): nothing to say fixed` }
|
|
760
|
-
}
|
|
761
|
-
|
|
762
444
|
/** the views of an item its messages hold, never the version's own (wiki tools/shipkit/threads-store.md, A message's
|
|
763
445
|
* views): an update's media, a question's options, a proposed sound */
|
|
764
446
|
export function messageViewsOf(x: ReviewItem): Set<number> {
|