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
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// the fold of a store's threads that own one address into one (wiki tools/shipkit/threads-store.md, The one thread
|
|
2
|
-
// guard): in the order of their newest versions, the oldest version of each later thread supersedes the newest version
|
|
3
|
-
// of the one before. Only a missing link is written, through the head's one rewrite path, so a second run finds
|
|
4
|
-
// nothing and every message stays where it was
|
|
5
|
-
import { ownAddressOf, type ReviewItem, type Spec } from './model.ts'
|
|
6
|
-
import { readAll, specOf, updateHead } from './store.ts'
|
|
7
|
-
import { ownAddressesOf, threadsOf, type Thread } from './threads.ts'
|
|
8
|
-
|
|
9
|
-
/** one link the fold writes: `id` supersedes `supersedes` (the newest of the thread before); `was`: the version it
|
|
10
|
-
* superseded before, on a fork the one the two heads share, and the write holds only while it still does */
|
|
11
|
-
export interface FoldLink {
|
|
12
|
-
address: string
|
|
13
|
-
id: string
|
|
14
|
-
supersedes: string
|
|
15
|
-
was?: string
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const created = (t: Thread): string => t.head.item.created
|
|
19
|
-
|
|
20
|
-
/** a trailer thread whose every version names exactly one shot: a refilm of that shot he judged alone, its own subject */
|
|
21
|
-
const oneShot = (t: Thread): boolean => t.versions.every((v) => v.item.trailer !== undefined && v.item.trailer.shots.length === 1)
|
|
22
|
-
|
|
23
|
-
/** the links that make each address one thread, pure: agents' threads only; a note joins at read time already. A
|
|
24
|
-
* thread whose oldest version a link already names is left; two heads that share older versions (a fork) are folded:
|
|
25
|
-
* the later head's first version of its own supersedes the other head in place of the version they share */
|
|
26
|
-
export function foldPlan(items: readonly ReviewItem[], spec: Spec): FoldLink[] {
|
|
27
|
-
const by = new Map<string, Thread[]>()
|
|
28
|
-
for (const t of threadsOf(items, spec)) {
|
|
29
|
-
if (t.head.item.origin.by !== 'agent' || oneShot(t)) continue
|
|
30
|
-
const a = ownAddressOf(t.head.item, spec) ?? ownAddressesOf(t, spec)[0]
|
|
31
|
-
if (a === undefined) continue
|
|
32
|
-
by.set(a, [...(by.get(a) ?? []), t])
|
|
33
|
-
}
|
|
34
|
-
const out: FoldLink[] = []
|
|
35
|
-
for (const [address, ts] of by) {
|
|
36
|
-
if (ts.length < 2) continue
|
|
37
|
-
const sorted = [...ts].sort((a, b) => created(a).localeCompare(created(b)) || a.head.item.id.localeCompare(b.head.item.id))
|
|
38
|
-
for (let i = 1; i < sorted.length; i++) {
|
|
39
|
-
const prev = sorted[i - 1]!
|
|
40
|
-
const cur = sorted[i]!
|
|
41
|
-
const shared = new Set(prev.versions.map((v) => v.item.id))
|
|
42
|
-
const own = [...cur.versions].reverse().find((v) => !shared.has(v.item.id))
|
|
43
|
-
if (own === undefined) continue
|
|
44
|
-
const was = own.item.supersedes
|
|
45
|
-
if (was !== undefined && shared.has(was)) {
|
|
46
|
-
if (was !== prev.head.item.id) out.push({ address, id: own.item.id, supersedes: prev.head.item.id, was })
|
|
47
|
-
continue
|
|
48
|
-
}
|
|
49
|
-
if (was === undefined) out.push({ address, id: own.item.id, supersedes: prev.head.item.id })
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return out
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** the plan of a store and, with `go`, each link written; the threads before and after */
|
|
56
|
-
export function foldStore(dir: string, o: { go: boolean }): { links: FoldLink[]; before: number; after: number } {
|
|
57
|
-
const spec = specOf(dir)
|
|
58
|
-
const items = readAll(dir).items
|
|
59
|
-
const links = foldPlan(items, spec)
|
|
60
|
-
const before = threadsOf(items, spec).length
|
|
61
|
-
if (!o.go) return { links, before, after: before - links.length }
|
|
62
|
-
for (const l of links) updateHead(dir, l.id, (cur) => (cur.supersedes === l.was ? { ...cur, supersedes: l.supersedes } : cur))
|
|
63
|
-
return { links, before, after: threadsOf(readAll(dir).items, spec).length }
|
|
64
|
-
}
|
package/src/review/wait.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// what a thread waits on from him (wiki tools/shipkit/threads-how-it-fits.md, The model): one verb of his turn, else
|
|
2
|
-
// whose hands. Never a type of the thread: its open objects decide, in the dock's order. A row's badge reads the first
|
|
3
|
-
// (`waitOf`); the filters and their counts read every verb its open objects ask (`verbsOf`, `waitsMatch`)
|
|
4
|
-
import { kindOfAsk } from './answer-kinds.ts'
|
|
5
|
-
import type { MessageType } from './glyphs.ts'
|
|
6
|
-
import { isClosedAskState, moveOf, stateOf, type Message } from './model.ts'
|
|
7
|
-
import { heldOpen, holdMoveOf } from './holds.ts'
|
|
8
|
-
import { askFactsOf, askStateOf, headWaits, membersOf, openAsksOf, openItemVerdictsOf, turnOf, type Thread } from './threads.ts'
|
|
9
|
-
|
|
10
|
-
export const WAITS = ['judge', 'answer', 'do', 'agents', 'done'] as const
|
|
11
|
-
export type Wait = (typeof WAITS)[number]
|
|
12
|
-
/** the verbs of his turn */
|
|
13
|
-
export const OWNER_WAITS = ['judge', 'answer', 'do'] as const satisfies readonly Wait[]
|
|
14
|
-
export type OwnerWait = (typeof OWNER_WAITS)[number]
|
|
15
|
-
export const isOwnerWait = (w: string): w is OwnerWait => (OWNER_WAITS as readonly string[]).includes(w)
|
|
16
|
-
|
|
17
|
-
/** a url's `waits=judge,answer` (the inbox's key): the owner's verbs it names, null when it names none */
|
|
18
|
-
export function waitsOfParam(v: string | null): OwnerWait[] | null {
|
|
19
|
-
const ws = OWNER_WAITS.filter((w) => (v ?? '').split(',').includes(w))
|
|
20
|
-
return ws.length > 0 ? ws : null
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const DO_ANSWERS: ReadonlySet<string> = new Set(['checklist', 'url', 'secret', 'file'])
|
|
24
|
-
const DO_ASKS: ReadonlySet<string> = new Set(['action', 'purchase', 'credential'])
|
|
25
|
-
|
|
26
|
-
/** an ask's own record: an action, a purchase or a credential is done, a decision or an answer is answered */
|
|
27
|
-
export const askVerb = (kind: string): OwnerWait => (DO_ASKS.has(kind) ? 'do' : 'answer')
|
|
28
|
-
|
|
29
|
-
/** the verb of one open request in the dock: a proposed change is judged, a question that takes a checklist, a url, a
|
|
30
|
-
* secret or a file is done, any other question is answered */
|
|
31
|
-
export const requestVerb = (m: Pick<Message, 'propose' | 'ask'>): OwnerWait => (m.propose !== undefined ? 'judge' : DO_ANSWERS.has(kindOfAsk(m as Message)) ? 'do' : 'answer')
|
|
32
|
-
|
|
33
|
-
/** what a thread waits on from him first: the type of message, or the kind of the object, a row draws as its icon */
|
|
34
|
-
export type WaitsOn = { type: MessageType } | { kind: string }
|
|
35
|
-
|
|
36
|
-
/** every open object of his turn as its verb and what waits, in the dock's order: the ask's own record, each open
|
|
37
|
-
* question, proposed change or message that asks the owner's verdict oldest first, the version that waits for the
|
|
38
|
-
* owner's verdict, the owner's note an agent asked about, an object of his move that holds it open */
|
|
39
|
-
function entriesOf(t: Thread): { wait: OwnerWait; on?: WaitsOn }[] {
|
|
40
|
-
const out: { wait: OwnerWait; on?: WaitsOn }[] = []
|
|
41
|
-
const head = t.head.item
|
|
42
|
-
const ask = askStateOf(t)?.state
|
|
43
|
-
const facts = askFactsOf(t)
|
|
44
|
-
if (facts !== null && !isClosedAskState(ask)) out.push({ wait: askVerb(facts.kind), on: { kind: 'ask' } })
|
|
45
|
-
for (const m of [...openAsksOf(t), ...openItemVerdictsOf(t)].sort((a, b) => a.at.localeCompare(b.at)))
|
|
46
|
-
out.push(m.asksVerdict === true && m.ask === undefined && m.propose === undefined ? { wait: 'judge', on: verdictOn(m) } : { wait: requestVerb(m), on: { type: requestType(m) } })
|
|
47
|
-
if (headWaits(t)) out.push({ wait: 'judge', on: { kind: head.on ? head.on.slice(0, head.on.indexOf(':')) : head.subject.kind } })
|
|
48
|
-
const notes = [...(head.origin.by === 'agent' ? [] : [t.head]), ...t.answers.filter((x) => t.joined.has(x.item.id))]
|
|
49
|
-
if (notes.some((x) => moveOf(stateOf(x, false).state) === 'owner')) out.push({ wait: 'answer', on: { type: 'note' } })
|
|
50
|
-
const hold = heldOpen(membersOf(t)).find((h) => holdMoveOf(h) === 'owner')
|
|
51
|
-
if (hold !== undefined) out.push({ wait: 'do', on: { kind: hold.address.slice(0, hold.address.indexOf(':')) } })
|
|
52
|
-
return out
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** the one verb a thread's badge says, and what waits: while it is his turn or set aside, its first open object's
|
|
56
|
-
* (entriesOf), `answer` on the rare turn of his no open object explains; `agents` or `done` once the turn is not his.
|
|
57
|
-
* `owed`: on the agents' move after his last word (band.ts AFTER_MOVE), the verb of what still waits on him, a quiet
|
|
58
|
-
* mark that never puts the thread back in his turn */
|
|
59
|
-
export function waitEntryOf(t: Thread, now = new Date()): { wait: Wait; on?: WaitsOn; owed?: OwnerWait } {
|
|
60
|
-
const turn = turnOf(t, now)
|
|
61
|
-
if (turn === 'done') return { wait: turn }
|
|
62
|
-
if (turn === 'agents') {
|
|
63
|
-
const owed = entriesOf(t)[0]?.wait
|
|
64
|
-
return owed !== undefined ? { wait: turn, owed } : { wait: turn }
|
|
65
|
-
}
|
|
66
|
-
return entriesOf(t)[0] ?? { wait: 'answer' }
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** every verb his open objects ask, the first one first: a filter lists the thread for any of them, never only for its
|
|
70
|
-
* badge; none once the turn is not his */
|
|
71
|
-
export function verbsOf(t: Thread, now = new Date()): OwnerWait[] {
|
|
72
|
-
const turn = turnOf(t, now)
|
|
73
|
-
if (turn === 'agents' || turn === 'done') return []
|
|
74
|
-
const vs = [...new Set(entriesOf(t).map((e) => e.wait))]
|
|
75
|
-
return vs.length > 0 ? vs : ['answer']
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** the one matcher of every verbs filter (the threads page, the inbox): none picked lists all, else a thread whose
|
|
79
|
-
* verbs hold one picked */
|
|
80
|
-
export const waitsMatch = (sel: readonly OwnerWait[] | null, verbs: readonly string[]): boolean => sel === null || verbs.some((v) => (sel as readonly string[]).includes(v))
|
|
81
|
-
|
|
82
|
-
export const waitOf = (t: Thread, now = new Date()): Wait => waitEntryOf(t, now).wait
|
|
83
|
-
|
|
84
|
-
/** an open request's type: a proposed change, a secret field, a checklist, any other question */
|
|
85
|
-
const requestType = (m: Message): MessageType => (m.propose !== undefined ? 'change' : kindOfAsk(m) === 'secret' ? 'secret' : kindOfAsk(m) === 'checklist' ? 'checklist' : 'question')
|
|
86
|
-
|
|
87
|
-
/** a message that asks the owner's verdict: the object it links when it links one (a reflection, a draft), else its words */
|
|
88
|
-
const verdictOn = (m: Message): WaitsOn => {
|
|
89
|
-
const a = m.about?.[0]
|
|
90
|
-
return a !== undefined && a.includes(':') ? { kind: a.slice(0, a.indexOf(':')) } : { type: 'message' }
|
|
91
|
-
}
|
package/src/rules/rule.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// The LEGACY rule shape, kept for the compatibility window. A repo that
|
|
2
|
-
// still registers invariants through `repo.config.ts rules: []` imports
|
|
3
|
-
// `Rule` from here, and the engine reads each one as a check whose body is
|
|
4
|
-
// `lint` (check.ts owns the shape now). Both die together, at the first
|
|
5
|
-
// release after `shipkit fleet` shows no repo below 0.40.
|
|
6
|
-
//
|
|
7
|
-
// A new invariant is a `<name>.check.ts` file: `check({ blocking, run })`,
|
|
8
|
-
// dropped anywhere in the repo, discovered with no config edit.
|
|
9
|
-
import { repoOff } from '../core/when.ts'
|
|
10
|
-
import { tagCheckLines, checkCacheExtra, type Rule, type RuleEnv } from '../check.ts'
|
|
11
|
-
|
|
12
|
-
export type { FixResult, Rule, RuleEnv } from '../check.ts'
|
|
13
|
-
|
|
14
|
-
/** the config part of a rule's cache identity, including where it runs */
|
|
15
|
-
export function ruleCacheExtra(rule: Rule, env: RuleEnv): string | undefined {
|
|
16
|
-
return checkCacheExtra(rule.cacheKey?.(env), repoOff(env.config, rule.id)?.reason ?? null)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** tag every severity line with the rule id (check.ts owns the rendering) */
|
|
20
|
-
export const tagRuleLines = tagCheckLines
|
|
21
|
-
|
|
22
|
-
// ── the legacy id namespace ──────────────────────────────────────────────
|
|
23
|
-
// A rule id is PREFIX plus exactly 3 digits, and `SK` is reserved for the
|
|
24
|
-
// toolkit's own checks so a repo rule can never shadow one. A `*.check.ts`
|
|
25
|
-
// file takes its id from its NAME and may use plain words, so this shape
|
|
26
|
-
// binds the `rules: []` key only.
|
|
27
|
-
|
|
28
|
-
export const RULE_ID_RE = /^[A-Z]{2,4}\d{3}$/
|
|
29
|
-
|
|
30
|
-
/** validate the rules a repo registers. Throws on a malformed id, a
|
|
31
|
-
* duplicate, a missing owner page, or one squatting the reserved SK
|
|
32
|
-
* prefix, so a bad registration dies at config load and never mid gate. */
|
|
33
|
-
export function validateRules(rules: readonly Rule[], o: { label: string; taken?: Iterable<string> } = { label: 'rules' }): void {
|
|
34
|
-
const seen = new Set<string>(o.taken ?? [])
|
|
35
|
-
for (const r of rules) {
|
|
36
|
-
if (!RULE_ID_RE.test(r.id)) throw new Error(`${o.label}: bad id '${r.id}' — rules are PREFIX+3 digits (e.g. SK001, RV001)`)
|
|
37
|
-
if (r.id.startsWith('SK'))
|
|
38
|
-
throw new Error(`${o.label}: id '${r.id}' uses the reserved SK prefix — repo rules pick their own (e.g. RV${r.id.slice(-3)})`)
|
|
39
|
-
if (seen.has(r.id)) throw new Error(`${o.label}: duplicate id ${r.id}`)
|
|
40
|
-
if (r.owner === '') throw new Error(`${o.label}: ${r.id} has no owner page`)
|
|
41
|
-
seen.add(r.id)
|
|
42
|
-
}
|
|
43
|
-
}
|
package/src/serve/hook-thread.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// the daemon's hook thread: the inbox hook's work for each hook that asks (review/hook-ask.ts), in a worker of its own
|
|
2
|
-
// (hook-worker.ts) that keeps warm what the work reads, while the loop only awaits a message. Its own worker, never
|
|
3
|
-
// the read thread's: a hook waits on no repo's rows.
|
|
4
|
-
// the one constraint a reader breaks first: a thread on older code than its tree answers « stale » and is stopped
|
|
5
|
-
// here, so the next ask starts a new one on the code on disk; until then every hook runs in its own process
|
|
6
|
-
import { HOOK_PATH, HOOK_WIRE, type HookAnswer, type HookAsk } from '../review/hook-ask.ts'
|
|
7
|
-
import { WorkerThread } from './read-thread.ts'
|
|
8
|
-
|
|
9
|
-
const ENTRY = new URL('./hook-worker.ts', import.meta.url).href
|
|
10
|
-
|
|
11
|
-
export class HookThread extends WorkerThread<{ ask: HookAsk }> {
|
|
12
|
-
constructor(entry = ENTRY) {
|
|
13
|
-
super(entry, 'hook thread')
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** the hook's answer, or why the thread did not serve it */
|
|
17
|
-
async answer(ask: HookAsk): Promise<HookAnswer> {
|
|
18
|
-
const a = await this.ask<HookAnswer & { stale?: true }>({ ask }).catch((e: Error): HookAnswer => ({ served: false, why: e.message }))
|
|
19
|
-
if (!a.served && 'stale' in a) {
|
|
20
|
-
// the next hook finds a thread on the code on disk, warm
|
|
21
|
-
this.stop()
|
|
22
|
-
this.open()
|
|
23
|
-
return { served: false, why: a.why }
|
|
24
|
-
}
|
|
25
|
-
return a
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** the hook's one route, POST HOOK_PATH: null for any other path. A request of another wire is not served */
|
|
30
|
-
export async function hookRoute(req: Request, path: string, thread: HookThread): Promise<Response | null> {
|
|
31
|
-
if (path !== HOOK_PATH) return null
|
|
32
|
-
if (req.method !== 'POST') return new Response('POST only', { status: 405 })
|
|
33
|
-
const ask = (await req.json().catch(() => null)) as HookAsk | null
|
|
34
|
-
if (ask?.v !== HOOK_WIRE || typeof ask.src !== 'string' || typeof ask.cwd !== 'string' || typeof ask.text !== 'string' || typeof ask.env !== 'object' || ask.env === null || typeof ask.until !== 'number')
|
|
35
|
-
return Response.json({ served: false, why: `a hook of wire ${String(ask?.v)}, this daemon speaks ${HOOK_WIRE}` } satisfies HookAnswer)
|
|
36
|
-
return Response.json(await thread.answer(ask), { headers: { 'Cache-Control': 'no-store' } })
|
|
37
|
-
}
|
package/src/serve/hook-work.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
// the work of the daemon's hook thread (hook-worker.ts is its entry): the inbox hook's work (cli/inbox-hook-run.ts
|
|
2
|
-
// hookWork) for one hook that asks, under the asking hook's env and with what it prints taken as its own, or why it
|
|
3
|
-
// is not this thread's to serve.
|
|
4
|
-
// the one constraint a reader breaks first: an answer is this thread's code, so a hook is served only by a thread on
|
|
5
|
-
// the hook's own tree whose loaded modules are the files on disk: one moved, and it answers « stale », and the daemon
|
|
6
|
-
// starts a new thread on the code on disk
|
|
7
|
-
import { statSync } from 'node:fs'
|
|
8
|
-
import type { HookAnswer, HookAsk } from '../review/hook-ask.ts'
|
|
9
|
-
|
|
10
|
-
/** who acts: the asking hook's own, set for its work alone */
|
|
11
|
-
const ACTOR = (k: string): boolean => /^(CLAUDE_|SK_)/.test(k) || k === 'SHIPKIT_ORCHESTRATOR'
|
|
12
|
-
/** the daemon's own mark, never a store */
|
|
13
|
-
const OWN = new Set(['SHIPKIT_HOME_WORKER'])
|
|
14
|
-
|
|
15
|
-
/** why the thread at `src`, started under `base`, does not serve the hook; null when it does. A hook whose env moves a
|
|
16
|
-
* store or the home (any other SHIPKIT_ value, another HOME) reads stores the thread does not hold */
|
|
17
|
-
export function hookRefusal(a: HookAsk, src: string, base: Record<string, string | undefined>, now = Date.now()): string | null {
|
|
18
|
-
if (a.src !== src) return `the hook runs ${a.src}, the daemon ${src}`
|
|
19
|
-
if ((a.env.HOME ?? '') !== (base.HOME ?? '')) return 'the hook runs under another HOME'
|
|
20
|
-
for (const k of new Set([...Object.keys(a.env), ...Object.keys(base)])) {
|
|
21
|
-
if (!k.startsWith('SHIPKIT_') || ACTOR(k) || OWN.has(k)) continue
|
|
22
|
-
if (a.env[k] !== base[k]) return `the hook's env moves ${k}`
|
|
23
|
-
}
|
|
24
|
-
if (now > a.until) return 'the work could not start in time: the hook runs it itself'
|
|
25
|
-
return null
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const mtimeOf = (f: string): number => {
|
|
29
|
-
try {
|
|
30
|
-
return statSync(f).mtimeMs
|
|
31
|
-
} catch {
|
|
32
|
-
return -1
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** the modules a thread loaded under `src`, each with its file's time once it loaded: `moved` names one whose file
|
|
37
|
-
* changed since, the code the thread runs no longer the code on disk */
|
|
38
|
-
export class LoadedModules {
|
|
39
|
-
private at = new Map<string, number>()
|
|
40
|
-
constructor(private readonly src: string, private readonly mtime: (f: string) => number = mtimeOf) {}
|
|
41
|
-
note(files: Iterable<string>): void {
|
|
42
|
-
for (const f of files) if (f.startsWith(`${this.src}/`) && !this.at.has(f)) this.at.set(f, this.mtime(f))
|
|
43
|
-
}
|
|
44
|
-
moved(): string | null {
|
|
45
|
-
for (const [f, at] of this.at) if (this.mtime(f) !== at) return f.slice(this.src.length + 1)
|
|
46
|
-
return null
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export type Work = (text: string, cwd: string, io: { out: (l: string) => void; err: (l: string) => void }) => Promise<number>
|
|
51
|
-
type Write = typeof process.stdout.write
|
|
52
|
-
|
|
53
|
-
/** one hook's work (`work`, hookWork in the thread) under its own actor env, every print of it taken: its console and
|
|
54
|
-
* its process streams, put back after, as are the env values it moved */
|
|
55
|
-
export async function workAs(a: HookAsk, work: Work): Promise<HookAnswer> {
|
|
56
|
-
const env = process.env
|
|
57
|
-
const was = new Map<string, string | undefined>()
|
|
58
|
-
for (const k of Object.keys(env)) if (ACTOR(k)) was.set(k, env[k])
|
|
59
|
-
for (const k of was.keys()) delete env[k]
|
|
60
|
-
for (const [k, v] of Object.entries(a.env)) if (ACTOR(k)) {
|
|
61
|
-
if (!was.has(k)) was.set(k, undefined)
|
|
62
|
-
env[k] = v
|
|
63
|
-
}
|
|
64
|
-
let out = ''
|
|
65
|
-
let err = ''
|
|
66
|
-
const taken = { log: console.log, info: console.info, warn: console.warn, error: console.error, stdout: process.stdout.write, stderr: process.stderr.write }
|
|
67
|
-
const line = (to: 'out' | 'err') => (...xs: unknown[]): void => {
|
|
68
|
-
const text = `${xs.map((x) => (typeof x === 'string' ? x : Bun.inspect(x))).join(' ')}\n`
|
|
69
|
-
if (to === 'out') out += text
|
|
70
|
-
else err += text
|
|
71
|
-
}
|
|
72
|
-
const text = (c: string | Uint8Array): string => (typeof c === 'string' ? c : new TextDecoder().decode(c))
|
|
73
|
-
console.log = console.info = line('out')
|
|
74
|
-
console.warn = console.error = line('err')
|
|
75
|
-
process.stdout.write = ((c: string | Uint8Array) => ((out += text(c)), true)) as Write
|
|
76
|
-
process.stderr.write = ((c: string | Uint8Array) => ((err += text(c)), true)) as Write
|
|
77
|
-
try {
|
|
78
|
-
const code = await work(a.text, a.cwd, { out: (l) => void (out += `${l}\n`), err: (l) => void (err += `${l}\n`) })
|
|
79
|
-
return { served: true, out, err, code }
|
|
80
|
-
} catch (e) {
|
|
81
|
-
// a throw is the hook's own to show: it runs the work itself
|
|
82
|
-
return { served: false, why: `the work threw: ${(e as Error).message}` }
|
|
83
|
-
} finally {
|
|
84
|
-
Object.assign(console, { log: taken.log, info: taken.info, warn: taken.warn, error: taken.error })
|
|
85
|
-
process.stdout.write = taken.stdout
|
|
86
|
-
process.stderr.write = taken.stderr
|
|
87
|
-
for (const [k, v] of was) {
|
|
88
|
-
if (v === undefined) delete env[k]
|
|
89
|
-
else env[k] = v
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
package/src/serve/hook-worker.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// the daemon's hook thread (hook-thread.ts): each hook's work (hook-work.ts), one at a time, since the env and the
|
|
2
|
-
// prints are the thread's own while it works. What the work reads stays warm here between two hooks: the stores' rows
|
|
3
|
-
// read since the last read, the units, the lanes' facts, the ended sessions' listings.
|
|
4
|
-
import { dirname } from 'node:path'
|
|
5
|
-
import { installOneLib } from '../core/one-lib.ts'
|
|
6
|
-
import { keepTranscriptListing } from '../agent-time/store.ts'
|
|
7
|
-
import type { HookAnswer, HookAsk } from '../review/hook-ask.ts'
|
|
8
|
-
import { hookRefusal, LoadedModules, workAs } from './hook-work.ts'
|
|
9
|
-
|
|
10
|
-
declare const self: Worker
|
|
11
|
-
|
|
12
|
-
// a thread never inherits its process's resolver hook (read-worker.ts)
|
|
13
|
-
installOneLib()
|
|
14
|
-
// every hook reads the transcripts of the sessions its threads name: kept current here by a watch
|
|
15
|
-
keepTranscriptListing()
|
|
16
|
-
|
|
17
|
-
const SRC = dirname(import.meta.dir)
|
|
18
|
-
/** the daemon's env when the thread started */
|
|
19
|
-
const BASE: Record<string, string | undefined> = { ...process.env }
|
|
20
|
-
const loaded = new LoadedModules(SRC)
|
|
21
|
-
|
|
22
|
-
// the modules the work loads, loaded as the thread starts: a cold load is longer than a hook waits
|
|
23
|
-
// (review/hook-ask.ts HOOK_WAIT_MS), so the first hook after a start would run itself
|
|
24
|
-
const warm = Promise.all([
|
|
25
|
-
import('../cli/inbox-hook-run.ts'),
|
|
26
|
-
import('../cli/review-here.ts'),
|
|
27
|
-
import('../review/inbox-hook.ts'),
|
|
28
|
-
import('../review/inbox-read.ts'),
|
|
29
|
-
import('../review/project.ts'),
|
|
30
|
-
import('../review/hand-over.ts'),
|
|
31
|
-
import('../review/watchers.ts'),
|
|
32
|
-
import('../review/take-back.ts'),
|
|
33
|
-
import('../agent-time/registry.ts'),
|
|
34
|
-
import('../orchestrator/role.ts'),
|
|
35
|
-
import('../orchestrator/places.ts'),
|
|
36
|
-
]).catch(() => [])
|
|
37
|
-
.finally(() => loaded.note(Object.keys(require.cache)))
|
|
38
|
-
|
|
39
|
-
async function answer(a: HookAsk): Promise<HookAnswer & { stale?: true }> {
|
|
40
|
-
await warm
|
|
41
|
-
const moved = loaded.moved()
|
|
42
|
-
if (moved !== null) return { served: false, why: `${moved} moved since the hook thread loaded it`, stale: true }
|
|
43
|
-
const no = hookRefusal(a, SRC, BASE)
|
|
44
|
-
if (no !== null) return { served: false, why: no }
|
|
45
|
-
try {
|
|
46
|
-
const { hookWork } = await import('../cli/inbox-hook-run.ts')
|
|
47
|
-
return await workAs(a, hookWork)
|
|
48
|
-
} finally {
|
|
49
|
-
loaded.note(Object.keys(require.cache))
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
let queue: Promise<unknown> = Promise.resolve()
|
|
54
|
-
self.onmessage = (e: MessageEvent<{ id: number; ask: HookAsk }>) => {
|
|
55
|
-
const { id, ask } = e.data
|
|
56
|
-
queue = queue.then(async () => self.postMessage({ id, answer: await answer(ask).catch((x: Error): HookAnswer => ({ served: false, why: x.message })) }))
|
|
57
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
// the timeline and the dock (wiki tools/shipkit/threads-page.md, The dock): every item lives whole in the timeline, its
|
|
2
|
-
// words wrapped and its controls under them (a question's options with the agent's pick, an ask's instructions with
|
|
3
|
-
// their boxes, a checklist, a field, a secret, a verdict's buttons). The dock above his reply box holds no content: ONE
|
|
4
|
-
// line, the first thing that waits on him (its glyph, a short title, its age, « jump ↑ », a click that scrolls the
|
|
5
|
-
// timeline to the item and lights it), « +N » when more wait, and the open ask's own acts at its end
|
|
6
|
-
import { observer } from 'mobx-react-lite'
|
|
7
|
-
import { useState, type ReactNode } from 'react'
|
|
8
|
-
import type { ReplyCell } from '../../../review/cells.ts'
|
|
9
|
-
import { actsLeft, versionActs } from '../../../review/settle.ts'
|
|
10
|
-
import { CellGlyph } from './object-panel.tsx'
|
|
11
|
-
import { Age, stampWords } from '../time-ago.tsx'
|
|
12
|
-
import { keepFocus } from './kit.tsx'
|
|
13
|
-
import { AskBody, ProposeBody } from './question-views.tsx'
|
|
14
|
-
import { currentStep, InstructionsBody, stepLine } from './instructions-view.tsx'
|
|
15
|
-
import { Cta } from './cta.tsx'
|
|
16
|
-
import { renderMdInline } from '../md.ts'
|
|
17
|
-
import { Words } from '../words.tsx'
|
|
18
|
-
import type { ReviewSt } from './review-st.ts'
|
|
19
|
-
import { answeredWords, dockDom, requestState, requestWord, type ThreadSt } from './thread-st.ts'
|
|
20
|
-
import { tip } from '../tips.ts'
|
|
21
|
-
|
|
22
|
-
const firstLine = (t: string): string => t.split('\n').find((l) => l.trim() !== '')?.trim() ?? ''
|
|
23
|
-
|
|
24
|
-
/** where a checklist stands, on its reminder: « 2 of 5 » */
|
|
25
|
-
const progressOf = (c: ReplyCell): string | null => {
|
|
26
|
-
const lines = c.ask?.lines
|
|
27
|
-
return c.ask?.kind === 'checklist' && lines ? `${lines.filter((l) => l.tick).length} of ${lines.length}` : null
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** the question or the change itself, as it answers */
|
|
31
|
-
const RequestBody = observer(({ rv, thread, c }: { rv: ReviewSt; thread: ThreadSt; c: ReplyCell }) =>
|
|
32
|
-
c.ask ? <AskBody rv={rv} thread={thread} c={c} ask={c.ask} /> : c.propose ? <ProposeBody rv={rv} thread={thread} c={c} p={c.propose} /> : null,
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
/** `ask`: the open ask's own acts (its proof url, « done », « I will not do this »), drawn at the end of the line;
|
|
36
|
-
* `titled` when nothing else waits, so the line names the ask itself. Keyed by its thread: « +N » opens per thread */
|
|
37
|
-
export const Dock = observer(({ rv, thread, ask }: { rv: ReviewSt; thread: ThreadSt; ask?: ((titled: boolean) => ReactNode) | null }) => {
|
|
38
|
-
const [more, setMore] = useState(false)
|
|
39
|
-
const verdict = thread.verdictAbove
|
|
40
|
-
// the owner's words came after the version: the agents move first (review/band.ts AFTER_MOVE), the verdict waits, quiet
|
|
41
|
-
const later = thread.data?.turn === 'agents'
|
|
42
|
-
const cls = later ? 'rv-dockverdict rv-docklater' : 'rv-dockverdict'
|
|
43
|
-
const after = later ? ' · an agent answers your words first' : ''
|
|
44
|
-
const lines = thread.openRequests.map((c) => (c.instructions && c.ask ? <StepsReminder key={c.id} rv={rv} thread={thread} c={c} /> : <Reminder key={c.id} rv={rv} thread={thread} c={c} />))
|
|
45
|
-
if (verdict)
|
|
46
|
-
lines.push(
|
|
47
|
-
versionActs(verdict.item) !== null ? (
|
|
48
|
-
// a version answered by its kind's acts: what is left for him in its words, never a verdict
|
|
49
|
-
<Line key={verdict.id} id={dockDom(verdict.id)} cls={cls} go={() => thread.reveal(verdict.id)} kind={later ? 'when ready' : 'your turn'} title={`v${verdict.n}: ${actsLeft(verdict.item, verdict.settled)}${after}`} />
|
|
50
|
-
) : (
|
|
51
|
-
<Line key={verdict.id} id={dockDom(verdict.id)} cls={cls} go={() => thread.reveal(verdict.id)} kind={later ? 'verdict, when ready' : 'your verdict'} title={`v${verdict.n} waits for your verdict${thread.waitingViews ? ` · ${thread.waitingViews.waiting} of ${thread.waitingViews.of} views` : ''}${after}`} />
|
|
52
|
-
),
|
|
53
|
-
)
|
|
54
|
-
const acts = ask?.(lines.length === 0) ?? null
|
|
55
|
-
if (lines.length === 0 && acts === null) return <Expected thread={thread} />
|
|
56
|
-
const [first, ...rest] = lines
|
|
57
|
-
return (
|
|
58
|
-
<section className="rv-dock" aria-label="what waits on your answer">
|
|
59
|
-
<div className="rv-dockbox">
|
|
60
|
-
{/* the others, opened by « +N »: over the line, so the line never moves away from his box */}
|
|
61
|
-
{more && rest.length > 0 ? <div className="rv-dockentries">{rest}</div> : null}
|
|
62
|
-
<div className="rv-dockline">
|
|
63
|
-
{first}
|
|
64
|
-
{rest.length > 0 ? (
|
|
65
|
-
<button className="rv-dockmore ghost" aria-expanded={more} {...tip(more ? 'fold them again' : `${rest.length} more ${rest.length > 1 ? 'wait' : 'waits'} on you: show ${rest.length > 1 ? 'them' : 'it'}`)} onMouseDown={keepFocus} onClick={() => setMore(!more)}>
|
|
66
|
-
{more ? 'fewer' : `+${rest.length} more`}
|
|
67
|
-
</button>
|
|
68
|
-
) : null}
|
|
69
|
-
{acts}
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
</section>
|
|
73
|
-
)
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
/** nothing waits on his answer: one quiet line of what is expected of him and why (review/expect.ts expectOf), never
|
|
77
|
-
* an empty bar that leaves him guessing; a promise past its time in the warning colour */
|
|
78
|
-
const Expected = observer(({ thread }: { thread: ThreadSt }) => {
|
|
79
|
-
const e = thread.expect
|
|
80
|
-
if (e === null) return null
|
|
81
|
-
return (
|
|
82
|
-
<section className={`rv-dock rv-dockquiet${e.late ? ' late' : ''}`} aria-label="what is expected of you">
|
|
83
|
-
<div className="rv-dockbox">
|
|
84
|
-
<div className="rv-dockline">
|
|
85
|
-
<p className="rv-dockexpect" role="status">{e.words}</p>
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
</section>
|
|
89
|
-
)
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
/** one reminder: a click anywhere on it scrolls the timeline to its item and lights it; its jump right after its words */
|
|
93
|
-
const Line = ({ id, go, glyph, kind, title, count, when, cls = '' }: { id: string; go: () => void; glyph?: ReactNode; kind: string; title: string; count?: string | null; when?: ReactNode; cls?: string }) => (
|
|
94
|
-
<button id={id} className={`rv-dockentry rv-reminder ghost ${cls}`} {...tip(`${title}: jump to it`)} onMouseDown={keepFocus} onClick={go}>
|
|
95
|
-
{glyph}
|
|
96
|
-
<span className="rv-dockkind">{kind}</span>
|
|
97
|
-
<b className="rv-dockq mdi" dangerouslySetInnerHTML={{ __html: renderMdInline(title) }} />
|
|
98
|
-
{count ? <span className="rv-dockcount">{count}</span> : null}
|
|
99
|
-
{when}
|
|
100
|
-
<span className="rv-dockplace">jump ↑</span>
|
|
101
|
-
</button>
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
const When = observer(({ rv, at }: { rv: ReviewSt; at: string }) => {
|
|
105
|
-
const t = Date.parse(at)
|
|
106
|
-
return <time className="rv-when" dateTime={at} {...tip(stampWords(t))}><Age clock={rv} at={t} /></time>
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
/** an open question, change or item that waits for a verdict: its first line, a reminder */
|
|
110
|
-
const Reminder = observer(({ rv, thread, c }: { rv: ReviewSt; thread: ThreadSt; c: ReplyCell }) => (
|
|
111
|
-
<Line id={dockDom(c.id)} go={() => thread.reveal(c.id)} glyph={<CellGlyph rv={rv} c={c} />} kind={requestWord(c)} title={firstLine(c.text) || requestWord(c)} count={progressOf(c)} when={<When rv={rv} at={c.at} />} />
|
|
112
|
-
))
|
|
113
|
-
|
|
114
|
-
/** an ask's instructions: « step 2 of 3: <title> », a click jumps to that step in the timeline */
|
|
115
|
-
const StepsReminder = observer(({ rv, thread, c }: { rv: ReviewSt; thread: ThreadSt; c: ReplyCell }) => {
|
|
116
|
-
const line = stepLine(thread, c)
|
|
117
|
-
const at = currentStep(thread, c)
|
|
118
|
-
return <Line id={dockDom(c.id)} go={() => (at === null ? thread.reveal(c.id) : thread.revealStep(c.id, at))} glyph={<CellGlyph rv={rv} c={c} />} kind={line.n} title={line.title} when={<When rv={rv} at={c.at} />} cls="rv-docksteps" />
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
/** a question or a change at its place in the timeline, where he answers it: whole, its words wrapped and its controls
|
|
122
|
-
* under them; an ask's instructions with a box on each step; once answered, his answer said over it. Superseded: read
|
|
123
|
-
* only. Its words go read with the thread (review/owner-read.ts), never from its reminder in the dock */
|
|
124
|
-
export const RequestCell = observer(({ rv, thread, c }: { rv: ReviewSt; thread: ThreadSt; c: ReplyCell }) => {
|
|
125
|
-
if (c.instructions && c.ask) return <InstructionsBody rv={rv} thread={thread} c={c} live={!c.superseded} />
|
|
126
|
-
const waiting = thread.waitsNow(c.id)
|
|
127
|
-
return (
|
|
128
|
-
<div className={`rv-requestcell ${requestState(c, waiting)}`}>
|
|
129
|
-
{!c.superseded && !waiting ? (
|
|
130
|
-
// asked before his close and never answered: it waits on nobody (review/threads.ts closedAt)
|
|
131
|
-
<div className="rv-requestline">
|
|
132
|
-
<span className="rv-requestanswer">{c.moot ? 'closed, not answered' : `answered: ${answeredWords(c)}`}</span>
|
|
133
|
-
</div>
|
|
134
|
-
) : null}
|
|
135
|
-
{c.text.trim() !== '' ? <Words text={c.text} className="rv-words" /> : null}
|
|
136
|
-
{c.superseded ? (
|
|
137
|
-
<fieldset disabled className="rv-readonly">
|
|
138
|
-
<RequestBody rv={rv} thread={thread} c={c} />
|
|
139
|
-
</fieldset>
|
|
140
|
-
) : (
|
|
141
|
-
<Cta on={waiting}>
|
|
142
|
-
<RequestBody rv={rv} thread={thread} c={c} />
|
|
143
|
-
</Cta>
|
|
144
|
-
)}
|
|
145
|
-
</div>
|
|
146
|
-
)
|
|
147
|
-
})
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// the three verdicts as faces, drawn on the hub's 20 unit grid: ok smiles, fix is flat, reject frowns. The tone is the
|
|
2
|
-
// verdict's (review.css .st-*: green, orange, red); outlined while open, filled once it is the one picked
|
|
3
|
-
import type { ItemVerdict } from '../../../review/verdict-items.ts'
|
|
4
|
-
|
|
5
|
-
const MOUTH: Record<ItemVerdict, string> = {
|
|
6
|
-
approved: 'M6.4 11.6q3.6 3.6 7.2 0',
|
|
7
|
-
'approved-with-fix': 'M6.8 12.9h6.4',
|
|
8
|
-
rejected: 'M6.4 14q3.6-3.6 7.2 0',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const Face = ({ status, filled = false, size = 22 }: { status: ItemVerdict; filled?: boolean; size?: number }) => (
|
|
12
|
-
<svg className={`rv-faceico${filled ? ' filled' : ''}`} viewBox="0 0 20 20" width={size} height={size} aria-hidden="true">
|
|
13
|
-
<circle cx="10" cy="10" r="8.2" className="rv-faceround" />
|
|
14
|
-
<circle cx="7.1" cy="8" r="1.15" className="rv-faceeye" />
|
|
15
|
-
<circle cx="12.9" cy="8" r="1.15" className="rv-faceeye" />
|
|
16
|
-
<path d={MOUTH[status]} className="rv-facemouth" />
|
|
17
|
-
</svg>
|
|
18
|
-
)
|