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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// a thread moved whole to the repo it is about (wiki tools/shipkit/threads-essentials.md, A thread): every item with
|
|
2
|
+
// its head and each message as stored (verdicts, answers, read marks, holds), its media and its links, ids and times
|
|
3
|
+
// kept; one trace line on both sides, and a `moved` event in the old repo that its address and ids resolve by.
|
|
4
|
+
// The one constraint a reader breaks first: a move is the owner's act alone. It runs from the hub's routes (an owner
|
|
5
|
+
// word route, http/owner-word.ts): his « move to project… » or his click on the move an agent suggested
|
|
6
|
+
// (`sk thread suggest-move`); no verb an agent types moves a thread
|
|
7
|
+
import { cpSync, existsSync } from 'node:fs'
|
|
8
|
+
import { homedir } from 'node:os'
|
|
9
|
+
import { join } from 'node:path'
|
|
10
|
+
import { repoNameOf } from '../agent-time/registry.ts'
|
|
11
|
+
import { houseRepos } from '../house/project-gutter.ts'
|
|
12
|
+
import { itemsDb, repoIdOf } from './item-db.ts'
|
|
13
|
+
import { appendEvent, eventOfRow, eventsRepo, landEvents } from './events.ts'
|
|
14
|
+
import { ID_RE, specProblems, type Message } from './model.ts'
|
|
15
|
+
import { appendMessage, itemOfRef, landCopy, mediaDir, rawHead, rawMessage, readAll, readItem, setAside, specOf, storeDir, threadIds } from './store.ts'
|
|
16
|
+
import { membersOf, ownAddressesOf, THREAD_ID_RE, threadIdOf, threadOfAddress, threadOfItem, threadsOf, threadsOfId, type Thread } from './threads.ts'
|
|
17
|
+
|
|
18
|
+
/** where a moved thread went: the repo by name and root, its head and address there */
|
|
19
|
+
export interface Moved {
|
|
20
|
+
to: string
|
|
21
|
+
root: string
|
|
22
|
+
head: string
|
|
23
|
+
address: string | null
|
|
24
|
+
ids: string[]
|
|
25
|
+
by: string
|
|
26
|
+
at: number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** a thread of the store by any of its names: its address, its thread id, an item id of it */
|
|
30
|
+
function threadOfRef(dir: string, ref: string): Thread | null {
|
|
31
|
+
const items = readAll(dir).items
|
|
32
|
+
const spec = specOf(dir)
|
|
33
|
+
if (THREAD_ID_RE.test(ref)) return threadsOfId(ref, threadsOf(items, spec))[0] ?? null
|
|
34
|
+
if (!ID_RE.test(ref) && ref.includes(':')) return threadOfAddress(ref, items, spec, { up: true })
|
|
35
|
+
const x = itemOfRef(dir, ref)
|
|
36
|
+
return x === null ? null : threadOfItem(x.item.id, threadsOf(items, spec))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** the thread `ref` names in the store of `fromRoot` moved whole into the store of `toRoot`, by the owner. Refused for
|
|
40
|
+
* an agent, for the same repo, for an ask's or a blocked command's thread (their records are their repo's), and when
|
|
41
|
+
* the other store holds a thread on its address or an item of its ids */
|
|
42
|
+
export function moveThread(fromRoot: string, ref: string, toRoot: string, o: { by: string; now?: Date }): Moved {
|
|
43
|
+
if (o.by !== 'owner') throw new Error(`${o.by} may not move a thread: the owner moves it; suggest it with sk thread suggest-move <address> <repo> "<why>"`)
|
|
44
|
+
const fromDir = storeDir(fromRoot)
|
|
45
|
+
const toDir = storeDir(toRoot)
|
|
46
|
+
const from = repoNameOf(fromRoot)
|
|
47
|
+
const to = repoNameOf(toRoot)
|
|
48
|
+
if (repoIdOf(fromDir) === repoIdOf(toDir)) throw new Error(`the thread is in ${to} already`)
|
|
49
|
+
const t = threadOfRef(fromDir, ref)
|
|
50
|
+
if (t === null) throw new Error(`no thread ${ref} in ${from}`)
|
|
51
|
+
const spec = specOf(fromDir)
|
|
52
|
+
const address = ownAddressesOf(t, spec)[0] ?? null
|
|
53
|
+
if (address !== null && /^(ask|blocked):/.test(address)) throw new Error(`${address}: an ${address.slice(0, address.indexOf(':'))} thread stays in the repo whose record it is`)
|
|
54
|
+
const members = membersOf(t)
|
|
55
|
+
const ids = members.map((x) => x.item.id)
|
|
56
|
+
const there = readAll(toDir).items
|
|
57
|
+
if (address !== null && threadOfAddress(address, there, specOf(toDir)) !== null) throw new Error(`${to} has its own thread on ${address}: write in it, or close one of them`)
|
|
58
|
+
const taken = ids.filter((id) => there.some((x) => x.item.id === id))
|
|
59
|
+
if (taken.length > 0) throw new Error(`${to} holds an item of the same id: ${taken.join(', ')}`)
|
|
60
|
+
const wrong = members.flatMap((x) => specProblems(x.item, specOf(toDir)).map((p) => `${x.item.id}: ${p}`))
|
|
61
|
+
if (wrong.length > 0) throw new Error(`${to} does not read this thread: ${wrong.join('; ')}`)
|
|
62
|
+
const now = o.now ?? new Date()
|
|
63
|
+
const copied: string[] = []
|
|
64
|
+
try {
|
|
65
|
+
for (const id of ids) {
|
|
66
|
+
const held = rawHead(fromDir, id)
|
|
67
|
+
if (held === null) throw new Error(`${id}: no head in ${from}`)
|
|
68
|
+
const media = join(mediaDir(fromDir), id)
|
|
69
|
+
if (existsSync(media)) cpSync(media, join(mediaDir(toDir), id), { recursive: true })
|
|
70
|
+
landCopy(toDir, id, held.head, held.at, threadIds(fromDir, id).map((mid) => rawMessage(fromDir, id, mid)))
|
|
71
|
+
copied.push(id)
|
|
72
|
+
}
|
|
73
|
+
} catch (e) {
|
|
74
|
+
// the copies made so far go aside, so the thread stays whole where it was
|
|
75
|
+
for (const id of copied) setAside(toDir, id)
|
|
76
|
+
throw e
|
|
77
|
+
}
|
|
78
|
+
const keys = new Set([...ids, ...(address === null ? [] : [address]), threadIdOf(t)])
|
|
79
|
+
const fromRepo = eventsRepo(fromDir)
|
|
80
|
+
const db = itemsDb()
|
|
81
|
+
const links = (db.query("select * from thread_events where repo = ? and type = 'link' order by seq").all(fromRepo) as Parameters<typeof eventOfRow>[0][]).map(eventOfRow).filter((e) => keys.has(e.thread))
|
|
82
|
+
if (links.length > 0) landEvents(eventsRepo(toDir), links.map(({ repo: _r, seq: _s, ...e }) => e), db)
|
|
83
|
+
const head = t.head.item.id
|
|
84
|
+
const trace: Omit<Message, 'id' | 'at'> = { who: o.by, moved: { from, to } }
|
|
85
|
+
appendMessage(toDir, head, trace, { now })
|
|
86
|
+
appendMessage(fromDir, head, trace, { now })
|
|
87
|
+
const moved: Moved = { to, root: toRoot, head, address, ids, by: o.by, at: now.getTime() }
|
|
88
|
+
appendEvent(fromRepo, { type: 'moved', sender: o.by, thread: address ?? head, at: moved.at, content: { title: `moved to ${to}`, moved } }, db)
|
|
89
|
+
for (const id of ids) setAside(fromDir, id)
|
|
90
|
+
return moved
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** where the thread `ref` names went, when it left this store: by its address, its thread id, an item id, or an item
|
|
94
|
+
* id with a message (`<id>/<message>`); the newest move first. Null when it never left */
|
|
95
|
+
export function movedOf(dir: string, ref: string): Moved | null {
|
|
96
|
+
const id = ref.trim().replace(/\/.*$/, '').replace(/^t-/, '')
|
|
97
|
+
const rows = itemsDb().query("select * from thread_events where repo = ? and type = 'moved' order by seq desc").all(eventsRepo(dir)) as Parameters<typeof eventOfRow>[0][]
|
|
98
|
+
for (const r of rows) {
|
|
99
|
+
const m = eventOfRow(r).content.moved as Moved | undefined
|
|
100
|
+
if (m != null && (m.address === ref.trim() || m.ids.includes(id))) return m
|
|
101
|
+
}
|
|
102
|
+
return null
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** the line a reader of a moved thread's old place gets: where it is now and the command that opens it there */
|
|
106
|
+
export const movedLine = (ref: string, m: Moved): string => `${ref} moved to ${m.to}: its thread is there now, cd ${m.root.replace(homedir(), '~')} && sk thread show ${m.address ?? m.head}`
|
|
107
|
+
|
|
108
|
+
/** the root of a house repo by its name, from the repo at `root`; null for a name no house repo has */
|
|
109
|
+
export function houseRootOf(root: string, name: string): string | null {
|
|
110
|
+
return houseRepos(root, homedir()).repos.find((r) => r.name === name)?.path ?? null
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** the house repos a thread of the repo at `root` may move to: every one but its own, by name */
|
|
114
|
+
export function moveTargetsOf(root: string): string[] {
|
|
115
|
+
const own = repoNameOf(root)
|
|
116
|
+
return houseRepos(root, homedir()).repos.map((r) => r.name).filter((n) => n !== own)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** the question an agent asks to suggest a move: option 0 moves the thread at his click, option 1 keeps it */
|
|
120
|
+
export const suggestMoveQuestion = (to: string, why: string): { text: string; options: string[]; pick: number; move: { to: string } } => ({
|
|
121
|
+
text: `This is about ${to}: move it there?${why.trim() === '' ? '' : `\n\n${why.trim()}`}`,
|
|
122
|
+
options: [`move to ${to}`, 'keep it here'],
|
|
123
|
+
pick: 0,
|
|
124
|
+
move: { to },
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
/** the move a question's options ask, typed by hand with sk thread ask: « move to <repo> » then « keep it here » */
|
|
128
|
+
export function moveOfOptions(options: readonly string[]): { to: string } | null {
|
|
129
|
+
const m = options.length === 2 && options[1]!.trim() === 'keep it here' ? /^move to ([\w.-]+)$/.exec(options[0]!.trim()) : null
|
|
130
|
+
return m === null ? null : { to: m[1]! }
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** after the owner's answer `answer` on item `id`: his « move to <repo> » on a move question moves the thread there; its
|
|
134
|
+
* outcome a line, a refusal said in the thread so it is never silent */
|
|
135
|
+
export function moveOnAnswer(root: string, id: string, answer: Message, o: { rootOf?: (name: string) => string | null; now?: Date } = {}): Moved | null {
|
|
136
|
+
if (answer.answer?.option !== 0 || answer.re === undefined) return null
|
|
137
|
+
const dir = storeDir(root)
|
|
138
|
+
const q = readItem(dir, id)?.thread.find((m) => m.id === answer.re)
|
|
139
|
+
const to = q?.ask?.move?.to
|
|
140
|
+
if (to === undefined) return null
|
|
141
|
+
const toRoot = (o.rootOf ?? ((n: string) => houseRootOf(root, n)))(to)
|
|
142
|
+
try {
|
|
143
|
+
if (toRoot === null) throw new Error(`no house repo ${to}`)
|
|
144
|
+
return moveThread(root, id, toRoot, { by: 'owner', ...(o.now ? { now: o.now } : {}) })
|
|
145
|
+
} catch (e) {
|
|
146
|
+
appendMessage(dir, id, { who: 'machine', text: `not moved to ${to}: ${(e as Error).message}` }, { machine: true })
|
|
147
|
+
return null
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -8,7 +8,8 @@ import type { Resource } from '../collections/collection-types.ts'
|
|
|
8
8
|
import { canonicalAddress, updatesOf } from './model.ts'
|
|
9
9
|
import { NEED_KINDS, needAddress } from './need-address.ts'
|
|
10
10
|
import { postUpdate, readAll, storeDir, storeStamp } from './store.ts'
|
|
11
|
-
import {
|
|
11
|
+
import { type Thread } from './threads.ts'
|
|
12
|
+
import { orderedThreads, threadState } from './thread-state.ts'
|
|
12
13
|
|
|
13
14
|
export interface NeedSync {
|
|
14
15
|
fixed: number
|
|
@@ -41,7 +42,7 @@ export async function syncNeedThreads(root: string, repo: string, needs: readonl
|
|
|
41
42
|
if (a !== null && t.head.item.origin.by === 'agent' && prefixes.some((p) => a.startsWith(p)) && !mine.has(a)) mine.set(a, t)
|
|
42
43
|
}
|
|
43
44
|
for (const [a, t] of mine) {
|
|
44
|
-
if (standing.has(a) || lastState(t) === 'fixed' ||
|
|
45
|
+
if (standing.has(a) || lastState(t) === 'fixed' || threadState(t, now).turn === 'done') continue
|
|
45
46
|
await postUpdate(dir, t.head.item.id, { who: 'agent', state: 'fixed', text: 'folded: its file is gone from .shipkit/reflections/', machine: true, now })
|
|
46
47
|
out.fixed++
|
|
47
48
|
}
|
|
@@ -41,6 +41,17 @@ export interface ObjectCard {
|
|
|
41
41
|
/** a state with its card beside its json */
|
|
42
42
|
export type CardState = StoredState & { card?: ObjectCard }
|
|
43
43
|
|
|
44
|
+
/** what an action's word box starts with (KindAction `fill`): each line of the object's words that begins `<label>:`,
|
|
45
|
+
* its code marks dropped, one a line */
|
|
46
|
+
export function fillOf(md: string, label: string): string {
|
|
47
|
+
const head = `${label}:`
|
|
48
|
+
return md
|
|
49
|
+
.split('\n')
|
|
50
|
+
.filter((l) => l.startsWith(head))
|
|
51
|
+
.map((l) => l.slice(head.length).trim().replace(/^`(.*)`$/s, '$1'))
|
|
52
|
+
.join('\n')
|
|
53
|
+
}
|
|
54
|
+
|
|
44
55
|
/** the card a state carries, null when it carries none or one the hub cannot draw */
|
|
45
56
|
export function cardOf(s: StoredState | undefined): ObjectCard | null {
|
|
46
57
|
const c = (s as CardState | undefined)?.card
|
|
@@ -10,11 +10,14 @@ import { HOUSE_LAYOUT } from '../core/house-layout.ts'
|
|
|
10
10
|
import { queueDir } from '../reflections/reflections-queue.ts'
|
|
11
11
|
import type { ObjectRead } from './cells.ts'
|
|
12
12
|
import { readReflection, reflectionOfAddress } from './reflection-object.ts'
|
|
13
|
+
import { blockedOfAddress, blockedTag, readBlocked } from './blocked-object.ts'
|
|
13
14
|
|
|
14
15
|
/** `harvested`: the house's harvested folder (harvestedOf); null reads the queue alone */
|
|
15
16
|
export const objectReaderOf =
|
|
16
17
|
(root: string, repo = basename(root), o: { harvested?: string | null } = {}): ObjectRead =>
|
|
17
18
|
(address) => {
|
|
19
|
+
const b = blockedOfAddress(address)
|
|
20
|
+
if (b !== null) return b.repo === repo ? readBlocked(root, b.hash) : null
|
|
18
21
|
const r = reflectionOfAddress(address)
|
|
19
22
|
return r === null || r.repo !== repo ? null : readReflection(root, r.repo, r.file, o.harvested ?? null)
|
|
20
23
|
}
|
|
@@ -35,7 +38,9 @@ export async function harvestedOf(root: string): Promise<string | null> {
|
|
|
35
38
|
|
|
36
39
|
/** a word that moves when a file the reader reads moves (added, edited, folded away): a thread view's tag carries it, so a
|
|
37
40
|
* card never shows a reflection as it stood before */
|
|
38
|
-
export
|
|
41
|
+
export const objectsTag = (root: string): string => `${reflectionsTag(root)}-${blockedTag(root)}`
|
|
42
|
+
|
|
43
|
+
function reflectionsTag(root: string): string {
|
|
39
44
|
const dir = queueDir(root)
|
|
40
45
|
let h = 0
|
|
41
46
|
try {
|
package/src/review/one-block.ts
CHANGED
|
@@ -44,7 +44,7 @@ export function spotWords(item: Item, n: number, s: Spot): string {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/** where the reply box's words go: a spot of a version, a kind's action that takes words. `label` names it on the chip.
|
|
47
|
-
* `version` is a fix on the whole version, its words the verdict's own note (
|
|
47
|
+
* `version` is a fix on the whole version, its words the verdict's own note (tone-bar.tsx), never the reply box's */
|
|
48
48
|
export type ReplyOn =
|
|
49
49
|
| { to: 'spot'; version: string; spot: Spot; label: string }
|
|
50
50
|
| { to: 'version'; version: string; label: string }
|
package/src/review/owner-read.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// thread's « you read up to here ». Pure and browser safe
|
|
4
4
|
// the one constraint a reader breaks first: « your turn » is no news. A version that waits for the owner's verdict is new only
|
|
5
5
|
// until he opens the thread; the turn says it waits, the cursor says whether he saw it
|
|
6
|
-
import type { Turn } from './band.ts'
|
|
7
6
|
import { handedOver, isReply, partyOf, type ReviewItem } from './model.ts'
|
|
7
|
+
import { type Turn } from './thread-state.ts'
|
|
8
8
|
|
|
9
9
|
/** a turn whose news the pills count: a done thread he never opened and one set aside never call him */
|
|
10
10
|
export const countsUnread = (turn: Turn): boolean => turn === 'yours' || turn === 'agents'
|
package/src/review/phone-push.ts
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
// push path, orchestrator/push.ts pushNow
|
|
6
6
|
// the one constraint a reader breaks first: the text lands on a public server, so the title and the line pass the
|
|
7
7
|
// advisors' leak scan first, and what waited while muted or quiet is dropped, never sent later as a backlog
|
|
8
|
-
import { isReply, type Message, type ReviewItem } from './model.ts'
|
|
8
|
+
import { isClosedAskState, isReply, type Message, type ReviewItem } from './model.ts'
|
|
9
9
|
import { newToOwner } from './owner-read.ts'
|
|
10
|
-
import {
|
|
10
|
+
import { membersOf, threadTitle, type Thread } from './threads.ts'
|
|
11
|
+
import { threadState } from './thread-state.ts'
|
|
11
12
|
|
|
12
13
|
/** a thread pushes once the newest of what waits has settled this long: what lands meanwhile joins the push */
|
|
13
14
|
export const PHONE_SETTLE_MS = 20_000
|
|
@@ -63,8 +64,8 @@ export function mutedOf(t: Thread): boolean {
|
|
|
63
64
|
return muted
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
/** an agent's word that waits on him: a request the
|
|
67
|
-
*
|
|
67
|
+
/** an agent's word that waits on him: a request the thread's state lists as waiting on the owner (`open`, so one
|
|
68
|
+
* answered, superseded, withdrawn or mooted by the owner's close never pushes; a question with a row per thing once), or a plain reply after a word of his. An
|
|
68
69
|
* update line is progress, never a push */
|
|
69
70
|
const waitsOnHim = (m: Message & { on: string }, open: ReadonlySet<string>, spokeAt: string): boolean =>
|
|
70
71
|
m.who !== 'machine' && (open.has(`${m.on}/${m.id}`) || (spokeAt !== '' && spokeAt < m.at && isReply(m) && m.ask === undefined && m.propose === undefined && m.asksVerdict !== true && m.update === undefined))
|
|
@@ -77,12 +78,12 @@ const firstWordAt = (members: readonly ReviewItem[]): string =>
|
|
|
77
78
|
* and the words of waitsOnHim; nothing on a thread set aside */
|
|
78
79
|
export function phoneItemsOf(t: Thread, repo: string, now = new Date()): PhoneItem[] {
|
|
79
80
|
// an open ask's thread pushes through the needs pings, its `pinged` mark the one that says it went (collections/pings.ts)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (turn === 'aside') return []
|
|
81
|
+
const s = threadState(t, now)
|
|
82
|
+
if (s.ask !== null && !isClosedAskState(s.ask.state)) return []
|
|
83
|
+
if (s.turn === 'aside') return []
|
|
83
84
|
const members = membersOf(t)
|
|
84
85
|
const spoke = firstWordAt(members)
|
|
85
|
-
const open = new Set(
|
|
86
|
+
const open = new Set(s.waitsOwner.filter((w) => w.what === 'question' || w.what === 'change' || w.what === 'steps' || w.what === 'words').map((w) => w.id))
|
|
86
87
|
const byId = new Map(members.map((x) => [x.item.id, x]))
|
|
87
88
|
const out: PhoneItem[] = []
|
|
88
89
|
for (const f of newToOwner(members)) {
|
|
@@ -90,7 +91,7 @@ export function phoneItemsOf(t: Thread, repo: string, now = new Date()): PhoneIt
|
|
|
90
91
|
const x = byId.get(item)
|
|
91
92
|
if (x === undefined) continue
|
|
92
93
|
if (msg === undefined) {
|
|
93
|
-
if (
|
|
94
|
+
if (x === t.head && s.headWaits) out.push({ key: `${repo}/${item}`, at: f.at, line: `${x.item.origin.by === 'agent' && x.item.origin.lane ? `${x.item.origin.lane}: ` : ''}a version waits for your verdict: ${firstLine(x.item.title)}` })
|
|
94
95
|
continue
|
|
95
96
|
}
|
|
96
97
|
const m = x.thread.find((y) => y.id === msg)
|
package/src/review/previews.ts
CHANGED
|
@@ -11,14 +11,14 @@ import { ensureLocal, remotePreviewUrl, remoteUrl } from './media-read.ts'
|
|
|
11
11
|
import { mediaDir, rawHead } from './store.ts'
|
|
12
12
|
import { spoolOf } from './item-db.ts'
|
|
13
13
|
import { bytesWords } from '../core/words.ts'
|
|
14
|
-
import {
|
|
14
|
+
import { PREVIEW_BOX, type PreviewSize } from './view-layout.ts'
|
|
15
15
|
|
|
16
|
+
export type { PreviewSize }
|
|
16
17
|
/** `tile` a small gallery tile, a list row's or a strip's picture, `thumb` a larger tile, `fit` a view in the thread
|
|
17
18
|
* column: the widest each is drawn, at 2x. A `tile` also fits the height of that frame, so a tall image stays tiny */
|
|
18
|
-
export const PREVIEW_W = { tile:
|
|
19
|
-
export type PreviewSize = keyof typeof PREVIEW_W
|
|
19
|
+
export const PREVIEW_W = { tile: PREVIEW_BOX.tile.w, thumb: PREVIEW_BOX.thumb.w, fit: PREVIEW_BOX.fit.w } as const
|
|
20
20
|
export const isPreviewSize = (s: string): s is PreviewSize => s in PREVIEW_W
|
|
21
|
-
const PREVIEW_H: Partial<Record<PreviewSize, number>> = { tile:
|
|
21
|
+
const PREVIEW_H: Partial<Record<PreviewSize, number>> = { tile: PREVIEW_BOX.tile.h }
|
|
22
22
|
const QUALITY: Record<PreviewSize, number> = { tile: 70, thumb: 75, fit: 82 }
|
|
23
23
|
|
|
24
24
|
const IMAGE = /\.(png|jpe?g|webp)$/i
|
|
@@ -145,6 +145,34 @@ export async function previewFile(dir: string, id: string, name: string, size: P
|
|
|
145
145
|
return job
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
/** any image file at most `w` px wide (never enlarged), a webp in `cacheDir` named by `key`, made once on the same
|
|
149
|
+
* job slots as the previews above and made again only when its source is newer; null when the file does not read.
|
|
150
|
+
* The pages that show a repo's own pictures in tiles (a store's screenshots) read it, never the full file */
|
|
151
|
+
export async function sizedImage(src: string, cacheDir: string, key: string, w: number): Promise<string | null> {
|
|
152
|
+
if (!IMAGE.test(src) || !existsSync(src)) return null
|
|
153
|
+
const out = join(cacheDir, `${key.replace(/[^\w.-]+/g, '_')}.${w}.webp`)
|
|
154
|
+
const at = statSync(src).mtimeMs
|
|
155
|
+
if (existsSync(out) && statSync(out).mtimeMs >= at) return out
|
|
156
|
+
const pending = making.get(out)
|
|
157
|
+
if (pending) return pending
|
|
158
|
+
const job = slot(async () => {
|
|
159
|
+
mkdirSync(dirname(out), { recursive: true })
|
|
160
|
+
const tmp = `${out}.${process.pid}.tmp`
|
|
161
|
+
try {
|
|
162
|
+
const { default: sharp } = await import('sharp')
|
|
163
|
+
await sharp(src).resize({ width: w, withoutEnlargement: true }).webp({ quality: 82 }).toFile(tmp)
|
|
164
|
+
renameSync(tmp, out)
|
|
165
|
+
return out
|
|
166
|
+
} catch (e) {
|
|
167
|
+
rmSync(tmp, { force: true })
|
|
168
|
+
console.error(`FAIL: a ${w} px copy of ${src}: ${(e as Error).message}`)
|
|
169
|
+
return null
|
|
170
|
+
}
|
|
171
|
+
}).finally(() => making.delete(out))
|
|
172
|
+
making.set(out, job)
|
|
173
|
+
return job
|
|
174
|
+
}
|
|
175
|
+
|
|
148
176
|
/** every preview being made has landed: a test removes its folder only after */
|
|
149
177
|
export const previewsSettled = async (): Promise<void> => void (await Promise.all([...making.values()]))
|
|
150
178
|
|
package/src/review/push.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
// machine, the projects, each repo's rows, media and parties. Each source is a cheap stamp (a counter, an mtime, an
|
|
8
8
|
// in-memory state) read every SOURCE_TICK_MS while a page listens, or a write that says it at once (`moved`); a stamp
|
|
9
9
|
// that moved sends `event: src` naming it, and the page reads that source alone.
|
|
10
|
-
// the one constraint a reader breaks first: nothing here reads while no page listens, and a read that fails (a
|
|
11
|
-
//
|
|
10
|
+
// the one constraint a reader breaks first: nothing here reads while no page listens, and a read that fails (a repair
|
|
11
|
+
// holds the database) says nothing: the page's slow poll is the net, never a notice that lies
|
|
12
12
|
import type { Database } from 'bun:sqlite'
|
|
13
13
|
import { itemsDb, repoIdOf } from './item-db.ts'
|
|
14
14
|
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// a recap of a long thread (wiki tools/shipkit/threads.md, A recap): an agent's words in four sections that ask the
|
|
2
|
+
// owner's verdict like a version. Accepted (ok, or ok with a fix), it is where every reader of the thread starts: the
|
|
3
|
+
// newest accepted one covers every recap before it. Nothing is deleted or rewritten: the store keeps every message.
|
|
4
|
+
// The cut itself (what stays in sight before it) is the thread state model's (review/thread-state.ts recapCut).
|
|
5
|
+
// the one constraint a reader breaks first: a recap the owner has not accepted cuts nothing; until the owner's ok the thread reads whole
|
|
6
|
+
import { partyOf, type Message, type ReviewItem } from './model.ts'
|
|
7
|
+
import { verdictOnMessage } from './verdict-items.ts'
|
|
8
|
+
|
|
9
|
+
/** the sections of a recap, in this order, each a `## ` heading */
|
|
10
|
+
export const RECAP_SECTIONS = ['Decided', 'Live now', 'Open', 'Links'] as const
|
|
11
|
+
|
|
12
|
+
/** what a section holds, as the verb's refusal says it */
|
|
13
|
+
const SECTION_SAYS: Record<(typeof RECAP_SECTIONS)[number], string> = {
|
|
14
|
+
Decided: "what was settled, the owner's words quoted where they set a rule: - <what> (« <the owner's words> »)",
|
|
15
|
+
'Live now': 'what stands now, built or decided: - <what>',
|
|
16
|
+
Open: 'each thing still open with who owes it: - <who>: <what> (owner, or a lane), or - none',
|
|
17
|
+
Links: 'the versions and messages that matter, by id: - `<id>` <why>, or - none',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** the size of `sk thread show --md` past which an agent may offer the owner a recap, in bytes: about 4,000 tokens */
|
|
21
|
+
export const RECAP_OFFER_BYTES = 15_000
|
|
22
|
+
|
|
23
|
+
/** the words of the owner's request (the hub's « recap »), and of the question an agent offers the owner with */
|
|
24
|
+
export const RECAP_ASK_WORDS = 'recap this thread, so it reads from the recap on'
|
|
25
|
+
export const RECAP_OFFER_WORDS = 'recap this thread? It then reads from the recap on, the history one click away'
|
|
26
|
+
|
|
27
|
+
const ID = /`([^`\s]+)`/g
|
|
28
|
+
|
|
29
|
+
/** each problem of a recap's words: a missing or misplaced section, an empty one, an open line that names nobody, a
|
|
30
|
+
* link that names no id of the thread (`ids`, items and messages; empty checks none) */
|
|
31
|
+
export function recapProblems(body: string, ids: ReadonlySet<string> = new Set()): string[] {
|
|
32
|
+
const out: string[] = []
|
|
33
|
+
const heads = [...body.matchAll(/^##[ \t]+(.+?)\s*$/gm)].map((m) => ({ name: m[1]!, at: m.index! }))
|
|
34
|
+
const named = heads.map((h) => RECAP_SECTIONS.find((s) => s.toLowerCase() === h.name.toLowerCase()) ?? null)
|
|
35
|
+
for (const h of heads.filter((_, i) => named[i] === null)) out.push(`## ${h.name}: no section of a recap (${RECAP_SECTIONS.map((s) => `## ${s}`).join(', ')})`)
|
|
36
|
+
const kept = heads.flatMap((h, i) => (named[i] === null ? [] : [{ ...h, section: named[i]!, i }]))
|
|
37
|
+
for (const s of RECAP_SECTIONS) {
|
|
38
|
+
const n = kept.filter((h) => h.section === s).length
|
|
39
|
+
if (n === 0) out.push(`## ${s} is missing: ${SECTION_SAYS[s]}`)
|
|
40
|
+
if (n > 1) out.push(`## ${s} is there ${n} times: one each`)
|
|
41
|
+
}
|
|
42
|
+
const order = kept.map((h) => RECAP_SECTIONS.indexOf(h.section))
|
|
43
|
+
if (order.some((o, i) => i > 0 && o < order[i - 1]!)) out.push(`the sections go in this order: ${RECAP_SECTIONS.join(', ')}`)
|
|
44
|
+
for (const h of kept) {
|
|
45
|
+
const end = heads.find((x) => x.at > h.at)?.at ?? body.length
|
|
46
|
+
const lines = body.slice(h.at, end).split('\n').slice(1).map((l) => l.trim()).filter((l) => l !== '')
|
|
47
|
+
if (lines.length === 0) {
|
|
48
|
+
out.push(`## ${h.section} is empty: ${SECTION_SAYS[h.section]}`)
|
|
49
|
+
continue
|
|
50
|
+
}
|
|
51
|
+
const bullets = lines.filter((l) => /^[-*]\s/.test(l))
|
|
52
|
+
if (h.section === 'Open')
|
|
53
|
+
for (const b of bullets) if (!/^[-*]\s+none\b/i.test(b) && !/^[-*]\s+\**[\w.@-]+\**(?:\s+owes)?\s*:\s*\S/.test(b)) out.push(`## Open: « ${b.slice(0, 80)} » names nobody who owes it: - <who>: <what>`)
|
|
54
|
+
if (h.section === 'Links')
|
|
55
|
+
for (const b of bullets) {
|
|
56
|
+
if (/^[-*]\s+none\b/i.test(b)) continue
|
|
57
|
+
const named = [...b.matchAll(ID)].map((m) => m[1]!)
|
|
58
|
+
if (named.length === 0) out.push(`## Links: « ${b.slice(0, 80)} » names no id: - \`<id>\` <why>`)
|
|
59
|
+
else if (ids.size > 0 && !named.some((x) => ids.has(x) || ids.has(x.split('/').at(-1)!))) out.push(`## Links: « ${b.slice(0, 80)} » names no id of this thread (sk thread show <address> --md lists them)`)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return out
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** a recap of the thread and where it stands: its message, the item it sits on */
|
|
66
|
+
export interface RecapRef {
|
|
67
|
+
id: string
|
|
68
|
+
on: string
|
|
69
|
+
at: string
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** the thread's recaps: the newest the owner accepted, the newest still waiting on the owner's verdict, the owner's request no recap answered yet
|
|
73
|
+
* (the owner's « recap », or the owner's yes to an agent's offer), and an agent's offer still open or that the owner declined: either stops a
|
|
74
|
+
* new offer */
|
|
75
|
+
export interface RecapState {
|
|
76
|
+
accepted: RecapRef | null
|
|
77
|
+
waits: RecapRef | null
|
|
78
|
+
asked: RecapRef | null
|
|
79
|
+
offer?: 'open' | 'declined'
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const accepts = (thread: readonly Message[], m: Message): boolean => {
|
|
83
|
+
const v = verdictOnMessage(thread, m)
|
|
84
|
+
return v !== null && (v.status === 'approved' || v.status === 'approved-with-fix')
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** the recaps of the thread's items (wiki tools/shipkit/threads.md, A recap); null when it holds none and asks none */
|
|
88
|
+
export function recapStateOf(members: readonly ReviewItem[]): RecapState | null {
|
|
89
|
+
let accepted: RecapRef | null = null
|
|
90
|
+
let waits: RecapRef | null = null
|
|
91
|
+
let asked: RecapRef | null = null
|
|
92
|
+
let newest = ''
|
|
93
|
+
let offer: RecapState['offer']
|
|
94
|
+
for (const x of members)
|
|
95
|
+
for (const m of x.thread) {
|
|
96
|
+
if (m.recapAsk === true && partyOf(m.who) === 'owner' && (asked === null || m.at >= asked.at)) asked = { id: m.id, on: x.item.id, at: m.at }
|
|
97
|
+
// an agent's offer (`sk thread recap --offer`): the owner's yes is the owner's request, the owner's « not now » stands
|
|
98
|
+
if (m.ask !== undefined && m.text === RECAP_OFFER_WORDS && partyOf(m.who) === 'agent') {
|
|
99
|
+
const a = [...x.thread].reverse().find((y) =>y.re === m.id && y.answer?.option !== undefined && partyOf(y.who) === 'owner')
|
|
100
|
+
if (a === undefined) offer = 'open'
|
|
101
|
+
else if (a.answer!.option === 0) {
|
|
102
|
+
if (asked === null || a.at >= asked.at) asked = { id: a.id, on: x.item.id, at: a.at }
|
|
103
|
+
} else offer = 'declined'
|
|
104
|
+
}
|
|
105
|
+
if (m.recap !== true || partyOf(m.who) !== 'agent') continue
|
|
106
|
+
if (m.at > newest) newest = m.at
|
|
107
|
+
const ref = { id: m.id, on: x.item.id, at: m.at }
|
|
108
|
+
if (accepts(x.thread, m)) {
|
|
109
|
+
if (accepted === null || m.at >= accepted.at) accepted = ref
|
|
110
|
+
} else if (verdictOnMessage(x.thread, m) === null && !x.thread.some((y) => y.replaces === m.id) && (waits === null || m.at >= waits.at)) waits = ref
|
|
111
|
+
}
|
|
112
|
+
// the owner's request stands until a recap comes after it
|
|
113
|
+
if (asked !== null && newest >= asked.at) asked = null
|
|
114
|
+
// a recap the owner answered with a newer one standing waits no more than the newer one
|
|
115
|
+
if (waits !== null && accepted !== null && accepted.at > waits.at) waits = null
|
|
116
|
+
return accepted === null && waits === null && asked === null && offer === undefined ? null : { accepted, waits, asked, ...(offer ? { offer } : {}) }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** an agent may offer the owner a recap: the thread reads past RECAP_OFFER_BYTES, no recap waits on the owner nor the owner's request, no
|
|
120
|
+
* offer is open, and the owner never declined one */
|
|
121
|
+
export const offersRecap = (bytes: number, r: RecapState | null): boolean => bytes > RECAP_OFFER_BYTES && r?.waits == null && r?.asked == null && r?.offer === undefined
|
|
122
|
+
|
|
123
|
+
/** the line `sk thread show --md` ends with past the threshold: how to offer, never a recap unasked */
|
|
124
|
+
export const offerLine = (bytes: number, address: string, bin = 'sk'): string =>
|
|
125
|
+
`this thread reads ${Math.round(bytes / 1000)} KB: offer the owner a recap (${bin} thread recap ${address} --offer), never write one the owner did not ask for`
|
|
126
|
+
|
|
127
|
+
/** under the owner's request, as the holder reads it: the verb that writes the recap */
|
|
128
|
+
export const recapHint = (m: Pick<Message, 'recapAsk'>, address: string, bin = 'sk'): string =>
|
|
129
|
+
m.recapAsk === true ? ` · write it: ${bin} thread recap ${address} --body <file> (## ${RECAP_SECTIONS.join(', ## ')})` : ''
|
package/src/review/referring.ts
CHANGED
|
@@ -5,8 +5,9 @@ import { itemsDb } from './item-db.ts'
|
|
|
5
5
|
import { eventsRepo } from './events.ts'
|
|
6
6
|
import { readAllCached, specOf, storeDir } from './store.ts'
|
|
7
7
|
import { verdictOf } from './model.ts'
|
|
8
|
-
import { holderOf, membersOf, ownAddressesOf, threadsNaming, threadsOf,
|
|
8
|
+
import { holderOf, membersOf, ownAddressesOf, threadsNaming, threadsOf, type Thread } from './threads.ts'
|
|
9
9
|
import { workingsOf } from './traces.ts'
|
|
10
|
+
import { threadState } from './thread-state.ts'
|
|
10
11
|
|
|
11
12
|
/** the keys of the threads that refer to `<kind>:<key>` or a part of it (`<kind>:<key>/…`), each once: a thread's own
|
|
12
13
|
* address, else its head item's id, the way `sk thread show` and a link's `thread` name it */
|
|
@@ -53,9 +54,11 @@ export function workingThreadOf(root: string, me: { lane: string | null; session
|
|
|
53
54
|
let best: { t: Thread; at: string } | null = null
|
|
54
55
|
for (const t of threadsOf(readAllCached(dir).items, specOf(dir))) {
|
|
55
56
|
const h = holderOf(t)
|
|
56
|
-
if (h === null || !mine(h.lane, h.session)
|
|
57
|
+
if (h === null || !mine(h.lane, h.session)) continue
|
|
58
|
+
const s = threadState(t)
|
|
59
|
+
if (s.turn === 'done' && verdictOf(t.head) !== null) continue
|
|
57
60
|
const v = t.head.item
|
|
58
|
-
const waiting = v.origin.by === 'agent' && mine(v.origin.lane, v.origin.session) && (headWaits
|
|
61
|
+
const waiting = v.origin.by === 'agent' && mine(v.origin.lane, v.origin.session) && (s.headWaits || v.wip !== undefined)
|
|
59
62
|
if (!waiting && workingsOf(t).open === null) continue
|
|
60
63
|
if (best === null || h.at > best.at) best = { t, at: h.at }
|
|
61
64
|
}
|
|
@@ -12,9 +12,10 @@ import { HOUSE_KINDS } from './kinds.ts'
|
|
|
12
12
|
import { canonicalAddress, partyOf, updatesOf, type Message } from './model.ts'
|
|
13
13
|
import { workingThreadOf } from './referring.ts'
|
|
14
14
|
import { agentName, attachTo, openThread, postAction, postUpdate, readAll, readAllCached, sessionId, specOf, storeDir } from './store.ts'
|
|
15
|
-
import { membersOf,
|
|
15
|
+
import { membersOf, ownAddressesOf, threadsOf, type Thread } from './threads.ts'
|
|
16
16
|
import { slugOf } from '../core/slug.ts'
|
|
17
17
|
import { dayStamp } from '../core/day-stamp.ts'
|
|
18
|
+
import { orderedThreads, threadState } from './thread-state.ts'
|
|
18
19
|
|
|
19
20
|
export const REFLECTION = 'reflection'
|
|
20
21
|
|
|
@@ -88,7 +89,7 @@ export function reflectionThreads(root: string, repo: string): (file: string) =>
|
|
|
88
89
|
by.set(address, l)
|
|
89
90
|
}
|
|
90
91
|
for (const t of threadsOf(readAllCached(dir).items, spec)) {
|
|
91
|
-
const base = { id: t.head.item.id, title: t.head.item.title, done:
|
|
92
|
+
const base = { id: t.head.item.id, title: t.head.item.title, done: threadState(t).turn === 'done' }
|
|
92
93
|
for (const a of ownAddressesOf(t, spec)) if (a.startsWith(`${REFLECTION}:`)) add(a, { ...base, how: 'own', at: t.head.item.created })
|
|
93
94
|
for (const x of membersOf(t))
|
|
94
95
|
for (const m of x.thread)
|
|
@@ -192,7 +193,7 @@ export async function foldReflectionThreads(root: string, o: { go: boolean; now?
|
|
|
192
193
|
out.kept++
|
|
193
194
|
continue
|
|
194
195
|
}
|
|
195
|
-
if (
|
|
196
|
+
if (threadState(t).turn === 'done' || updatesOf(t.head).at(-1)?.update?.state === 'fixed') {
|
|
196
197
|
out.already++
|
|
197
198
|
continue
|
|
198
199
|
}
|