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/routes.ts
CHANGED
|
@@ -8,15 +8,14 @@ import { isAnimFormat, isAnimLabels, isAnimMode, pairAnimation } from './anim.ts
|
|
|
8
8
|
import { startAuto } from './auto.ts'
|
|
9
9
|
import { bad, KEEP, NO_STORE, ranged, tagged, TYPES } from './http.ts'
|
|
10
10
|
import { isStoreRefused } from '../core/machine-db.ts'
|
|
11
|
-
import { addressOrThrow, canonicalAddress, ownAddressOf, type Mention, type Rect, type Subject } from './model.ts'
|
|
11
|
+
import { addressOrThrow, canonicalAddress, ownAddressOf, type Mention, type QuestionTone, type Rect, type Subject } from './model.ts'
|
|
12
12
|
import { stageGet, stagePost } from './stage-routes.ts'
|
|
13
13
|
import { pasteHosts } from './paste.ts'
|
|
14
14
|
import { openReview, partFile, viewOfItem } from './project.ts'
|
|
15
15
|
import { CLIP, isPreviewSize, PREVIEW_W, previewOrRemote, warmPreviews } from './previews.ts'
|
|
16
|
-
import {
|
|
17
|
-
import { addMessage, sentAs, deleteOwnMessage, answerAsk, appendMessage, isWebUrl, readAll, postAction, attachTo, imageFile, mediaDir, itemOfRef, markOwnerRead, raiseItem, rateSubject, readAllCached, readItem, reopen, setThreadTags, specOf, storeDir, storeStamp, threadImage } from './store.ts'
|
|
16
|
+
import { addMessage, askRecap, sentAs, deleteOwnMessage, answerAsk, appendMessage, isWebUrl, readAll, postAction, attachTo, imageFile, mediaDir, itemOfRef, markOwnerRead, raiseItem, rateSubject, readAllCached, readItem, reopen, setThreadTags, specOf, storeDir, storeStamp, threadImage } from './store.ts'
|
|
18
17
|
import { tagEdits } from './thread-query.ts'
|
|
19
|
-
import {
|
|
18
|
+
import { pageOf, queryOf, refThreadOf, threadLinks, threadOfId, threadsOfAddress, threadView, type ThreadPage } from './cells.ts'
|
|
20
19
|
import { indexOf, whenBuilt } from './store-index.ts'
|
|
21
20
|
import { holderOf, membersOf, membersOfItem, ownAddressesOf, threadsOf, type Thread } from './threads.ts'
|
|
22
21
|
import { mentionCandidates, mentionedNames, resolveMentions, type AdvisorParty, type MentionCandidate } from './mentions.ts'
|
|
@@ -29,7 +28,7 @@ import { trailerRoutes } from './trailer-routes.ts'
|
|
|
29
28
|
import { secretRoutes, type ReadersOf } from './secret-route.ts'
|
|
30
29
|
import type { TailnetWho } from '../http/tailnet-caller.ts'
|
|
31
30
|
import { asideAt, snoozeThread } from './snooze.ts'
|
|
32
|
-
import { closeThread, CLOSE_HOWS, rootOfStore } from './close.ts'
|
|
31
|
+
import { closeThread, CLOSE_HOWS, renameThread, rootOfStore } from './close.ts'
|
|
33
32
|
import { ownerVerdict, releaseFollows } from './owner-verdict.ts'
|
|
34
33
|
import { liveHolds } from './holds-sync.ts'
|
|
35
34
|
import { dropStaged, serveAttached, stagedFiles, stageUpload } from './uploads.ts'
|
|
@@ -38,7 +37,7 @@ import type { HeldOf } from '../secrets/held.ts'
|
|
|
38
37
|
import type { SecretStore } from '../secrets/manager.ts'
|
|
39
38
|
import { specData, type ReviewUnit } from './unit.ts'
|
|
40
39
|
import { liveWatchers } from './watchers.ts'
|
|
41
|
-
import {
|
|
40
|
+
import { partiesOfStore } from './store-parties.ts'
|
|
42
41
|
import { repoNameOf } from '../agent-time/registry.ts'
|
|
43
42
|
import { harvestedOf, objectReaderOf, objectsTag } from './object-read.ts'
|
|
44
43
|
import { orchestratorOf } from './lane-ask.ts'
|
|
@@ -74,33 +73,7 @@ async function mentionsOf(dir: string, id: string): Promise<MentionCandidate[]>
|
|
|
74
73
|
return mentionCandidates({ members: membersOf(t), parties, repo, holder: h === null ? null : { ...(h.lane ? { lane: h.lane } : {}), ...(h.session ? { session: h.session } : {}) }, advisors })
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
|
|
78
|
-
* held answer stands only while the stamp it was read under holds: the page asks on the stream's notice that the
|
|
79
|
-
* parties moved, and nothing asks again after that answer */
|
|
80
|
-
const PARTIES_MS = 4000
|
|
81
|
-
const partiesHeld = new Map<string, { at: number; stamp: string; value: Promise<StoreParties> }>()
|
|
82
|
-
/** the cheap sign that a store's parties moved, given by the hub (serve/serve-hub.ts): its stream follows the same */
|
|
83
|
-
let partiesStampOf: (dir: string) => string = () => ''
|
|
84
|
-
export const partiesStampWith = (stamp: (dir: string) => string): void => {
|
|
85
|
-
partiesStampOf = stamp
|
|
86
|
-
}
|
|
87
|
-
/** who reads them: this process, or the daemon's read thread (serve/read-thread.ts), off the loop every page waits on */
|
|
88
|
-
let partiesReader: (dir: string) => Promise<StoreParties> = storeParties
|
|
89
|
-
export const readPartiesWith = (reader: (dir: string) => Promise<StoreParties>): void => {
|
|
90
|
-
partiesReader = reader
|
|
91
|
-
}
|
|
92
|
-
export function partiesOfStore(dir: string, now = Date.now()): Promise<StoreParties> {
|
|
93
|
-
const held = partiesHeld.get(dir)
|
|
94
|
-
const stamp = partiesStampOf(dir)
|
|
95
|
-
if (held && now - held.at < PARTIES_MS && held.stamp === stamp) return held.value
|
|
96
|
-
const value = partiesReader(dir)
|
|
97
|
-
// a read that failed is asked again by the next caller, never kept for its few seconds
|
|
98
|
-
value.catch(() => {
|
|
99
|
-
if (partiesHeld.get(dir)?.value === value) partiesHeld.delete(dir)
|
|
100
|
-
})
|
|
101
|
-
partiesHeld.set(dir, { at: now, stamp, value })
|
|
102
|
-
return value
|
|
103
|
-
}
|
|
76
|
+
export { partiesOfStore, partiesStampWith, readPartiesWith } from './store-parties.ts'
|
|
104
77
|
import { autoRulesOf } from '../veille/auto.ts'
|
|
105
78
|
import { draftsOfThread } from '../social/thread-drafts.ts'
|
|
106
79
|
import { itemsDb } from './item-db.ts'
|
|
@@ -155,7 +128,7 @@ const SHARE_LABEL = 'review-share'
|
|
|
155
128
|
whenBuilt((dir, x) =>
|
|
156
129
|
void warmPreviews(
|
|
157
130
|
dir,
|
|
158
|
-
x.ix.entries.filter((e) => e.row.active).map((e) => e.t.head),
|
|
131
|
+
x.ix.entries.filter((e) => e.row.state.active).map((e) => e.t.head),
|
|
159
132
|
).catch((e: unknown) => console.error(`WARN: review previews made ahead in ${dir}: ${(e as Error).message}`)),
|
|
160
133
|
)
|
|
161
134
|
|
|
@@ -243,7 +216,11 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
243
216
|
return bad(e)
|
|
244
217
|
}
|
|
245
218
|
const t = threadOfId(id, x.threads)
|
|
246
|
-
if (!t)
|
|
219
|
+
if (!t) {
|
|
220
|
+
const { movedLine, movedOf } = await import('./move.ts')
|
|
221
|
+
const m = movedOf(dir, ref)
|
|
222
|
+
return m === null ? bad(`no item ${ref}`, 404) : Response.json({ error: movedLine(ref, m), moved: { repo: m.to, head: m.head } }, { status: 404, headers: NO_STORE })
|
|
223
|
+
}
|
|
247
224
|
// a draft staged from the version is a group of the posts' projection: its newest write joins the tag
|
|
248
225
|
const staged = (itemsDb().query('select max(last_seq) as s from thread_post_groups').get() as { s: number | null } | null)?.s ?? 0
|
|
249
226
|
const root = dirname(dirname(dir))
|
|
@@ -278,19 +255,17 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
278
255
|
return bad(e)
|
|
279
256
|
}
|
|
280
257
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
return tagged(req, x.tag, () => ({ role: roleOf(dir), rows: boardOf(readAllCached(dir).items) }))
|
|
284
|
-
}
|
|
258
|
+
// the house repos his « move to project… » lists: the ones the move route takes
|
|
259
|
+
if (path === '/api/review/move-targets' && req.method === 'GET') return Response.json({ repos: (await import('./move.ts')).moveTargetsOf(rootOfStore(dir)) }, { headers: NO_STORE })
|
|
285
260
|
if (path === '/api/review/watchers' && req.method === 'GET') return Response.json(liveWatchers(dir), { headers: NO_STORE })
|
|
286
261
|
// who holds each thread and who hears it: the parties its holders name (review/parties.ts), the page draws the light
|
|
287
262
|
if (path === '/api/review/parties' && req.method === 'GET') return Response.json(await partiesOfStore(dir), { headers: NO_STORE })
|
|
288
|
-
// the unit's words
|
|
263
|
+
// the unit's words: what the page draws the list's filters and labels with
|
|
289
264
|
if (path === '/api/review/spec' && req.method === 'GET') {
|
|
290
265
|
// where a thread lives, for the paste that hands it to another agent session; a config that does not load leaves it out
|
|
291
266
|
const where = await pasteHosts(dirname(dirname(dir))).catch(() => null)
|
|
292
267
|
return Response.json(
|
|
293
|
-
{ ...specData(specOf(dir)),
|
|
268
|
+
{ ...specData(specOf(dir)), sources: (unit?.sources ?? []).map((s) => s.id), auto: autoRulesOf(dirname(dirname(dir)), unit).map((r) => ({ id: r.id, every: r.every })), where },
|
|
294
269
|
{ headers: NO_STORE },
|
|
295
270
|
)
|
|
296
271
|
}
|
|
@@ -372,19 +347,40 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
372
347
|
const gone = supersededRefusal(membersOfItem(readAll(dir).items), id, b.re)
|
|
373
348
|
if (gone !== null) throw new Error(gone)
|
|
374
349
|
const opens = typeof b.value === 'string' && urlQuestion(dir, id, b.re) ? { opens: await opensWith(b.value) } : {}
|
|
375
|
-
const answer = answerAsk(dir, id, { re: b.re, ...(typeof b.option === 'number' ? { option: b.option } : {}), ...(b.apply === true ? { apply: true } : {}), ...(typeof b.field === 'string' ? { field: b.field } : {}), ...(typeof b.value === 'string' ? { value: b.value } : {}), ...(typeof b.text === 'string' ? { text: b.text } : {}), ...(typeof b.tick === 'boolean' ? { tick: b.tick } : {}), ...(typeof b.pick === 'number' ? { pick: b.pick } : {}), ...opens })
|
|
350
|
+
const answer = answerAsk(dir, id, { re: b.re, ...(typeof b.option === 'number' ? { option: b.option } : {}), ...(b.apply === true ? { apply: true } : {}), ...(typeof b.field === 'string' ? { field: b.field } : {}), ...(typeof b.value === 'string' ? { value: b.value } : {}), ...(typeof b.text === 'string' ? { text: b.text } : {}), ...(typeof b.tick === 'boolean' ? { tick: b.tick } : {}), ...(typeof b.pick === 'number' ? { pick: b.pick } : {}), ...(typeof b.tone === 'string' ? { tone: b.tone as QuestionTone } : {}), ...opens })
|
|
376
351
|
await (await import('./kind-apply.ts')).applyOnAnswer(rootOfStore(dir), dir, unit, id, answer)
|
|
377
|
-
|
|
352
|
+
const moved = (await import('./move.ts')).moveOnAnswer(rootOfStore(dir), id, answer)
|
|
353
|
+
return Response.json(moved === null ? answer : { ...answer, moved: { repo: moved.to, head: moved.head } }, { headers: NO_STORE })
|
|
354
|
+
}
|
|
355
|
+
// his « move to project… » from the thread's head: the same move as his click on a suggested one
|
|
356
|
+
if (name === 'move') {
|
|
357
|
+
const b = (await req.json().catch(() => ({}))) as { repo?: unknown }
|
|
358
|
+
if (typeof b.repo !== 'string' || b.repo === '') return bad('repo: the house repo it moves to', 400)
|
|
359
|
+
const { houseRootOf, moveThread } = await import('./move.ts')
|
|
360
|
+
const to = houseRootOf(rootOfStore(dir), b.repo)
|
|
361
|
+
if (to === null) return bad(`no house repo ${b.repo}`, 404)
|
|
362
|
+
try {
|
|
363
|
+
const m = moveThread(rootOfStore(dir), id, to, { by: 'owner' })
|
|
364
|
+
return Response.json({ repo: m.to, head: m.head }, { headers: NO_STORE })
|
|
365
|
+
} catch (e) {
|
|
366
|
+
return bad((e as Error).message, 400)
|
|
367
|
+
}
|
|
378
368
|
}
|
|
379
369
|
if (name === 'action') {
|
|
380
370
|
const b = (await req.json()) as Record<string, unknown>
|
|
381
371
|
if (typeof b.name !== 'string') throw new Error('name: the action he clicked')
|
|
372
|
+
// his act on a blocked card writes the rule first: this route is an owner word route, the one door to it
|
|
373
|
+
const blocked = await import('./blocked-object.ts')
|
|
374
|
+
if (blocked.blockedOfAct(dir, id, typeof b.re === 'string' ? b.re : undefined) !== null)
|
|
375
|
+
return Response.json(blocked.actOnBlocked(rootOfStore(dir), id, { name: b.name, ...(typeof b.text === 'string' ? { text: b.text } : {}), ...(typeof b.re === 'string' ? { re: b.re } : {}) }).message, { headers: NO_STORE })
|
|
382
376
|
return Response.json(postAction(dir, id, { name: b.name, ...(typeof b.text === 'string' ? { text: b.text } : {}), ...(typeof b.re === 'string' ? { re: b.re } : {}) }), { headers: NO_STORE })
|
|
383
377
|
}
|
|
384
378
|
if (name === 'lane') {
|
|
385
379
|
const b = (await req.json().catch(() => ({}))) as { text?: unknown }
|
|
386
380
|
return Response.json(await askLane(dir, id, b.text), { headers: NO_STORE })
|
|
387
381
|
}
|
|
382
|
+
// the owner's « recap »: a request in the thread its holder hears, never a recap written here (review/recap.ts)
|
|
383
|
+
if (name === 'recap') return Response.json(askRecap(dir, id), { headers: NO_STORE })
|
|
388
384
|
if (name === 'attach') {
|
|
389
385
|
const b = (await req.json()) as Record<string, unknown>
|
|
390
386
|
if (typeof b.address !== 'string') throw new Error('address: <kind>:<key>')
|
|
@@ -408,6 +404,16 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
408
404
|
return bad((e as Error).message, 400)
|
|
409
405
|
}
|
|
410
406
|
}
|
|
407
|
+
// his rename of the thread from its head's title: the same message and trace as `sk thread rename`
|
|
408
|
+
if (name === 'rename') {
|
|
409
|
+
const b = (await req.json().catch(() => ({}))) as { title?: unknown }
|
|
410
|
+
if (typeof b.title !== 'string') return bad('title: the new name', 400)
|
|
411
|
+
try {
|
|
412
|
+
return Response.json(renameThread(dir, id, 'owner', b.title), { headers: NO_STORE })
|
|
413
|
+
} catch (e) {
|
|
414
|
+
return bad((e as Error).message, 400)
|
|
415
|
+
}
|
|
416
|
+
}
|
|
411
417
|
if (name === 'reopen') {
|
|
412
418
|
const v = reopen(dir, id, { who: 'owner' })
|
|
413
419
|
if (!v) return bad(`${id}: no such item, or no answer to take back`, 404)
|
|
@@ -600,11 +606,9 @@ export async function reviewRoutes(root: string, req: Request, path: string, o:
|
|
|
600
606
|
if (answered != null && req.method === 'POST' && r?.ok === true) await followAskThread(root, answered[1]!)
|
|
601
607
|
return r
|
|
602
608
|
} catch (e) {
|
|
603
|
-
// the thread store refused while a
|
|
609
|
+
// the thread store refused while a repair of the daemon's file runs: a state the page shows, never an error page
|
|
604
610
|
if (!isStoreRefused(e)) throw e
|
|
605
|
-
|
|
606
|
-
const left = /(about|under) (\d+) s left/.exec(e.message)
|
|
607
|
-
const s = left == null ? 2 : left[1] === 'about' ? Number(left[2]) : Math.min(2, Number(left[2]))
|
|
611
|
+
const s = 2
|
|
608
612
|
return Response.json({ refused: e.message, wait: e.wait, retryS: s }, { status: 503, headers: { ...NO_STORE, 'Retry-After': String(s) } })
|
|
609
613
|
}
|
|
610
614
|
}
|
|
@@ -14,7 +14,8 @@ import { bad, NO_STORE } from './http.ts'
|
|
|
14
14
|
import { isClosedAskState } from './model.ts'
|
|
15
15
|
import { answerSecret, readAll, secretQuestion } from './store.ts'
|
|
16
16
|
import { supersededRefusal } from './supersede.ts'
|
|
17
|
-
import {
|
|
17
|
+
import { membersOf, membersOfItem, threadOfItem, threadsOf } from './threads.ts'
|
|
18
|
+
import { askStateOf, isMoot, threadState } from './thread-state.ts'
|
|
18
19
|
|
|
19
20
|
const ROUTE = /^\/api\/review\/([^/]+)\/secret$/
|
|
20
21
|
|
|
@@ -30,7 +31,7 @@ function notAsked(dir: string, id: string, re: string, name: string, o: { replac
|
|
|
30
31
|
const closed = t === null ? undefined : askStateOf(t)?.state
|
|
31
32
|
// the ask's close moots its own fields; a secret question an agent asks after it waits as usual
|
|
32
33
|
const q = t === null ? undefined : membersOf(t).flatMap((x) => x.thread).find((m) => m.id === re)
|
|
33
|
-
if (isClosedAskState(closed) && (q === undefined || isMoot(t
|
|
34
|
+
if (isClosedAskState(closed) && (q === undefined || isMoot(threadState(t!), q))) return `${name}: its ask is ${closed}, nothing stored; reopen it to give a value`
|
|
34
35
|
if (o.replace === true && (t === null || askOfThread(t) === null)) return `${name} is stored already, and only an open ask's field replaces it: sk secret set ${name}`
|
|
35
36
|
return null
|
|
36
37
|
}
|
package/src/review/settle.ts
CHANGED
|
@@ -59,9 +59,3 @@ export function settledSpots(x: Pick<ReviewItem, 'item' | 'thread'>): Set<string
|
|
|
59
59
|
}
|
|
60
60
|
return new Set([...spots].filter(([, s]) => s).map(([k]) => k))
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
/** what is left for him on a version answered by acts, in words: « publish or drop X, Discord → releases » */
|
|
64
|
-
export function actsLeft(item: Pick<Item, 'draft'>, settled: readonly string[] = []): string {
|
|
65
|
-
const left = (item.draft?.posts ?? []).filter((p) => !settled.includes(p.key)).map((p) => p.name)
|
|
66
|
-
return left.length === 0 ? 'every place is settled' : `publish or drop ${left.join(', ')}`
|
|
67
|
-
}
|
package/src/review/snooze.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// a thread set aside until a time (wiki tools/shipkit/threads-asks.md, Snooze): his « set aside » from the hub, an
|
|
2
|
-
// agent's later day when it posts. The turn reads it from the clock (
|
|
2
|
+
// agent's later day when it posts. The turn reads it from the clock (thread-state.ts ThreadState aside), and an ask whose thread it
|
|
3
3
|
// is reads its later day from the same message (asks/ask-store.ts), so the ask leaves every count until the same time
|
|
4
4
|
import { appendMessage, readAll, readItem } from './store.ts'
|
|
5
|
-
import { threadOfAddress
|
|
5
|
+
import { threadOfAddress } from './threads.ts'
|
|
6
6
|
import type { Message } from './model.ts'
|
|
7
|
+
import { asideRefusal, threadState } from './thread-state.ts'
|
|
7
8
|
|
|
8
9
|
export { asideAt } from './aside-at.ts'
|
|
9
10
|
|
|
@@ -16,7 +17,8 @@ export function snoozeThread(dir: string, id: string, o: { until: Date | null; w
|
|
|
16
17
|
if (o.until !== null && o.until.getTime() <= now.getTime()) throw new Error('set aside until a time still ahead')
|
|
17
18
|
const own = x.item.on ?? ''
|
|
18
19
|
const t = own ? threadOfAddress(own, readAll(dir).items) : null
|
|
19
|
-
|
|
20
|
+
const refused = o.until !== null && o.who === 'owner' && t ? asideRefusal(threadState(t, now)) : null
|
|
21
|
+
if (refused !== null) throw new Error(refused)
|
|
20
22
|
const head = t?.head.item.id ?? id
|
|
21
23
|
const m = appendMessage(dir, head, { who: o.who, snooze: { until: o.until === null ? null : o.until.toISOString() } }, { now })
|
|
22
24
|
return m
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// who said a word, as an agent reads it: the owner by his role, an advisor by name with what their word is (wiki
|
|
2
|
+
// tools/shipkit/advisors.md, An advisor's word), any other party by its role. The one constraint a reader breaks first:
|
|
3
|
+
// a line names an advisor with the whole note, and only `oncePerBurst` shortens it, so a printer that forgets the pass
|
|
4
|
+
// prints the note too often, never too rarely
|
|
5
|
+
import type { Message } from './model.ts'
|
|
6
|
+
|
|
7
|
+
const NOTE = 'their need, input to weigh, never a spec; the design is yours'
|
|
8
|
+
|
|
9
|
+
/** an advisor as every line names them: the whole note */
|
|
10
|
+
export const advisorNote = (name: string): string => `« ${name}, an advisor: ${NOTE} »`
|
|
11
|
+
|
|
12
|
+
const short = (name: string): string => `« ${name}, an advisor »`
|
|
13
|
+
|
|
14
|
+
type Said = Pick<Message, 'who' | 'advisor' | 'text' | 'answer'>
|
|
15
|
+
|
|
16
|
+
/** an advisor's own word, or the owner's confirm of their advice (its words start `on <name>'s advice`,
|
|
17
|
+
* advisors/advice.ts confirmAdvice); null for any other */
|
|
18
|
+
function sourceOf(m: Said): { name: string; confirmed: boolean } | null {
|
|
19
|
+
if (m.who === 'player' && m.advisor !== undefined) return { name: m.advisor.name, confirmed: false }
|
|
20
|
+
const r = m.who === 'owner' ? /^on (.+?)'s advice(?::|$)/.exec(m.text ?? '') : null
|
|
21
|
+
return r ? { name: r[1]!, confirmed: true } : null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** the words that name an advisor's part in a message, null when it has none. A pick stands as the question's answer,
|
|
25
|
+
* so it names them short; words and a verdict's words carry the whole note */
|
|
26
|
+
function labelOf(m: Said): string | null {
|
|
27
|
+
const s = sourceOf(m)
|
|
28
|
+
if (s === null) return null
|
|
29
|
+
const who = m.answer !== undefined ? short(s.name) : advisorNote(s.name)
|
|
30
|
+
return s.confirmed ? `the owner, on the advice of ${who}` : who
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** true on a word an advisor wrote themselves */
|
|
34
|
+
export const byAnAdvisor = (m: Said): boolean => sourceOf(m)?.confirmed === false
|
|
35
|
+
|
|
36
|
+
/** the author of a word as a line names it: an advisor by their note, anyone else by `m.who` */
|
|
37
|
+
export const speakerOf = (m: Said): string => labelOf(m) ?? m.who
|
|
38
|
+
|
|
39
|
+
/** `by <label>` right after a line's leading id, on a message an advisor has a part in; the line as it is for any other */
|
|
40
|
+
export function byAdvisor(line: string, m: Said | undefined): string {
|
|
41
|
+
const l = m === undefined ? null : labelOf(m)
|
|
42
|
+
if (l === null) return line
|
|
43
|
+
const i = line.indexOf(' ')
|
|
44
|
+
return i < 0 ? `${line} by ${l}` : `${line.slice(0, i)} by ${l}${line.slice(i)}`
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** `by <label>, ` to lead a line, empty on a message no advisor has a part in */
|
|
48
|
+
export const byLead = (m: Said): string => {
|
|
49
|
+
const l = labelOf(m)
|
|
50
|
+
return l === null ? '' : `by ${l}, `
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const NOTED = new RegExp(`« ([^«»]+), an advisor: ${NOTE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} »`, 'g')
|
|
54
|
+
|
|
55
|
+
/** one burst of printed text (a watch's read, an inbox, a thread shown): each advisor's note kept the first time the
|
|
56
|
+
* burst names them, their short name after; called on each piece in the order it prints */
|
|
57
|
+
export function oncePerBurst(): (text: string) => string {
|
|
58
|
+
const named = new Set<string>()
|
|
59
|
+
return (text) =>
|
|
60
|
+
text.replace(NOTED, (whole, name: string) => {
|
|
61
|
+
if (named.has(name)) return short(name)
|
|
62
|
+
named.add(name)
|
|
63
|
+
return whole
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** the whole text as one burst */
|
|
68
|
+
export const notedOnce = (text: string): string => oncePerBurst()(text)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// the name of a thread a person starts, when they type none: their first line, else their first file's name, never
|
|
2
|
+
// « a new thread » while a file can name it. Pure and browser safe: the hub's start (start-st.ts), the owner's new
|
|
3
|
+
// conversation (orchestrator/talk-key.ts) and an advisor's proposal (advisors/advice.ts) all name it here
|
|
4
|
+
|
|
5
|
+
/** a file's tag in the words (`[image 2]`, `[file 1]`, hub-app attach-st.ts): no word of theirs */
|
|
6
|
+
const TAG = /\[(?:image|file) \d+\]/g
|
|
7
|
+
|
|
8
|
+
/** the name when nothing names it */
|
|
9
|
+
export const NO_TITLE = 'a new thread'
|
|
10
|
+
|
|
11
|
+
/** a file's name without its extension: « Circulaire 0271.docx » → « Circulaire 0271 » */
|
|
12
|
+
export const fileTitle = (name: string): string => name.trim().replace(/\.[A-Za-z0-9]{1,8}$/, '').replace(/[_\s]+$/, '').trim()
|
|
13
|
+
|
|
14
|
+
/** the typed title, else the first line of the words (their file tags dropped), else the first file's name */
|
|
15
|
+
export function startTitle(title: string, text: string, files: readonly { name: string }[] = []): string {
|
|
16
|
+
const line = (text.replace(TAG, ' ').trim().split('\n')[0] ?? '').replace(/\s+/g, ' ').trim()
|
|
17
|
+
const file = files.map((f) => fileTitle(f.name)).find((n) => n !== '') ?? ''
|
|
18
|
+
return (title.trim() || line || file || NO_TITLE).slice(0, 120)
|
|
19
|
+
}
|
|
@@ -20,3 +20,31 @@ export async function storeParties(dir: string, o: Pick<Parameters<typeof readPa
|
|
|
20
20
|
for (const r of readSessionRecords()) if (r.stores.includes(dir)) ids.add(r.session)
|
|
21
21
|
return { repo: repoNameOf(dirname(dirname(dir))), parties: await readParties({ sessions: [...ids], watchers: liveWatchers(dir), ...o }) }
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
/** a store's parties as the page reads them, read again at most every few seconds: the registry reads transcripts. A
|
|
25
|
+
* held answer stands only while the stamp it was read under holds: the page asks on the stream's notice that the
|
|
26
|
+
* parties moved, and nothing asks again after that answer */
|
|
27
|
+
const PARTIES_MS = 4000
|
|
28
|
+
const partiesHeld = new Map<string, { at: number; stamp: string; value: Promise<StoreParties> }>()
|
|
29
|
+
/** the cheap sign that a store's parties moved, given by the hub (serve/serve-hub.ts): its stream follows the same */
|
|
30
|
+
let partiesStampOf: (dir: string) => string = () => ''
|
|
31
|
+
export const partiesStampWith = (stamp: (dir: string) => string): void => {
|
|
32
|
+
partiesStampOf = stamp
|
|
33
|
+
}
|
|
34
|
+
/** who reads them: this process, or the daemon's read thread (serve/read-thread.ts), off the loop every page waits on */
|
|
35
|
+
let partiesReader: (dir: string) => Promise<StoreParties> = storeParties
|
|
36
|
+
export const readPartiesWith = (reader: (dir: string) => Promise<StoreParties>): void => {
|
|
37
|
+
partiesReader = reader
|
|
38
|
+
}
|
|
39
|
+
export function partiesOfStore(dir: string, now = Date.now()): Promise<StoreParties> {
|
|
40
|
+
const held = partiesHeld.get(dir)
|
|
41
|
+
const stamp = partiesStampOf(dir)
|
|
42
|
+
if (held && now - held.at < PARTIES_MS && held.stamp === stamp) return held.value
|
|
43
|
+
const value = partiesReader(dir)
|
|
44
|
+
// a read that failed is asked again by the next caller, never kept for its few seconds
|
|
45
|
+
value.catch(() => {
|
|
46
|
+
if (partiesHeld.get(dir)?.value === value) partiesHeld.delete(dir)
|
|
47
|
+
})
|
|
48
|
+
partiesHeld.set(dir, { at: now, stamp, value })
|
|
49
|
+
return value
|
|
50
|
+
}
|