rvlib-shipkit 2.28.0 → 2.29.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 +55 -0
- package/package.json +10 -2
- package/src/advisors/acts.ts +277 -0
- package/src/advisors/advice.ts +384 -0
- package/src/advisors/advisor-view.ts +417 -0
- package/src/advisors/app-graph.ts +112 -0
- package/src/advisors/app.ts +75 -0
- package/src/advisors/door.ts +59 -0
- package/src/advisors/edge/api.ts +292 -0
- package/src/advisors/edge/bucket.ts +43 -0
- package/src/advisors/edge/certs.ts +20 -0
- package/src/advisors/edge/form.ts +45 -0
- package/src/advisors/edge/handler.ts +156 -0
- package/src/advisors/edge/jwt.ts +76 -0
- package/src/advisors/edge/shell.ts +27 -0
- package/src/advisors/edge/status.ts +12 -0
- package/src/advisors/edge/types.ts +137 -0
- package/src/advisors/edge/worker.ts +52 -0
- package/src/advisors/expose.ts +150 -0
- package/src/advisors/job.ts +35 -0
- package/src/advisors/owner-store.ts +226 -0
- package/src/advisors/photos.ts +182 -0
- package/src/advisors/project.ts +311 -0
- package/src/advisors/r2.ts +48 -0
- package/src/advisors/routes.ts +469 -0
- package/src/advisors/scan.ts +194 -0
- package/src/advisors/sync.ts +363 -0
- package/src/agent-time/accounts-usage-disk.ts +29 -0
- package/src/agent-time/accounts-usage.ts +97 -0
- package/src/agent-time/hooks.ts +64 -27
- package/src/agent-time/lane-name.ts +7 -0
- package/src/agent-time/leads.ts +95 -0
- package/src/agent-time/registry.ts +106 -41
- package/src/agent-time/render.ts +35 -4
- package/src/agent-time/report-cache.ts +4 -8
- package/src/agent-time/report.ts +19 -1
- package/src/agent-time/store.ts +10 -16
- package/src/annex/snapshots.ts +3 -3
- package/src/annex/tidy.ts +10 -23
- package/src/asks/ask-after.ts +2 -1
- package/src/asks/ask-carry.ts +190 -0
- package/src/asks/ask-close.ts +72 -0
- package/src/asks/ask-doc.ts +42 -0
- package/src/asks/ask-migrate.ts +9 -9
- package/src/asks/ask-steps-fold.ts +71 -114
- package/src/asks/ask-store.ts +170 -53
- package/src/asks/ask-words-fold.ts +208 -0
- package/src/checks/SK001-package-json-shape.check.ts +5 -7
- package/src/checks/SK004-gitignore-policy.check.ts +13 -13
- package/src/checks/SK010-undeclared-unit.check.ts +77 -64
- package/src/checks/SK013-one-way-in-policy.check.ts +20 -8
- package/src/checks/SK027-agent-wiki-links.check.ts +46 -6
- package/src/checks/SK033-global-contribution.check.ts +1 -1
- package/src/checks/SK036-draft-media-size.check.ts +5 -4
- package/src/checks/SK039-vscode-watch-generated.check.ts +1 -1
- package/src/checks/SK040-release-words.check.ts +39 -10
- package/src/checks/SK042-post-kinds.check.ts +2 -2
- package/src/checks/SK045-slow-hooks.check.ts +5 -2
- package/src/checks/SK049-thread-answers-hook.check.ts +6 -4
- package/src/checks/SK051-no-formatter.check.ts +485 -0
- package/src/cli/cmd_Advisors.ts +336 -0
- package/src/cli/cmd_Annex.ts +10 -10
- package/src/cli/cmd_Asks.ts +111 -10
- package/src/cli/cmd_Backup.ts +7 -7
- package/src/cli/cmd_CacheAudit.ts +1 -1
- package/src/cli/cmd_Check.ts +3 -3
- package/src/cli/cmd_Checks.ts +1 -1
- package/src/cli/cmd_Ci.ts +15 -16
- package/src/cli/cmd_Db.ts +9 -9
- package/src/cli/cmd_FleetPush.ts +1 -1
- package/src/cli/cmd_History.ts +2 -2
- package/src/cli/cmd_Home.ts +5 -6
- package/src/cli/cmd_Hooks.ts +13 -3
- package/src/cli/cmd_Hq.ts +30 -19
- package/src/cli/cmd_Keys.ts +1 -1
- package/src/cli/cmd_Lanes.ts +9 -3
- package/src/cli/cmd_Media.ts +59 -13
- package/src/cli/cmd_Orchestrator.ts +138 -0
- package/src/cli/cmd_Rec.ts +5 -2
- package/src/cli/cmd_Reflect.ts +17 -3
- package/src/cli/cmd_Releases.ts +38 -38
- package/src/cli/cmd_Review.ts +690 -316
- package/src/cli/cmd_Shot.ts +14 -6
- package/src/cli/cmd_Social.ts +5 -4
- package/src/cli/cmd_SocialDrafts.ts +23 -10
- package/src/cli/cmd_Space.ts +1 -1
- package/src/cli/cmd_Start.ts +1 -1
- package/src/cli/cmd_ThreadKinds.ts +18 -11
- package/src/cli/cmd_ThreadReflect.ts +20 -12
- package/src/cli/cmd_ThreadSyncNeeds.ts +7 -7
- package/src/cli/cmd_Time.ts +2 -1
- package/src/cli/cmd_Tmp.ts +9 -8
- package/src/cli/cmd_TraceAudit.ts +1 -1
- package/src/cli/cmd_Trailer.ts +5 -5
- package/src/cli/cmd_Urls.ts +3 -3
- package/src/cli/cmd_Vault.ts +4 -4
- package/src/cli/cmd_When.ts +1 -1
- package/src/cli/cmd_Worktrees.ts +109 -0
- package/src/cli/registry.ts +15 -4
- package/src/cli.ts +21 -13
- package/src/collections/actions.ts +2 -1
- package/src/collections/checks.ts +1 -1
- package/src/collections/collection-types.ts +16 -5
- package/src/collections/pings.ts +3 -0
- package/src/collections/providers.ts +15 -15
- package/src/collections/review.ts +25 -23
- package/src/collections/state-rules.ts +8 -7
- package/src/comfy/comfy-panel.ts +2 -2
- package/src/commands/model.ts +1 -1
- package/src/commands/routes.ts +1 -1
- package/src/commands/runs.ts +1 -1
- package/src/core/app-icon.ts +3 -9
- package/src/core/atomic-write.ts +36 -0
- package/src/core/budget.ts +16 -1
- package/src/core/bun-builtins.ts +7 -7
- package/src/core/canonical-scripts.ts +4 -6
- package/src/core/check-ctx.ts +17 -3
- package/src/core/day-stamp.ts +20 -0
- package/src/core/git-bin.ts +10 -0
- package/src/core/git.ts +60 -16
- package/src/core/hard-reset.ts +1 -2
- package/src/core/history-files.ts +4 -8
- package/src/core/house-layout.ts +3 -0
- package/src/core/hub-theme.ts +16 -0
- package/src/core/identity.ts +1 -1
- package/src/core/in-base.ts +19 -0
- package/src/core/instance.ts +15 -5
- package/src/core/last-good.ts +42 -133
- package/src/core/layout.ts +1 -1
- package/src/core/load-probe.ts +4 -8
- package/src/core/locked-write.ts +117 -47
- package/src/core/loop-watch.ts +24 -3
- package/src/core/machine-db.ts +54 -12
- package/src/core/machine-link.ts +1 -1
- package/src/core/memory-watch.ts +3 -2
- package/src/core/motherhome.ts +2 -1
- package/src/core/nearest.ts +23 -0
- package/src/core/on-loop.ts +57 -0
- package/src/core/one-way-in-policy.ts +26 -13
- package/src/core/raw-access.ts +9 -2
- package/src/core/reexec.ts +3 -5
- package/src/core/repo-walk.ts +104 -0
- package/src/core/retention.ts +10 -12
- package/src/core/run-dirs.ts +45 -0
- package/src/core/runs-matrix.ts +1 -1
- package/src/core/slots.ts +2 -2
- package/src/core/slug.ts +33 -0
- package/src/core/spawn-timeout.ts +3 -1
- package/src/core/squircle.ts +0 -8
- package/src/core/throwaway-worktree.ts +21 -2
- package/src/core/unit-files.ts +4 -4
- package/src/core/when-block.ts +4 -5
- package/src/core/when.ts +1 -3
- package/src/core/words.ts +33 -0
- package/src/fleet/push-fleet.ts +4 -11
- package/src/{core → gate}/cache-audit.ts +1 -1
- package/src/{core → gate}/check-runner.ts +24 -54
- package/src/{core → gate}/discover-checks.ts +5 -102
- package/src/{core → gate}/discover-legacy-checks.ts +3 -3
- package/src/{ledger → gate}/gate-checks.ts +5 -5
- package/src/gate/head-gate.ts +151 -0
- package/src/{core → gate}/job-follow.ts +1 -1
- package/src/{core → gate}/job-run.ts +3 -3
- package/src/{core → gate}/pre-commit-discovery.ts +2 -2
- package/src/{core → gate}/run-check.ts +7 -7
- package/src/{core → gate}/run-ci.ts +9 -9
- package/src/gate/run-fix.ts +173 -0
- package/src/{core → gate}/run-fixers.ts +14 -14
- package/src/{core → gate}/trace-audit.ts +8 -8
- package/src/home/activity-shape.ts +1 -1
- package/src/home/activity.ts +13 -11
- package/src/home/app-sign.ts +17 -9
- package/src/home/daemon-guard.ts +6 -0
- package/src/home/daemon-jobs.ts +52 -10
- package/src/home/database-words.ts +21 -27
- package/src/home/databases.ts +3 -3
- package/src/home/global-context.ts +2 -2
- package/src/home/global-units.ts +1 -1
- package/src/home/gui-app/ShipkitGui.swift +129 -55
- package/src/home/gui-app.ts +1 -1
- package/src/home/handover.ts +126 -0
- package/src/home/home-move.ts +29 -16
- package/src/home/home-paths.ts +30 -8
- package/src/home/home-routes.ts +75 -5
- package/src/home/home-start.ts +1 -1
- package/src/home/home-state.ts +12 -6
- package/src/home/hubs.ts +28 -5
- package/src/home/inbox-shape.ts +61 -38
- package/src/home/inbox.ts +2 -1
- package/src/home/lib-watch.ts +93 -74
- package/src/home/machine-fold.ts +46 -43
- package/src/home/machine-repair.ts +5 -6
- package/src/home/machine-stores.ts +3 -3
- package/src/home/machine-temp.ts +58 -67
- package/src/home/page-build.ts +330 -0
- package/src/home/page-held.ts +338 -0
- package/src/home/pm-config.ts +10 -2
- package/src/home/pm.ts +35 -1
- package/src/home/process-apps.ts +3 -3
- package/src/home/push-sources.ts +132 -0
- package/src/home/run-daemon.ts +54 -4
- package/src/home/run-pm.ts +2 -1
- package/src/home/run-web.ts +11 -6
- package/src/home/search-shape.ts +54 -0
- package/src/home/search.ts +114 -0
- package/src/home/serve-daemon.ts +40 -18
- package/src/home/serve-web.ts +86 -145
- package/src/home/space-page.ts +7 -7
- package/src/home/space-words.ts +11 -10
- package/src/home/supervise.ts +24 -0
- package/src/home/time-page-shape.ts +0 -13
- package/src/home/vault-page.ts +15 -15
- package/src/home/vault-reveal.ts +29 -0
- package/src/home/vault-words.ts +3 -3
- package/src/home/via-hub.ts +3 -4
- package/src/home/worktree-tidy.ts +236 -0
- package/src/hooks/edit-guard.ts +12 -0
- package/src/hooks/hook-gates.ts +2 -0
- package/src/hooks/leak-guard.ts +9 -3
- package/src/hooks/one-way-in-guard.ts +11 -3
- package/src/hooks/run-hooks.ts +58 -5
- package/src/hooks/shared-file.ts +174 -0
- package/src/{serve → house}/project-gutter.ts +5 -1
- package/src/hq/door-route.ts +2 -2
- package/src/hq/door.ts +3 -3
- package/src/hq/files-send.ts +5 -5
- package/src/hq/forgotten-log.ts +1 -1
- package/src/hq/history-check.ts +7 -6
- package/src/hq/history-send.ts +12 -14
- package/src/hq/hq-db.ts +1 -1
- package/src/hq/hq-local.ts +12 -10
- package/src/hq/hq-routes.ts +1 -1
- package/src/hq/hq-store.ts +4 -4
- package/src/hq/kinds/ask.ts +4 -3
- package/src/hq/kinds/index.ts +4 -4
- package/src/hq/kinds/{card-gone.ts → item-gone.ts} +24 -25
- package/src/hq/kinds/{card-msg.ts → item-msg.ts} +25 -27
- package/src/hq/kinds/{card.ts → item.ts} +31 -29
- package/src/hq/kinds/kind.ts +3 -0
- package/src/hq/kinds/media.ts +2 -3
- package/src/hq/kinds/prompt.ts +2 -1
- package/src/hq/kinds/time-day.ts +5 -4
- package/src/hq/ledger.ts +22 -22
- package/src/hq/machine-notes.ts +14 -15
- package/src/hq/outbox.ts +31 -22
- package/src/hq/report.ts +10 -12
- package/src/hq/switch.ts +20 -23
- package/src/hq/{cards.ts → thread-sync.ts} +127 -99
- package/src/hq/vault-route.ts +1 -1
- package/src/{serve → http}/door-forward.ts +11 -4
- package/src/http/loopback-serve.ts +84 -0
- package/src/{serve → http}/same-origin.ts +3 -2
- package/src/{serve → http}/tailnet-caller.ts +5 -4
- package/src/identities/machine-route.ts +2 -2
- package/src/identities/shown.ts +2 -6
- package/src/ledger/check-table.ts +1 -1
- package/src/ledger/db.ts +1 -0
- package/src/ledger/git-key.ts +9 -3
- package/src/ledger/git-scan.ts +2 -2
- package/src/ledger/ledger.ts +6 -16
- package/src/media-kinds.ts +4 -1
- package/src/media-store/backup/daemon.ts +3 -2
- package/src/media-store/backup/keys.ts +0 -3
- package/src/media-store/backup/manifest.ts +1 -1
- package/src/media-store/backup/prune.ts +15 -18
- package/src/media-store/backup/retention.ts +2 -2
- package/src/media-store/backup/run.ts +8 -27
- package/src/media-store/backup/sources.ts +11 -12
- package/src/media-store/backup/thread-copy.ts +8 -9
- package/src/media-store/backup/watch.ts +10 -6
- package/src/media-store/content.ts +3 -0
- package/src/media-store/copy/night.ts +4 -4
- package/src/media-store/daemon.ts +5 -4
- package/src/media-store/db.ts +10 -20
- package/src/media-store/forget-one.ts +247 -0
- package/src/media-store/forget.ts +23 -4
- package/src/media-store/hq-send.ts +5 -4
- package/src/media-store/purge.ts +2 -2
- package/src/media-store/remote.ts +2 -2
- package/src/media-store/space-listing.ts +0 -5
- package/src/media-store/space.ts +1 -0
- package/src/media-store/tidy.ts +3 -3
- package/src/media-store/upload.ts +2 -2
- package/src/media-store/webp.ts +3 -3
- package/src/messages/objects.ts +5 -3
- package/src/messages/score.ts +1 -3
- package/src/messages/store-doc.ts +114 -0
- package/src/messages/verdicts.ts +6 -0
- package/src/messages/write.ts +3 -3
- package/src/mv/mv-md.ts +43 -12
- package/src/orchestrator/brief.md +29 -0
- package/src/orchestrator/deliver.ts +81 -0
- package/src/orchestrator/drill.ts +129 -0
- package/src/orchestrator/guards.ts +63 -0
- package/src/orchestrator/keeper.ts +332 -0
- package/src/orchestrator/phone.ts +98 -0
- package/src/orchestrator/pm.ts +20 -0
- package/src/orchestrator/presence-shape.ts +17 -0
- package/src/orchestrator/presence.ts +68 -0
- package/src/orchestrator/push.ts +102 -0
- package/src/orchestrator/routes.ts +113 -0
- package/src/orchestrator/state.ts +92 -0
- package/src/orchestrator/switch.ts +86 -0
- package/src/orchestrator/tmux.ts +82 -0
- package/src/orchestrator/unheard.ts +68 -0
- package/src/pages/unit.ts +1 -1
- package/src/plan/repo-source.ts +1 -1
- package/src/recordings/load.ts +1 -1
- package/src/recordings/model.ts +18 -10
- package/src/recordings/place.ts +3 -3
- package/src/recordings/recorder-app/Capture.swift +69 -21
- package/src/recordings/recorder-app/Editor.swift +214 -11
- package/src/recordings/recorder-app/main.swift +229 -47
- package/src/recordings/recorder-app.ts +1 -1
- package/src/recordings/routes.ts +11 -1
- package/src/recordings/take.ts +7 -5
- package/src/recordings/view.ts +6 -0
- package/src/reflect/prompt-corpus.ts +5 -3
- package/src/reflect/thread-words.ts +51 -0
- package/src/reflections/reflection-close.ts +123 -0
- package/src/reflections/reflection-doc.ts +59 -0
- package/src/reflections/reflection-place.ts +60 -0
- package/src/release/gate-checkout.ts +122 -20
- package/src/release/git-facts.ts +9 -8
- package/src/release/machine-words.ts +21 -3
- package/src/release/public-clean.ts +78 -19
- package/src/release/run-bump.ts +3 -5
- package/src/release/run-release.ts +42 -38
- package/src/releases/add.ts +33 -87
- package/src/releases/{from-card.ts → from-thread.ts} +47 -46
- package/src/releases/model.ts +207 -36
- package/src/releases/routes.ts +2 -2
- package/src/releases/shape.ts +184 -0
- package/src/releases/store.ts +10 -10
- package/src/repo-config.ts +13 -3
- package/src/review/anim.ts +7 -7
- package/src/review/answer-kinds.ts +39 -10
- package/src/review/auto.ts +3 -3
- package/src/review/band.ts +95 -3
- package/src/review/branch-hold.ts +12 -5
- package/src/review/cells.ts +169 -46
- package/src/review/doc-card.ts +41 -0
- package/src/review/doc-model.ts +100 -0
- package/src/review/doc-routes.ts +66 -0
- package/src/review/doc-save.ts +152 -0
- package/src/review/{draft-card.ts → draft-item.ts} +10 -7
- package/src/review/draft-model.ts +125 -17
- package/src/review/events.ts +5 -12
- package/src/review/file-tags.ts +52 -0
- package/src/review/format.ts +84 -41
- package/src/review/gone.ts +20 -20
- package/src/review/hand-over.ts +58 -0
- package/src/review/heard.ts +29 -0
- package/src/review/house-kind-defs.ts +34 -4
- package/src/review/http.ts +1 -1
- package/src/review/inbox-hook.ts +55 -9
- package/src/review/inbox-read.ts +38 -13
- package/src/review/instructions.ts +42 -0
- package/src/review/{card-db.ts → item-db.ts} +32 -30
- package/src/review/{card-rows.ts → item-rows.ts} +77 -50
- package/src/review/kind-still.ts +125 -0
- package/src/review/kinds.ts +46 -10
- package/src/review/lane-ask.ts +6 -2
- package/src/review/live-post.ts +107 -0
- package/src/review/live-view.ts +137 -0
- package/src/review/media-kind.ts +4 -4
- package/src/review/media-read.ts +4 -4
- package/src/review/media.ts +3 -5
- package/src/review/mentions.ts +100 -0
- package/src/review/model-moved.ts +76 -0
- package/src/review/model.ts +471 -149
- package/src/review/move.ts +59 -58
- package/src/review/need-address.ts +5 -5
- package/src/review/need-threads.ts +15 -57
- package/src/review/notes.ts +2 -1
- package/src/review/one-block.ts +64 -0
- package/src/review/owner-read.ts +41 -0
- package/src/review/owner-verdict.ts +3 -3
- package/src/review/parties.ts +101 -9
- package/src/review/paste.ts +4 -4
- package/src/review/phone-push.ts +137 -0
- package/src/review/previews.ts +16 -16
- package/src/review/project.ts +1 -1
- package/src/review/push.ts +269 -0
- package/src/review/referring.ts +26 -4
- package/src/review/reflection-object.ts +13 -18
- package/src/review/rev.ts +1 -1
- package/src/review/role.ts +3 -3
- package/src/review/routes.ts +113 -74
- package/src/review/search-index.ts +218 -0
- package/src/review/search-job.ts +40 -0
- package/src/review/search-ocr.ts +138 -0
- package/src/review/search-text.ts +129 -0
- package/src/review/secret-route.ts +44 -14
- package/src/review/settle.ts +67 -0
- package/src/review/stage-routes.ts +15 -13
- package/src/review/{stage-card.ts → stage-thread.ts} +18 -17
- package/src/review/store-index.ts +49 -0
- package/src/review/store-parties.ts +20 -0
- package/src/review/store.ts +394 -214
- package/src/review/supersede.ts +23 -7
- package/src/review/take-back.ts +19 -6
- package/src/review/threads.ts +184 -63
- package/src/review/traces.ts +21 -33
- package/src/review/trailer-desk.ts +7 -7
- package/src/review/{trailer-card.ts → trailer-item.ts} +10 -10
- package/src/review/trailer-model.ts +4 -4
- package/src/review/trailer-notes.ts +2 -2
- package/src/review/trailer-routes.ts +5 -4
- package/src/review/trailer-shots.ts +3 -3
- package/src/review/unit.ts +70 -9
- package/src/review/uploads.ts +103 -0
- package/src/review/verdict-items.ts +2 -2
- package/src/review/verdict-write.ts +1 -1
- package/src/review/view-layout.ts +69 -0
- package/src/review/wait.ts +11 -5
- package/src/review/wakes.ts +115 -0
- package/src/review/watch-feed.ts +183 -0
- package/src/review/watchers.ts +27 -6
- package/src/rules/untrack-generated.ts +40 -39
- package/src/scaffold/files/bunfig.toml +1 -9
- package/src/scaffold/files/vscode-settings.json +1 -1
- package/src/scaffold/project-scaffold.ts +14 -10
- package/src/secrets/archive.ts +2 -1
- package/src/secrets/keychain-write.ts +11 -3
- package/src/secrets/lapse-mark.ts +8 -3
- package/src/secrets/lapse.ts +26 -15
- package/src/secrets/security-line.ts +19 -0
- package/src/serve/embed.ts +1 -1
- package/src/serve/house-runs.ts +1 -1
- package/src/serve/hub-app/accounts-line.tsx +67 -0
- package/src/serve/hub-app/activity-st.ts +46 -50
- package/src/serve/hub-app/advice-box.tsx +66 -0
- package/src/serve/hub-app/advisor-app.tsx +46 -0
- package/src/serve/hub-app/advisor-face.tsx +29 -0
- package/src/serve/hub-app/advisor-host.ts +142 -0
- package/src/serve/hub-app/advisor.html +22 -0
- package/src/serve/hub-app/advisors-st.ts +261 -0
- package/src/serve/hub-app/advisors-view.tsx +269 -0
- package/src/serve/hub-app/advisors.css +57 -0
- package/src/serve/hub-app/app-bridge.ts +27 -24
- package/src/serve/hub-app/ask-steps-st.ts +60 -0
- package/src/serve/hub-app/ask-steps.tsx +23 -0
- package/src/serve/hub-app/asks-page.tsx +8 -5
- package/src/serve/hub-app/asks-st.ts +1 -4
- package/src/serve/hub-app/auto-text.tsx +106 -14
- package/src/serve/hub-app/checks-svc.ts +1 -1
- package/src/serve/hub-app/clock-svc.ts +21 -5
- package/src/serve/hub-app/code-copy.ts +173 -12
- package/src/serve/hub-app/col-card.tsx +14 -21
- package/src/serve/hub-app/col-list-page.tsx +2 -2
- package/src/serve/hub-app/col-list-st.ts +6 -1
- package/src/serve/hub-app/col-tables.ts +14 -8
- package/src/serve/hub-app/cols-svc.ts +11 -1
- package/src/serve/hub-app/comfy-svc.ts +3 -2
- package/src/serve/hub-app/commands/commands-st.ts +36 -26
- package/src/serve/hub-app/controls.css +27 -11
- package/src/serve/hub-app/cursor-spot.ts +81 -0
- package/src/serve/hub-app/database-st.ts +31 -26
- package/src/serve/hub-app/database-view.tsx +12 -12
- package/src/serve/hub-app/dock-st.ts +51 -10
- package/src/serve/hub-app/dock-view.tsx +14 -1
- package/src/serve/hub-app/editor/doc-editor-st.ts +223 -0
- package/src/serve/hub-app/editor/doc-editor.tsx +116 -0
- package/src/serve/hub-app/editor/doc-saved.tsx +26 -0
- package/src/serve/hub-app/editor/doc-slot.ts +66 -0
- package/src/serve/hub-app/editor.css +36 -0
- package/src/serve/hub-app/emoji-names.ts +1915 -0
- package/src/serve/hub-app/emoji.ts +133 -0
- package/src/serve/hub-app/floating.tsx +162 -6
- package/src/serve/hub-app/git-st.ts +25 -19
- package/src/serve/hub-app/hash-route.ts +1 -1
- package/src/serve/hub-app/header-bar.tsx +4 -3
- package/src/serve/hub-app/held-keys.ts +25 -0
- package/src/serve/hub-app/home-st.ts +114 -16
- package/src/serve/hub-app/home-strip.css +3 -2
- package/src/serve/hub-app/home-strip.tsx +5 -2
- package/src/serve/hub-app/home.html +7 -0
- package/src/serve/hub-app/hub-app.tsx +56 -6
- package/src/serve/hub-app/hub.css +67 -31
- package/src/serve/hub-app/icons.tsx +10 -0
- package/src/serve/hub-app/identities-st.ts +35 -25
- package/src/serve/hub-app/identities-view.tsx +9 -6
- package/src/serve/hub-app/inbox-st.ts +39 -11
- package/src/serve/hub-app/inbox-view.tsx +10 -5
- package/src/serve/hub-app/inbox.css +6 -3
- package/src/serve/hub-app/index.html +7 -0
- package/src/serve/hub-app/insights-st.ts +27 -19
- package/src/serve/hub-app/instructions.css +9 -6
- package/src/serve/hub-app/kept-folds.ts +43 -0
- package/src/serve/hub-app/keys.ts +9 -3
- package/src/serve/hub-app/later.tsx +1 -1
- package/src/serve/hub-app/layout-st.ts +37 -6
- package/src/serve/hub-app/list-filter.tsx +1 -1
- package/src/serve/hub-app/live-bar.css +12 -0
- package/src/serve/hub-app/live-svc.ts +12 -2
- package/src/serve/hub-app/machine-st.ts +36 -10
- package/src/serve/hub-app/machines-st.ts +40 -34
- package/src/serve/hub-app/machines-view.tsx +5 -5
- package/src/serve/hub-app/markdown.css +81 -4
- package/src/serve/hub-app/md.ts +155 -9
- package/src/serve/hub-app/media-svc.ts +44 -11
- package/src/serve/hub-app/messages/messages-page.tsx +56 -12
- package/src/serve/hub-app/messages/messages-st.ts +26 -22
- package/src/serve/hub-app/new-thread.tsx +121 -0
- package/src/serve/hub-app/objects.css +1 -0
- package/src/serve/hub-app/orchestrator-line.tsx +104 -0
- package/src/serve/hub-app/orchestrator.css +37 -0
- package/src/serve/hub-app/page-keys.ts +7 -4
- package/src/serve/hub-app/page-reload.ts +111 -0
- package/src/serve/hub-app/pages-frames.tsx +2 -1
- package/src/serve/hub-app/pages-svc.ts +8 -3
- package/src/serve/hub-app/palette-st.ts +7 -2
- package/src/serve/hub-app/pane-boundary.tsx +13 -0
- package/src/serve/hub-app/pane-errors.ts +2 -1
- package/src/serve/hub-app/pano.css +20 -0
- package/src/serve/hub-app/plan-view.tsx +1 -1
- package/src/serve/hub-app/planned-st.ts +30 -26
- package/src/serve/hub-app/planned-view.tsx +16 -9
- package/src/serve/hub-app/polled.ts +201 -0
- package/src/serve/hub-app/presence-st.ts +110 -0
- package/src/serve/hub-app/project-list.css +98 -55
- package/src/serve/hub-app/project-list.tsx +136 -149
- package/src/serve/hub-app/projects-svc.ts +109 -57
- package/src/serve/hub-app/push-sign.tsx +15 -0
- package/src/serve/hub-app/push-svc.ts +273 -0
- package/src/serve/hub-app/quiet-st.ts +59 -0
- package/src/serve/hub-app/rail-fly.tsx +95 -0
- package/src/serve/hub-app/reach.ts +16 -0
- package/src/serve/hub-app/recordings-st.ts +169 -9
- package/src/serve/hub-app/recordings-take.ts +58 -0
- package/src/serve/hub-app/recordings-view.tsx +42 -35
- package/src/serve/hub-app/recordings.css +1 -1
- package/src/serve/hub-app/reflections-page.tsx +16 -4
- package/src/serve/hub-app/releases/releases-page.tsx +52 -19
- package/src/serve/hub-app/releases/releases-st.ts +39 -26
- package/src/serve/hub-app/releases.css +4 -0
- package/src/serve/hub-app/repo-sections.ts +21 -10
- package/src/serve/hub-app/repo-st.ts +36 -9
- package/src/serve/hub-app/review/advisor-bar.tsx +40 -0
- package/src/serve/hub-app/review/attach-st.ts +195 -0
- package/src/serve/hub-app/review/attach-view.tsx +260 -0
- package/src/serve/hub-app/review/clip-st.ts +1 -1
- package/src/serve/hub-app/review/cta.tsx +11 -0
- package/src/serve/hub-app/review/diff-view.tsx +37 -35
- package/src/serve/hub-app/review/doc-body.tsx +109 -0
- package/src/serve/hub-app/review/dock.tsx +36 -22
- package/src/serve/hub-app/review/draft-body.tsx +235 -0
- package/src/serve/hub-app/review/faces.tsx +26 -0
- package/src/serve/hub-app/review/group-block.tsx +75 -45
- package/src/serve/hub-app/review/heard-line.tsx +31 -0
- package/src/serve/hub-app/review/instructions-view.tsx +57 -32
- package/src/serve/hub-app/review/item-verdict.tsx +99 -26
- package/src/serve/hub-app/review/kind-states.tsx +148 -76
- package/src/serve/hub-app/review/kind-view.tsx +22 -7
- package/src/serve/hub-app/review/kit.tsx +4 -28
- package/src/serve/hub-app/review/lane-bar.tsx +4 -4
- package/src/serve/hub-app/review/lightbox.tsx +16 -0
- package/src/serve/hub-app/review/line-window.ts +149 -0
- package/src/serve/hub-app/review/live-bar-st.ts +145 -0
- package/src/serve/hub-app/review/live-bar.tsx +126 -0
- package/src/serve/hub-app/review/live-view.tsx +104 -0
- package/src/serve/hub-app/review/mention-st.ts +85 -0
- package/src/serve/hub-app/review/mesh-view.tsx +9 -0
- package/src/serve/hub-app/review/object-panel.tsx +35 -17
- package/src/serve/hub-app/review/pano-gl.ts +145 -0
- package/src/serve/hub-app/review/pano-view.tsx +192 -0
- package/src/serve/hub-app/review/phone-top.tsx +16 -0
- package/src/serve/hub-app/review/pictures-st.ts +38 -0
- package/src/serve/hub-app/review/question-views.tsx +107 -105
- package/src/serve/hub-app/review/review-board.tsx +1 -1
- package/src/serve/hub-app/review/review-cells.tsx +169 -111
- package/src/serve/hub-app/review/review-host.ts +69 -0
- package/src/serve/hub-app/review/review-kit.ts +34 -19
- package/src/serve/hub-app/review/review-list.tsx +123 -20
- package/src/serve/hub-app/review/review-page.tsx +7 -18
- package/src/serve/hub-app/review/review-st.ts +241 -138
- package/src/serve/hub-app/review/review-thread.tsx +463 -150
- package/src/serve/hub-app/review/review-views.tsx +540 -449
- package/src/serve/hub-app/review/scene-view.tsx +26 -0
- package/src/serve/hub-app/review/secret-facts.ts +26 -0
- package/src/serve/hub-app/review/space3d.tsx +114 -0
- package/src/serve/hub-app/review/splat-view.tsx +9 -0
- package/src/serve/hub-app/review/superseded-runs.ts +76 -0
- package/src/serve/hub-app/review/thread-close.tsx +17 -7
- package/src/serve/hub-app/review/thread-control-st.ts +2 -1
- package/src/serve/hub-app/review/thread-st.ts +528 -158
- package/src/serve/hub-app/review/thread-views.ts +71 -0
- package/src/serve/hub-app/review/{trailer-card.tsx → trailer-body.tsx} +34 -34
- package/src/serve/hub-app/review/trailer-page.tsx +23 -25
- package/src/serve/hub-app/review/trailer-st.ts +38 -38
- package/src/serve/hub-app/review/trailer-timeline.tsx +23 -19
- package/src/serve/hub-app/review/trailer-voices.tsx +3 -2
- package/src/serve/hub-app/review.css +259 -147
- package/src/serve/hub-app/search-st.ts +138 -0
- package/src/serve/hub-app/search-view.tsx +92 -0
- package/src/serve/hub-app/section-head.tsx +5 -4
- package/src/serve/hub-app/shell-rows.ts +126 -0
- package/src/serve/hub-app/site/site-st.ts +18 -23
- package/src/serve/hub-app/social/comms-page.tsx +14 -11
- package/src/serve/hub-app/social/group-editor.tsx +44 -0
- package/src/serve/hub-app/social/kit.tsx +7 -46
- package/src/serve/hub-app/social/next-release.tsx +2 -2
- package/src/serve/hub-app/social/post-card.tsx +16 -52
- package/src/serve/hub-app/social/problems.tsx +5 -4
- package/src/serve/hub-app/social/social-page.tsx +3 -3
- package/src/serve/hub-app/social/social-st.ts +31 -84
- package/src/serve/hub-app/social/stage-popup.tsx +6 -6
- package/src/serve/hub-app/social/stage-st.ts +9 -9
- package/src/serve/hub-app/social.css +0 -8
- package/src/serve/hub-app/space-st.ts +38 -48
- package/src/serve/hub-app/space-view.tsx +6 -6
- package/src/serve/hub-app/stores/stores-page.tsx +4 -4
- package/src/serve/hub-app/stores/stores-st.ts +19 -23
- package/src/serve/hub-app/terminal-input.ts +12 -0
- package/src/serve/hub-app/terminal-panel.tsx +40 -0
- package/src/serve/hub-app/terminal-st.ts +416 -0
- package/src/serve/hub-app/terminal.css +15 -0
- package/src/serve/hub-app/tests-svc.ts +3 -2
- package/src/serve/hub-app/theme-st.ts +1 -9
- package/src/serve/hub-app/thread-row.tsx +52 -17
- package/src/serve/hub-app/time-ago.tsx +39 -16
- package/src/serve/hub-app/time-st.ts +43 -27
- package/src/serve/hub-app/time-view.tsx +3 -3
- package/src/serve/hub-app/tree-build.ts +2 -2
- package/src/serve/hub-app/tree-row.tsx +43 -18
- package/src/serve/hub-app/tree-svc.ts +1 -1
- package/src/serve/hub-app/urls-svc.ts +6 -5
- package/src/serve/hub-app/vault-st.ts +32 -27
- package/src/serve/hub-app/vault-view.tsx +53 -2
- package/src/serve/hub-app/vault.css +2 -0
- package/src/serve/hub-app/veille/veille-page.tsx +4 -4
- package/src/serve/hub-app/veille/veille-st.ts +56 -49
- package/src/serve/hub-app/view-layout.css +90 -0
- package/src/serve/hub-app/waiting-svc.ts +2 -1
- package/src/serve/hub-app/wiki-st.ts +3 -2
- package/src/serve/hub-app/wikis-view.tsx +18 -15
- package/src/serve/hub-app/words.tsx +15 -0
- package/src/serve/hub-collections.ts +105 -0
- package/src/serve/hub-runtime.ts +67 -89
- package/src/serve/live-hop.ts +102 -0
- package/src/serve/other-repos.ts +1 -1
- package/src/serve/project-gutter-route.ts +53 -40
- package/src/serve/read-thread.ts +76 -0
- package/src/serve/read-worker.ts +53 -0
- package/src/serve/run-serve.ts +11 -7
- package/src/serve/secret-gate.ts +3 -3
- package/src/serve/serve-hub.ts +103 -34
- package/src/serve/terminal-guard.ts +50 -0
- package/src/serve/terminal-route.ts +176 -0
- package/src/shipkit.ts +8 -8
- package/src/shot/client.ts +32 -16
- package/src/shot/dom-clip.ts +30 -5
- package/src/shot/film-box.ts +23 -8
- package/src/shot/serve-shot.ts +16 -5
- package/src/shot/shooter.ts +72 -24
- package/src/shot/shot-ask.ts +17 -6
- package/src/shot/shot-guard.ts +53 -0
- package/src/shot/shot-theme.ts +70 -0
- package/src/shot/still-file.ts +60 -0
- package/src/site/desk.ts +4 -3
- package/src/social/compose.ts +13 -7
- package/src/social/cover.ts +4 -3
- package/src/social/desk-index.ts +2 -2
- package/src/social/draft-doc.ts +88 -0
- package/src/social/draft-versions.ts +80 -0
- package/src/social/drafts.ts +22 -4
- package/src/social/fit.ts +4 -3
- package/src/social/house.ts +1 -1
- package/src/social/import-drafts.ts +1 -1
- package/src/social/kinds.ts +1 -1
- package/src/social/load.ts +21 -13
- package/src/social/media-facts.ts +1 -19
- package/src/social/media-kind.ts +2 -2
- package/src/social/media-limit.ts +3 -18
- package/src/social/no-account.ts +38 -0
- package/src/social/post-sources.ts +4 -4
- package/src/social/post-text.ts +33 -13
- package/src/social/posts.ts +73 -18
- package/src/social/presence.ts +10 -8
- package/src/social/release-stage.ts +22 -22
- package/src/social/routes.ts +12 -30
- package/src/social/stage.ts +3 -3
- package/src/social/stats.ts +3 -4
- package/src/social/strip.ts +4 -6
- package/src/social/text.ts +2 -1
- package/src/social/{card-drafts.ts → thread-drafts.ts} +3 -3
- package/src/social/unit.ts +12 -3
- package/src/social/writes.ts +0 -6
- package/src/start-repo.ts +33 -13
- package/src/stores/desk.ts +1 -1
- package/src/suite/core-counters.ts +31 -3
- package/src/suite/judge-suites.ts +69 -47
- package/src/suite/select.ts +1 -27
- package/src/suite/suite-cli.ts +18 -8
- package/src/suite/suite-cpu-preload.ts +10 -6
- package/src/trace/tracer.ts +4 -5
- package/src/trailer/build.ts +30 -15
- package/src/trailer/ffmpeg.ts +90 -31
- package/src/trailer/fonts.ts +5 -6
- package/src/trailer/footage.ts +9 -3
- package/src/trailer/grammar.ts +2 -1
- package/src/trailer/graph.ts +12 -10
- package/src/trailer/load-unit.ts +1 -1
- package/src/trailer/passage.ts +4 -3
- package/src/trailer/prune.ts +4 -4
- package/src/trailer/score/sound.ts +3 -3
- package/src/trailer/shot-plan.ts +5 -5
- package/src/trailer/shot-state.ts +25 -31
- package/src/trailer/sound/eleven.ts +2 -1
- package/src/trailer/sound/gen.ts +3 -3
- package/src/trailer/sound/run.ts +76 -64
- package/src/trailer/sound/takes.ts +0 -3
- package/src/trailer/take-fault.ts +41 -0
- package/src/trailer/titles.ts +17 -13
- package/src/trailer/url.ts +1 -1
- package/src/trailer/vertical-draw.ts +7 -7
- package/src/trailer/vertical.ts +3 -3
- package/src/trailer/vocab.ts +3 -4
- package/src/ts/config.ts +60 -24
- package/src/ts/cycles.ts +3 -1
- package/src/ts/imports.ts +17 -3
- package/src/ts/rename.ts +6 -7
- package/src/ts/source-graph.ts +15 -9
- package/src/ts/workspaces.ts +26 -0
- package/src/tui/build-steps-panel.ts +3 -3
- package/src/tui/checks-panel.ts +2 -2
- package/src/urls/frame.ts +3 -3
- package/src/urls/routes.ts +1 -1
- package/src/urls/rows.ts +1 -1
- package/src/vault/house-keys.ts +1 -1
- package/src/vault/vault-audit.ts +2 -3
- package/src/vault/vault-config.ts +6 -2
- package/src/vault/vault-restore.ts +3 -9
- package/src/vault/vault-serve.ts +47 -11
- package/src/vault/vault-snapshot.ts +5 -14
- package/src/veille/desk.ts +2 -2
- package/src/veille/routes.ts +1 -1
- package/src/view3d/cam.ts +101 -0
- package/src/view3d/lib.ts +69 -0
- package/src/view3d/loop.ts +39 -0
- package/src/view3d/scene-cache.ts +62 -0
- package/src/view3d/viewer.ts +480 -0
- package/src/wiki/agent-paths.ts +55 -0
- package/src/wiki/run-wiki.ts +4 -1
- package/src/wiki/serve-graph.ts +2 -3
- package/src/core/run-fix.ts +0 -120
- package/src/home/hmr-keep.ts +0 -134
- package/src/serve/hub-app/review/draft-card.tsx +0 -163
- package/src/serve/hub-app/review/note-place.ts +0 -31
- /package/src/{serve → http}/door-names.ts +0 -0
- /package/src/{serve → http}/hub-port.ts +0 -0
package/src/cli/cmd_Review.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
// sk thread: an agent shows the owner something as
|
|
1
|
+
// sk thread: an agent shows the owner something as a version in its thread and reads his answer; a dispatcher routes
|
|
2
2
|
// what he, a player or a rule raised, a worker claims and closes it (review/store.ts, wiki tools/shipkit/threads.md).
|
|
3
3
|
// Every module loads inside execute: the cli registers this file on every `sk` call
|
|
4
4
|
import { Command, Option } from 'clipanion'
|
|
5
5
|
import type { AnswerKind } from '../review/model.ts'
|
|
6
|
+
import { holdsThread, laneOfCaller, maySee } from '../review/parties.ts'
|
|
7
|
+
import { realGit } from '../core/git.ts'
|
|
8
|
+
import { ageWords } from '../core/words.ts'
|
|
6
9
|
|
|
7
10
|
const DETAILS = `threads, the one exchange with the owner (wiki tools/shipkit/threads.md): one thread per subject, found by its address <kind>:<key>, for its whole life. sk thread post <address> sends a version into it, linked by the tool; ask, propose, reply and update write in it, and start it when no thread owns the address. He answers in the hub's threads page; you read his answer with watch, inbox or the inbox hook, then mark it seen. What he, a player or a rule raises is an item of the same store with its own state, closed with sk thread fixed. The store: .shipkit/review/ of each repo, or the daemon's rows (sk thread move). SK_AGENT names your lane.`
|
|
8
11
|
|
|
@@ -19,7 +22,7 @@ interface Here {
|
|
|
19
22
|
err: (l: string) => void
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
/** the shipkit repo the cwd stands in: only its store reaches a hub, so anywhere else
|
|
25
|
+
/** the shipkit repo the cwd stands in: only its store reaches a hub, so anywhere else an item is refused before a
|
|
23
26
|
* stray .shipkit/review/ is made where nobody looks */
|
|
24
27
|
async function reviewRoot(cwd: string): Promise<string | null> {
|
|
25
28
|
const { findRepoRoot } = await import('../ts/config.ts')
|
|
@@ -55,7 +58,7 @@ async function run(context: Ctx, body: (h: Here) => Promise<number> | number, o:
|
|
|
55
58
|
return await body({ dir, unit, say: { spec: specOf(dir), more: (x) => factLines(unit, x) }, out, err })
|
|
56
59
|
} catch (e) {
|
|
57
60
|
err(`FAIL: review: ${e instanceof Error ? e.message : String(e)}`)
|
|
58
|
-
// a walk of the
|
|
61
|
+
// a walk of the items' database runs: run it again once it ends
|
|
59
62
|
const { isStoreRefused, WAIT_EXIT } = await import('../core/machine-db.ts')
|
|
60
63
|
return isStoreRefused(e) && e.wait ? WAIT_EXIT : 1
|
|
61
64
|
}
|
|
@@ -66,9 +69,9 @@ const isHelp = (a: string): boolean => a === '--help' || a === '-h'
|
|
|
66
69
|
/** the verbs that write an agent's act in a thread */
|
|
67
70
|
const WRITING_VERBS = new Set(['post', 'add', 'add-view', 'ask', 'propose', 'reply', 'update', 'take', 'assign', 'working', 'fixed', 'done', 'attach', 'ready'])
|
|
68
71
|
|
|
69
|
-
/** the agent that acts
|
|
72
|
+
/** the agent that acts (review/parties.ts laneOfCaller); `need` refuses an unnamed one */
|
|
70
73
|
function actor(as: string | undefined, need: boolean, verb: string): string {
|
|
71
|
-
const n = as
|
|
74
|
+
const n = callerLane(as)
|
|
72
75
|
if (n === 'owner') throw new Error('the owner acts from the hub, not from here')
|
|
73
76
|
if (n) return n
|
|
74
77
|
if (need) throw new Error(`${verb} needs --as <name> (or SK_AGENT)`)
|
|
@@ -77,15 +80,27 @@ function actor(as: string | undefined, need: boolean, verb: string): string {
|
|
|
77
80
|
|
|
78
81
|
/** an item id, a player report's ref (`live#3`), or an address (`trailer:comfy-ts/main`, the newest version of the
|
|
79
82
|
* thread that owns it, or the one above it) to its item id */
|
|
80
|
-
async function idOf(dir: string, ref: string): Promise<string> {
|
|
83
|
+
async function idOf(dir: string, ref: string, one?: { verb: string; objects?: boolean }): Promise<string> {
|
|
81
84
|
const { itemOfRef, readAll, specOf } = await import('../review/store.ts')
|
|
82
85
|
const { addressOrThrow, ID_RE } = await import('../review/model.ts')
|
|
86
|
+
const { THREAD_ID_RE, threadIdOf, threadOfAddress, threadsOf, threadsOfId } = await import('../review/threads.ts')
|
|
87
|
+
// a thread named where one item is needed: refused with the ids it could mean, never its newest version guessed
|
|
88
|
+
const itemOf = async (t: import('../review/threads.ts').Thread): Promise<string> => {
|
|
89
|
+
if (!one) return t.head.item.id
|
|
90
|
+
const { itemIdsOf } = await import('../review/format.ts')
|
|
91
|
+
throw new Error(`${ref === threadIdOf(t) ? `${ref} is a thread` : `${ref} is the thread ${threadIdOf(t)}`}: ${one.verb} takes one item of it, by its id: ${itemIdsOf(t, one.objects).join('; ')}`)
|
|
92
|
+
}
|
|
93
|
+
if (THREAD_ID_RE.test(ref)) {
|
|
94
|
+
const ts = threadsOfId(ref, threadsOf(readAll(dir).items, specOf(dir)))
|
|
95
|
+
if (ts.length === 0) throw new Error(`no thread ${ref} (sk thread --all lists them)`)
|
|
96
|
+
if (ts.length > 1) throw new Error(`${ref} is the first version of ${ts.length} threads (two versions superseded it): name one by its newest version, ${ts.map((t) => t.head.item.id).join(' or ')}`)
|
|
97
|
+
return itemOf(ts[0]!)
|
|
98
|
+
}
|
|
83
99
|
if (!ID_RE.test(ref) && ref.includes(':') && !/^\w+#\d+$/.test(ref)) {
|
|
84
100
|
const a = addressOrThrow(ref)
|
|
85
|
-
const { threadOfAddress } = await import('../review/threads.ts')
|
|
86
101
|
const t = threadOfAddress(a, readAll(dir).items, specOf(dir), { up: true })
|
|
87
102
|
if (!t) throw new Error(`no thread owns ${a}: sk thread post ${a} --title "…" --what "…" starts it`)
|
|
88
|
-
return t
|
|
103
|
+
return itemOf(t)
|
|
89
104
|
}
|
|
90
105
|
const x = itemOfRef(dir, ref)
|
|
91
106
|
if (!x) throw new Error(`no item ${ref}`)
|
|
@@ -119,7 +134,7 @@ async function idOrOpen(h: Here, ref: string, title: string, as: string | undefi
|
|
|
119
134
|
const t = threadOfAddress(a, readAll(h.dir).items, specOf(h.dir), { up: true })
|
|
120
135
|
if (t) return t.head.item.id
|
|
121
136
|
await declaredOrThrow(h, a)
|
|
122
|
-
const lane =
|
|
137
|
+
const lane = callerLane(as)
|
|
123
138
|
const x = await openThread(h.dir, a, { title, ...(lane ? { lane } : {}) })
|
|
124
139
|
h.err(`${a}: no thread owned it, this one starts it: ${x.id}`)
|
|
125
140
|
return x.id
|
|
@@ -130,18 +145,18 @@ async function idOrOpen(h: Here, ref: string, title: string, as: string | undefi
|
|
|
130
145
|
const NO_ADDRESS =
|
|
131
146
|
'a version names the subject he judges, so it goes into that subject\'s one thread: sk thread post <kind>:<key> --title "…" --what "…" <media> (screen:<screen>, asset:<asset>, page:<page>, or a kind this repo\'s review unit declares; --trailer and --draft name their own). Page: wiki tools/shipkit/threads.md, The model'
|
|
132
147
|
|
|
133
|
-
/** the sources pulled before a read: a line per source down, said once a process */
|
|
134
|
-
const downSaid = new Set<string
|
|
148
|
+
/** the sources pulled before a read: a line per source down, said once a process and a store */
|
|
149
|
+
const downSaid = new Map<string, Set<string>>()
|
|
135
150
|
async function pull(h: Here): Promise<void> {
|
|
136
151
|
if (!h.unit?.sources?.length) return
|
|
137
152
|
const { pullSources } = await import('../review/project.ts')
|
|
138
153
|
const now = new Set<string>()
|
|
154
|
+
const said = downSaid.get(h.dir)
|
|
139
155
|
const got = await pullSources(h.dir, h.unit, (l) => {
|
|
140
156
|
now.add(l)
|
|
141
|
-
if (!
|
|
157
|
+
if (!said?.has(l)) h.err(l)
|
|
142
158
|
})
|
|
143
|
-
downSaid.
|
|
144
|
-
for (const l of now) downSaid.add(l)
|
|
159
|
+
downSaid.set(h.dir, now)
|
|
145
160
|
if (got.length > 0) h.err(`review: ${got.length} new items pulled`)
|
|
146
161
|
}
|
|
147
162
|
|
|
@@ -197,7 +212,7 @@ export function takeViews(args: readonly string[]): { views: ViewInput[]; rest:
|
|
|
197
212
|
return { views, rest }
|
|
198
213
|
}
|
|
199
214
|
|
|
200
|
-
const ADD_VIEW_USAGE = 'add-view <id> "<label>" <a.png> [<b.png>] | --image <a.png> | --before <a.png> --after <b.png> | --video <clip> | --audio <sound> | --gallery <a.png> … [--label "<label>"] [--note "<text>"] [--keep]'
|
|
215
|
+
const ADD_VIEW_USAGE = 'add-view <id> "<label>" <a.png> [<b.png>] | --image <a.png> | --before <a.png> --after <b.png> | --video <clip> | --audio <sound> | --pano <360.png> | --splat <a.ply> [--image <poster.png>] | --mesh <a.glb> [--image <poster.png>] | --gallery <a.png> … [--label "<label>"] [--note "<text>"] [--keep]'
|
|
201
216
|
const MEDIA_FILE = /\.(png|jpe?g|webp|gif|mp4|webm|mov|wav|mp3|flac|ogg|opus|m4a)$/i
|
|
202
217
|
|
|
203
218
|
/** one `--option` of a question: words, a media file, `<label>=<file>` or `<label>=<before>,<after>` (a gallery tile's
|
|
@@ -211,6 +226,31 @@ export function askOption(a: string): { label: string; files?: string[] } {
|
|
|
211
226
|
}
|
|
212
227
|
const quoted = (a: string): string => (/^[\w./=,@:+-]+$/.test(a) ? a : `"${a.replace(/"/g, '\\"')}"`)
|
|
213
228
|
|
|
229
|
+
/** a splat's or a mesh's view with its poster: the one given (--image), else the 3D file shot at rest now through the
|
|
230
|
+
* warm browser (view3d/lib.ts); `drop` deletes a shot once the store copied it. Any other view as it is */
|
|
231
|
+
async function withPoster(view: ViewInput): Promise<{ view: ViewInput; drop: () => void }> {
|
|
232
|
+
const space = view.splat ?? view.mesh
|
|
233
|
+
if (space === undefined || view.image !== undefined) return { view, drop: () => {} }
|
|
234
|
+
const { mkdtempSync, rmSync } = await import('node:fs')
|
|
235
|
+
const { tmpdir } = await import('node:os')
|
|
236
|
+
const { join } = await import('node:path')
|
|
237
|
+
const { existsSync } = await import('node:fs')
|
|
238
|
+
const kind = view.splat !== undefined ? 'splat' : 'mesh'
|
|
239
|
+
if (!existsSync(space)) throw new Error(`--${kind} ${space}: no such file`)
|
|
240
|
+
const { SPACE_EXT } = await import('../review/model.ts')
|
|
241
|
+
if (!SPACE_EXT[kind].test(space)) throw new Error(`--${kind} ${space}: ${kind === 'splat' ? 'a Gaussian splat, .ply or .spz' : 'a .glb mesh'}`)
|
|
242
|
+
const tmp = mkdtempSync(join(tmpdir(), 'view3d-poster-'))
|
|
243
|
+
const drop = (): void => rmSync(tmp, { recursive: true, force: true })
|
|
244
|
+
try {
|
|
245
|
+
const out = join(tmp, 'poster.png')
|
|
246
|
+
await (await import('../view3d/lib.ts')).shootPoster(kind, space, out)
|
|
247
|
+
return { view: { ...view, image: out }, drop }
|
|
248
|
+
} catch (e) {
|
|
249
|
+
drop()
|
|
250
|
+
throw new Error(`--${kind} ${space}: its poster could not be shot (${(e as Error).message}); give one with --image <poster.png>`)
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
214
254
|
/** add-view's args: the positional form, or the view flags of add; a flag is never a label, `own` are the repo unit's flags */
|
|
215
255
|
export async function addViewArgs(args: readonly string[], own: readonly string[]): Promise<{ id: string; view: ViewInput; repoFlags: Record<string, string[]> }> {
|
|
216
256
|
const one: Record<string, string> = {}
|
|
@@ -229,7 +269,7 @@ export async function addViewArgs(args: readonly string[], own: readonly string[
|
|
|
229
269
|
continue
|
|
230
270
|
}
|
|
231
271
|
if (name === 'what') throw new Error(`--what: a view takes no --what, a line on it is --note "<text>"; ${ADD_VIEW_USAGE}`)
|
|
232
|
-
if (!['label', 'note', 'image', 'video', 'audio', 'before', 'after', ...own].includes(name)) throw new Error(`${a}: add-view takes no such flag; ${ADD_VIEW_USAGE}`)
|
|
272
|
+
if (!['label', 'note', 'image', 'video', 'audio', 'pano', 'splat', 'mesh', 'before', 'after', ...own].includes(name)) throw new Error(`${a}: add-view takes no such flag; ${ADD_VIEW_USAGE}`)
|
|
233
273
|
const v = args[i + 1]
|
|
234
274
|
if (v === undefined || v.startsWith('--')) throw new Error(`${a} needs its value; ${ADD_VIEW_USAGE}`)
|
|
235
275
|
i++
|
|
@@ -242,18 +282,23 @@ export async function addViewArgs(args: readonly string[], own: readonly string[
|
|
|
242
282
|
let files = rest
|
|
243
283
|
if (label === undefined && rest[0] !== undefined && !MEDIA_FILE.test(rest[0])) [label, ...files] = rest
|
|
244
284
|
if (label === undefined && gallery?.[0] !== undefined && !MEDIA_FILE.test(gallery[0]) && !gallery[0].includes('=')) label = gallery.shift()
|
|
245
|
-
const
|
|
285
|
+
const space = one.splat ?? one.mesh
|
|
286
|
+
const given = [files.length > 0 ? 'files' : '', one.image && space === undefined ? '--image' : '', one.splat ? '--splat' : '', one.mesh ? '--mesh' : '', one.video ? '--video' : '', one.audio ? '--audio' : '', one.pano ? '--pano' : '', one.before || one.after ? '--before --after' : '', gallery ? '--gallery' : ''].filter((x) => x !== '')
|
|
246
287
|
if (given.length !== 1) throw new Error(`${given.length === 0 ? 'no media' : `one media a view, not ${given.join(' and ')}`}; ${ADD_VIEW_USAGE}`)
|
|
247
288
|
if (!label?.trim()) throw new Error(`the view needs its label: sk thread ${['add-view', id, '"<label>"', ...args.filter((a) => a !== id).map(quoted)].join(' ')}`)
|
|
248
289
|
if ((one.before === undefined) !== (one.after === undefined)) throw new Error(`--before and --after go together; ${ADD_VIEW_USAGE}`)
|
|
249
290
|
if (gallery?.length === 0) throw new Error(`--gallery needs its images; ${ADD_VIEW_USAGE}`)
|
|
250
|
-
const view: ViewInput =
|
|
291
|
+
const view: ViewInput = space !== undefined
|
|
292
|
+
? { label, ...(one.splat ? { splat: one.splat } : { mesh: space }), ...(one.image ? { image: one.image } : {}) }
|
|
293
|
+
: one.image
|
|
251
294
|
? { label, image: one.image }
|
|
252
295
|
: one.video
|
|
253
296
|
? { label, video: one.video }
|
|
254
297
|
: one.audio
|
|
255
298
|
? { label, audio: one.audio }
|
|
256
|
-
: one.
|
|
299
|
+
: one.pano
|
|
300
|
+
? { label, pano: one.pano }
|
|
301
|
+
: one.before && one.after
|
|
257
302
|
? { label, before: one.before, after: one.after }
|
|
258
303
|
: gallery
|
|
259
304
|
? { label, gallery: gallery.map(tileOf) }
|
|
@@ -291,15 +336,22 @@ function flagsOf(args: readonly string[], values: readonly string[], repeat: rea
|
|
|
291
336
|
|
|
292
337
|
const ADD_FLAGS = `flags:
|
|
293
338
|
--title "<title>" one short line: what he looks at (a lone "<title>" after the address is the same)
|
|
294
|
-
--what "<what>" what
|
|
339
|
+
--what "<what>" what he sees now, one or two short lines: never the mechanics (why no before, an internal rename, how a count is computed)
|
|
295
340
|
--post "<line>" the public line for a post of it, what a user gets (the repo's guard reads it)
|
|
296
341
|
--changelog "<category>: <line>" its change in the release being filled: on his approval it lands in .shipkit/releases/next.md with the version's after picture (the repo's guard reads it)
|
|
297
342
|
--rating <safe|mild|explicit> with --changelog: what its media shows at full size, the rating its picture lands with; unset, unrated (reads explicit: no SFW venue shows it)
|
|
298
343
|
--verdict words with no media wait for the owner's verdict like a version (a version asks it always)
|
|
344
|
+
--md <file.md | -> a markdown document as the subject (a table, a list, numbers; light html: <sub> <kbd> <mark>, <span class="green|amber|red|blue|dim">): words and tables go this way, never as a picture of text; the next version shows a text diff
|
|
345
|
+
--html <file.html | -> an html card as the subject, in a sandboxed frame (its own scripts and styles, no network but the hub's media), for when markdown is not enough
|
|
299
346
|
--image <a.png> the subject; a clip (webm, mp4) goes anywhere an image goes
|
|
300
347
|
--video <clip.mp4> a clip
|
|
301
348
|
--audio <sound.wav> a sound: a waveform and a player (wav, mp3, flac, ogg, opus, m4a)
|
|
349
|
+
--pano <360.png> an equirectangular panorama (2:1): he drags to look around, wheel or pinch to zoom
|
|
350
|
+
--splat <a.ply | a.spz> a Gaussian splat he orbits and flies through, in the lightbox only; --image <poster.png> its still in the thread, else one shot now
|
|
351
|
+
--mesh <a.glb> a mesh he walks through, in the lightbox only; --image <poster.png> its still in the thread, else one shot now
|
|
302
352
|
--before <a.png> --after <b.png> a before and after: two images, two clips of one size, or two sounds
|
|
353
|
+
on an object of a kind: its states (a json file, or a git ref its kind reads, . the working tree); a kind whose page draws it gets a still of that page shot now, or --image <a.png> as that still; a state that names its "views" gets one still a view, --image <view>=<a.png> for one (repeat it)
|
|
354
|
+
--live [<label>] <url> a running page framed in the thread (repeat it), its shot taken now: what an advisor sees, and what shows while it loads or when it stops answering; a loopback, tailnet or https url, never the hub's own
|
|
303
355
|
--label "<label>" the first view's label
|
|
304
356
|
--view "<label>" <a.png> [<b.png>] another view of the same subject (repeat it); --note "<text>" right after it: a line on that view
|
|
305
357
|
--choice the older form of a question: posts sk thread ask with each --view an option, and prints that form
|
|
@@ -339,9 +391,9 @@ async function helpWithUnit(context: Ctx, usage: string, kinds: boolean): Promis
|
|
|
339
391
|
return 0
|
|
340
392
|
}
|
|
341
393
|
|
|
342
|
-
/** --trailer and its flags as a
|
|
394
|
+
/** --trailer and its flags as a version: its cut, pinned renders and shots, the image it keeps (a still cut into a temp
|
|
343
395
|
* folder `drop` removes); null without --trailer, which then refuses its own flags */
|
|
344
|
-
export async function trailerOfFlags(o: Record<string, string>, others: boolean): Promise<{
|
|
396
|
+
export async function trailerOfFlags(o: Record<string, string>, others: boolean): Promise<{ item: import('../review/model.ts').ItemTrailer; image: string; drop: () => void } | null> {
|
|
345
397
|
if (o.trailer === undefined) {
|
|
346
398
|
for (const k of ['version', 'shots']) if (o[k] !== undefined) throw new Error(`--${k}: only with --trailer <cut.trailer>`)
|
|
347
399
|
return null
|
|
@@ -352,13 +404,13 @@ export async function trailerOfFlags(o: Record<string, string>, others: boolean)
|
|
|
352
404
|
const { tmpdir } = await import('node:os')
|
|
353
405
|
const { join } = await import('node:path')
|
|
354
406
|
const { findRepoRoot } = await import('../ts/config.ts')
|
|
355
|
-
const {
|
|
356
|
-
const tmp = mkdtempSync(join(tmpdir(), 'trailer-
|
|
407
|
+
const { trailerItemOf } = await import('../review/trailer-item.ts')
|
|
408
|
+
const tmp = mkdtempSync(join(tmpdir(), 'trailer-version-'))
|
|
357
409
|
const drop = (): void => rmSync(tmp, { recursive: true, force: true })
|
|
358
410
|
try {
|
|
359
411
|
const shots = o.shots?.split(',').map((s) => s.trim()).filter((s) => s !== '')
|
|
360
412
|
const input = { file: o.trailer, ...(o.version ? { version: o.version } : {}), ...(o.before ? { before: o.before } : {}), ...(shots ? { shots } : {}) }
|
|
361
|
-
const r = await
|
|
413
|
+
const r = await trailerItemOf(findRepoRoot(process.cwd()), process.cwd(), input, join(tmp, 'still.png'))
|
|
362
414
|
return { ...r, drop }
|
|
363
415
|
} catch (e) {
|
|
364
416
|
drop()
|
|
@@ -366,14 +418,40 @@ export async function trailerOfFlags(o: Record<string, string>, others: boolean)
|
|
|
366
418
|
}
|
|
367
419
|
}
|
|
368
420
|
|
|
369
|
-
/** --draft as a
|
|
421
|
+
/** --draft as a version: the post draft its slug names, pinned by the hashes of its head and of each message; null without
|
|
370
422
|
* --draft. A draft that does not load clean is refused in the loader's words */
|
|
371
|
-
export async function draftOfFlags(o: Record<string, string>, others: boolean, cwd: string = process.cwd()): Promise<import('../review/model.ts').
|
|
423
|
+
export async function draftOfFlags(o: Record<string, string>, others: boolean, cwd: string = process.cwd()): Promise<import('../review/model.ts').ItemDraft | null> {
|
|
372
424
|
if (o.draft === undefined) return null
|
|
373
425
|
const clash = ['image', 'video', 'audio', 'before', 'after', 'label', 'live', 'trailer'].filter((k) => o[k] !== undefined)
|
|
374
426
|
if (clash.length > 0 || others) throw new Error(`--draft: the version shows the draft itself; no ${clash.length > 0 ? clash.map((k) => `--${k}`).join(', ') : '--view, --gallery or --choice'} beside it`)
|
|
375
|
-
const [{ findRepoRoot }, { openDesk }, {
|
|
376
|
-
return
|
|
427
|
+
const [{ findRepoRoot }, { openDesk }, { draftItemOf }] = await Promise.all([import('../ts/config.ts'), import('../social/open.ts'), import('../review/draft-item.ts')])
|
|
428
|
+
return draftItemOf((await openDesk(findRepoRoot(cwd))).desk, o.draft, cwd).item
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/** --md <file | -> or --html <file | ->: the version's subject is that document, its text read now (`-` stdin); null
|
|
432
|
+
* without either. Words, numbers and tables go this way, never as a picture of text */
|
|
433
|
+
export async function docOfFlags(o: Record<string, string>, beside: { trailer: unknown; draft: unknown; states: unknown; choice: boolean; wip: boolean }, stdin: () => Promise<string> = () => new Response(Bun.stdin.stream()).text()): Promise<import('../review/model.ts').ItemDoc | null> {
|
|
434
|
+
if (o.md !== undefined && o.html !== undefined) throw new Error('--md and --html: one document a version; markdown first, --html when markdown is not enough')
|
|
435
|
+
const kind = o.md !== undefined ? 'md' : o.html !== undefined ? 'html' : null
|
|
436
|
+
if (kind === null) return null
|
|
437
|
+
const other = beside.trailer ? '--trailer' : beside.draft ? '--draft' : beside.states ? "an object's --before and --after states" : beside.choice ? '--choice' : beside.wip ? '--wip --live' : null
|
|
438
|
+
if (other !== null) throw new Error(`--${kind}: a document is the version's subject, never with ${other}`)
|
|
439
|
+
const path = o[kind]!
|
|
440
|
+
const ext = kind === 'md' ? /\.(md|markdown|txt)$/i : /\.html?$/i
|
|
441
|
+
if (path !== '-' && !ext.test(path)) throw new Error(`--${kind} ${path}: ${kind === 'md' ? 'a .md file' : 'an .html file'}, or - to read it from stdin`)
|
|
442
|
+
let text: string
|
|
443
|
+
if (path === '-') text = await stdin()
|
|
444
|
+
else {
|
|
445
|
+
const { existsSync, readFileSync } = await import('node:fs')
|
|
446
|
+
if (!existsSync(path)) throw new Error(`--${kind} ${path}: no such file`)
|
|
447
|
+
text = readFileSync(path, 'utf8')
|
|
448
|
+
}
|
|
449
|
+
if (text.includes('\0')) throw new Error(`--${kind} ${path}: not text`)
|
|
450
|
+
const { docProblem } = await import('../review/model.ts')
|
|
451
|
+
const doc = { kind, text } as const
|
|
452
|
+
const why = docProblem(doc)
|
|
453
|
+
if (why !== null) throw new Error(why)
|
|
454
|
+
return doc
|
|
377
455
|
}
|
|
378
456
|
|
|
379
457
|
export class ReviewAddCommand extends Command {
|
|
@@ -387,13 +465,17 @@ export class ReviewAddCommand extends Command {
|
|
|
387
465
|
details: `${DETAILS}\n\nsk thread post [<address> | <id>] <flags>. The address is the version's own (screen:<screen>, asset:<asset>, page:<page>, a kind of the repo's unit); --trailer and --draft name theirs, so it may be left out. An id names its thread. With no media, --title and --what are words: they start the thread, or are a reply in it. sk thread add is its older name.\n\n${ADD_FLAGS}`,
|
|
388
466
|
examples: [
|
|
389
467
|
['one image', 'sk thread post screen:menu --title "the new menu" --what "the menu, bigger" --image shots/menu.png'],
|
|
468
|
+
['a report with a table: markdown, never a picture of text', 'sk thread post page:hub/speed --title "the hub, before and after" --what "every click under 50 ms" --md report.md'],
|
|
390
469
|
['a before and after', 'sk thread post asset:lamps --title "lamps lit" --what "..." --before a.png --after b.png'],
|
|
391
470
|
['the next version: the same address, the tool links it', 'sk thread post asset:lamps --title "lamps lit, warmer" --what "..." --image c.png'],
|
|
392
471
|
['a pick among three voices, yours on the second', 'sk thread post asset:narrator --choice --pick 2 --title "the narrator" --what "..." --view "voice 0" a.flac --note "low, breathy" --view "voice 1" b.flac --view "voice 2" c.flac'],
|
|
472
|
+
['a 360° panorama he looks around in', 'sk thread post screen:hall --title "the hall in 360" --what "..." --pano hall-360.png'],
|
|
473
|
+
['a Gaussian splat he orbits, its poster shot now', 'sk thread post asset:hall --title "the hall as a splat" --what "..." --splat hall.ply'],
|
|
393
474
|
['icons he rates one by one', 'sk thread post asset:buff-icons --title "buff icons" --what "..." --gallery "icons" vitality=a.png haste=b.png greed=c.png'],
|
|
394
475
|
['a trailer cut against its last kept version', 'sk thread post --trailer trailer/demo/main.trailer --version v4 --before v3 --title "the drop, recut" --what "..."'],
|
|
395
476
|
['a post draft, each place answered on its own', 'sk thread post --draft 20261119-174922-trailer --title "the trailer post" --what "..."'],
|
|
396
|
-
['
|
|
477
|
+
['a running page, framed in the thread', 'sk thread post page:settings --title "the settings page" --what "..." --live "settings" http://localhost:5173/settings'],
|
|
478
|
+
['words, no picture', 'sk thread post messages:tui/u1 --title "the hook line" --what "the hook line, shorter: it names the gain first"'],
|
|
397
479
|
],
|
|
398
480
|
})
|
|
399
481
|
args = Option.Proxy()
|
|
@@ -405,16 +487,22 @@ export class ReviewAddCommand extends Command {
|
|
|
405
487
|
return run(this.context, async (h) => {
|
|
406
488
|
const { addItem, postUpdate, agentName } = await import('../review/store.ts')
|
|
407
489
|
if (this.path[1] === 'add') h.err('sk thread add is now sk thread post [<address>]: the same flags')
|
|
408
|
-
// `--wip "<what is still wrong>"`: a
|
|
490
|
+
// `--wip "<what is still wrong>"`: a version sent in work, its first update still broken; a bare --wip goes with --live
|
|
409
491
|
const w = this.args.indexOf('--wip')
|
|
410
492
|
const wipLine = w >= 0 && this.args[w + 1] !== undefined && !this.args[w + 1]!.startsWith('--') ? this.args[w + 1] : undefined
|
|
411
|
-
const {
|
|
493
|
+
const { takeLives } = await import('../review/live-post.ts')
|
|
494
|
+
const { lives, rest: unlived } = takeLives(wipLine === undefined ? this.args : [...this.args.slice(0, w + 1), ...this.args.slice(w + 2)])
|
|
495
|
+
const { views, rest } = takeViews(unlived)
|
|
412
496
|
// the repo's own flags: the subject kind's (--where), and the unit's for any kind (--mark), each repeatable
|
|
413
497
|
const kindName = rest[rest.indexOf('--subject') + 1]
|
|
414
498
|
const kind = rest.includes('--subject') && kindName ? h.unit?.kinds?.[kindName] : undefined
|
|
415
499
|
const own = [...Object.keys(kind?.flags ?? {}), ...Object.keys(h.unit?.flags ?? {})]
|
|
416
|
-
const f = flagsOf(rest, ['title', 'what', 'post', 'changelog', 'rating', '
|
|
500
|
+
const f = flagsOf(rest, ['title', 'what', 'post', 'changelog', 'rating', 'video', 'audio', 'pano', 'splat', 'mesh', 'before', 'after', 'label', 'topic', 'subject', 'commit', 'lane', 'supersedes', 'keeps', 'why', 'live', 'trailer', 'version', 'shots', 'pick', 'draft', 'on', 'md', 'html'], ['image', 'answers', 'about', ...own], ['new', 'wip', 'choice', 'keep', 'verdict'])
|
|
417
501
|
const o = f.one
|
|
502
|
+
// --image repeats only as the stills of a kind's page, one a view (<view>=<a.png>)
|
|
503
|
+
const images = f.many.image ?? []
|
|
504
|
+
if (images.length === 1) o.image = images[0]!
|
|
505
|
+
if (images.length > 1 && f.on.has('choice')) throw new Error('--choice: one --image, the first option; the others are --view')
|
|
418
506
|
// the first word names the thread: an address (the version's own), or an id (its thread)
|
|
419
507
|
const { addressOrThrow, canonicalAddress, ID_RE } = await import('../review/model.ts')
|
|
420
508
|
const first = f.positionals[0]
|
|
@@ -444,9 +532,17 @@ export class ReviewAddCommand extends Command {
|
|
|
444
532
|
if (lone !== undefined && more.length === 0 && o.title === undefined && !MEDIA_FILE.test(lone)) o.title = lone
|
|
445
533
|
else if (lone !== undefined) throw new Error(`unexpected ${f.positionals.map(quoted).join(' ')}: the title is --title "<title>", the subject --image <a.png> (sk thread post --help)`)
|
|
446
534
|
if (f.on.has('choice') && f.on.has('verdict')) throw new Error("--choice --verdict: a choice is a question, its pick is the owner's answer; post it without --verdict")
|
|
535
|
+
if (lives.length > 0 && (f.on.has('choice') || o.trailer !== undefined || o.draft !== undefined || o.live !== undefined))
|
|
536
|
+
throw new Error(`--live <url>: a view of a running page; never with ${f.on.has('choice') ? '--choice (ask, then post)' : o.trailer !== undefined ? '--trailer' : o.draft !== undefined ? '--draft' : '--wip --live <name>'}`)
|
|
447
537
|
if (f.on.has('choice')) return choiceAsQuestion(h, o, views, f.many)
|
|
448
538
|
const states = await statesOfFlags(h, o, views.length > 0)
|
|
539
|
+
if (images.length > 1 && !states) throw new Error('--image: one picture a version; it repeats as <view>=<a.png> only beside --after on a kind whose page draws views')
|
|
540
|
+
// a version a kind's page draws shows its stills: the picture given wins over a shot of the page
|
|
541
|
+
const still = states ? await stillOfFlags(h, o, states, images) : null
|
|
449
542
|
const trailer = await trailerOfFlags(o, views.length > 0 || f.on.has('wip') || f.on.has('choice'))
|
|
543
|
+
// a draft's own address with no media draws the draft itself, as --draft does: never a version of words
|
|
544
|
+
const ownDraft = o.on !== undefined ? /^draft:([^/]+)$/.exec(o.on) : null
|
|
545
|
+
if (ownDraft && o.draft === undefined && views.length === 0 && [o.image, o.video, o.audio, o.pano, o.before, o.after, o.live, o.trailer].every((v) => v === undefined)) o.draft = ownDraft[1]!
|
|
450
546
|
const draft = await draftOfFlags(o, views.length > 0 || f.on.has('choice'))
|
|
451
547
|
const repoFlags = Object.fromEntries(own.flatMap((k) => (f.many[k] ? [[k, f.many[k]]] : [])))
|
|
452
548
|
const parsed = kind?.parse ? kind.parse(Object.fromEntries(Object.keys(kind.flags ?? {}).map((k) => [k, f.many[k] ?? []]))) : null
|
|
@@ -456,23 +552,23 @@ export class ReviewAddCommand extends Command {
|
|
|
456
552
|
let wipViews: ViewInput[] = []
|
|
457
553
|
if (o.live !== undefined) {
|
|
458
554
|
if (!h.unit?.live) throw new Error("--live: the repo's review unit declares no live shots (live: { frames })")
|
|
459
|
-
if (o.image || o.video || o.audio || o.before || o.after || views.length > 0) throw new Error('--wip: the version shows the live shot alone, no --image, --video, pair or --view beside it')
|
|
555
|
+
if (o.image || o.video || o.audio || o.pano || o.splat || o.mesh || o.before || o.after || views.length > 0) throw new Error('--wip: the version shows the live shot alone, no --image, --video, pair or --view beside it')
|
|
460
556
|
const fr = h.unit.live.frames(o.live)
|
|
461
557
|
wipViews = [{ label: '', image: fr.image }, ...(fr.history.length > 0 ? [{ label: 'history', gallery: fr.history }] : [])]
|
|
462
558
|
}
|
|
463
559
|
const answers = await Promise.all((f.many.answers ?? []).map((a) => idOf(h.dir, a)))
|
|
464
560
|
if (o.post !== undefined) {
|
|
465
|
-
// a public line: the repo's guard reads it before the
|
|
561
|
+
// a public line: the repo's guard reads it before the version holds it
|
|
466
562
|
const { dirname } = await import('node:path')
|
|
467
563
|
const { loadSocialUnit } = await import('../social/unit.ts')
|
|
468
564
|
const unit = await loadSocialUnit(dirname(dirname(h.dir)))
|
|
469
565
|
const problems = unit?.guard ? [...unit.guard({ title: '', alt: '', texts: [o.post], files: [] })] : []
|
|
470
566
|
if (problems.length > 0) throw new Error(`--post: the repo's guard refuses it: ${problems.join('; ')}`)
|
|
471
567
|
}
|
|
472
|
-
let changelog: import('../review/model.ts').
|
|
568
|
+
let changelog: import('../review/model.ts').ItemChangelog | undefined
|
|
473
569
|
if (o.rating !== undefined && o.changelog === undefined) throw new Error('--rating rates the picture its --changelog line lands with: give --changelog too')
|
|
474
570
|
if (o.changelog !== undefined) {
|
|
475
|
-
// its category and line are public words: the repo's guard reads them before the
|
|
571
|
+
// its category and line are public words: the repo's guard reads them before the item holds them
|
|
476
572
|
const { dirname } = await import('node:path')
|
|
477
573
|
const { changelogOfFlag } = await import('../review/model.ts')
|
|
478
574
|
const { publicProblems } = await import('../social/unit.ts')
|
|
@@ -489,19 +585,24 @@ export class ReviewAddCommand extends Command {
|
|
|
489
585
|
if (problems.length > 0) throw new Error(`--changelog: the repo's guard refuses it: ${problems.join('; ')}`)
|
|
490
586
|
}
|
|
491
587
|
const topic = o.topic ?? parsed?.topic
|
|
588
|
+
const doc = await docOfFlags(o, { trailer, draft, states, choice: f.on.has('choice'), wip: o.live !== undefined })
|
|
492
589
|
let input: import('../review/store.ts').AddInput = {
|
|
493
590
|
title: o.title ?? '',
|
|
494
591
|
what: o.what ?? '',
|
|
495
592
|
...(o.post ? { post: o.post } : {}),
|
|
496
593
|
...(changelog ? { changelog } : {}),
|
|
497
|
-
...(parsed ? { subject: parsed.subject } : o.subject ? { subject: { kind: o.subject } } : trailer ? { subject: { kind: 'trailer' } } : draft ? { subject: { kind: 'draft', slug: draft.slug } } : {}),
|
|
594
|
+
...(parsed ? { subject: parsed.subject } : o.subject ? { subject: { kind: o.subject } } : trailer ? { subject: { kind: 'trailer' } } : draft ? { subject: { kind: 'draft', slug: draft.slug } } : doc ? { subject: { kind: 'doc' } } : {}),
|
|
595
|
+
...(doc ? { doc } : {}),
|
|
498
596
|
...(topic ? { topic } : {}),
|
|
499
|
-
...(trailer ? { image: trailer.image, trailer: trailer.
|
|
597
|
+
...(trailer ? { image: trailer.image, trailer: trailer.item } : {}),
|
|
500
598
|
...(draft ? { draft } : {}),
|
|
501
599
|
...(states ? { states } : {}),
|
|
502
600
|
...(o.image ? { image: o.image } : {}),
|
|
503
601
|
...(o.video ? { video: o.video } : {}),
|
|
504
602
|
...(o.audio ? { audio: o.audio } : {}),
|
|
603
|
+
...(o.pano ? { pano: o.pano } : {}),
|
|
604
|
+
...(o.splat ? { splat: o.splat } : {}),
|
|
605
|
+
...(o.mesh ? { mesh: o.mesh } : {}),
|
|
505
606
|
...(o.before && !trailer ? { before: o.before } : {}),
|
|
506
607
|
...(o.after ? { after: o.after } : {}),
|
|
507
608
|
...(o.label ? { label: o.label } : {}),
|
|
@@ -519,18 +620,31 @@ export class ReviewAddCommand extends Command {
|
|
|
519
620
|
...(o.pick !== undefined ? { agentPick: o.pick } : {}),
|
|
520
621
|
...(o.live !== undefined ? { image: wipViews[0]?.image ?? '', views: wipViews.slice(1), wip: { live: o.live } } : { views }),
|
|
521
622
|
}
|
|
522
|
-
const media = [o.image, o.video, o.audio, o.before, o.after, o.live, o.trailer, o.draft].some((v) => v !== undefined) || views.length > 0 || states !== null
|
|
623
|
+
const media = [o.image, o.video, o.audio, o.pano, o.splat, o.mesh, o.before, o.after, o.live, o.trailer, o.draft].some((v) => v !== undefined) || views.length > 0 || lives.length > 0 || states !== null || doc !== null
|
|
523
624
|
if (!media && input.on !== undefined) return postWords(h, input.on, input.title, input.what, input.lane, f.on.has('verdict'))
|
|
524
625
|
// a version asks the owner's verdict always: the field says it, the flag changes nothing else
|
|
525
626
|
if (f.on.has('verdict')) input = { ...input, asksVerdict: true }
|
|
627
|
+
// each live page asked and shot now: its shot is the view everyone but the owner's hub sees
|
|
628
|
+
const shots = lives.length > 0 ? await (await import('../review/live-post.ts')).liveViews(lives) : null
|
|
629
|
+
if (shots) input = { ...input, views: [...(input.views ?? []), ...shots.views] }
|
|
630
|
+
// a splat or a mesh with no --image: its poster shot now, the viewer at rest
|
|
631
|
+
const poster = await withPoster({ label: '', ...(input.splat ? { splat: input.splat } : {}), ...(input.mesh ? { mesh: input.mesh } : {}), ...(input.image ? { image: input.image } : {}) })
|
|
632
|
+
if (poster.view.image !== undefined) input = { ...input, image: poster.view.image }
|
|
526
633
|
if (h.unit?.add) input = await h.unit.add(input, repoFlags)
|
|
527
634
|
const { ownAddressOf } = await import('../review/model.ts')
|
|
528
635
|
const address = ownAddressOf({ subject: input.subject ?? { kind: 'shot' }, ...(input.on ? { on: input.on } : {}), ...(input.trailer ? { trailer: input.trailer } : {}), origin: { by: 'agent' }, views: [] } as unknown as import('../review/model.ts').Item, h.say.spec)
|
|
529
636
|
if (address === null && input.supersedes === undefined && (input.answers ?? []).length === 0) {
|
|
530
637
|
trailer?.drop()
|
|
638
|
+
shots?.drop()
|
|
639
|
+
poster.drop()
|
|
531
640
|
throw new Error(NO_ADDRESS)
|
|
532
641
|
}
|
|
533
|
-
const item = await addItem(h.dir, input).finally(() =>
|
|
642
|
+
const item = await addItem(h.dir, input).finally(() => {
|
|
643
|
+
trailer?.drop()
|
|
644
|
+
shots?.drop()
|
|
645
|
+
poster.drop()
|
|
646
|
+
})
|
|
647
|
+
if (still) await keepStill(h, item, still)
|
|
534
648
|
h.out(item.id)
|
|
535
649
|
// on stderr: a script reads the id alone on stdout
|
|
536
650
|
await saidIntoThread(h, item, o.supersedes !== undefined)
|
|
@@ -542,7 +656,7 @@ export class ReviewAddCommand extends Command {
|
|
|
542
656
|
// on stderr: a script reads the id alone on stdout
|
|
543
657
|
for (const line of await (await import('../review/previews.ts')).playCopies(h.dir, item)) h.err(line)
|
|
544
658
|
if (item.trailer) h.out(`trailer version: ${item.trailer.trailer}/${item.trailer.after.cut}${item.trailer.before ? ` against ${item.trailer.before.cut}` : ''}${item.trailer.shots.length > 0 ? `, shots ${item.trailer.shots.join(', ')}` : ''}`)
|
|
545
|
-
// a cut shown
|
|
659
|
+
// a cut shown in a thread is a version from then on: the next edit of its file makes the one after it
|
|
546
660
|
if (item.trailer && o.trailer !== undefined && o.version === undefined) {
|
|
547
661
|
try {
|
|
548
662
|
const [b, { keepShown, thumbnailKept, versionVideo }, { findRepoRoot }] = await Promise.all([import('../trailer/build.ts'), import('../trailer/passage.ts'), import('../ts/config.ts')])
|
|
@@ -566,7 +680,7 @@ export class ReviewAddCommand extends Command {
|
|
|
566
680
|
}
|
|
567
681
|
}
|
|
568
682
|
if (item.draft) h.out(`draft version: ${item.draft.slug}, ${item.draft.posts.length} place${item.draft.posts.length > 1 ? 's' : ''}: ${item.draft.posts.map((p) => p.name).join(', ')}`)
|
|
569
|
-
if (item.origin.by === 'agent' && !item.origin.lane) h.err(
|
|
683
|
+
if (item.origin.by === 'agent' && !item.origin.lane) h.err(`posted ${item.id} with no lane: on the next post pass --lane <id> (or SK_AGENT), so the hub colours it; never post this one again`)
|
|
570
684
|
if (item.choice && item.agentPick === undefined) h.err(`a choice with no pick of yours: every question carries one, sk thread pick ${item.id} <view> (or --pick on post)`)
|
|
571
685
|
const { unheardLine } = await import('../review/model.ts')
|
|
572
686
|
const { liveWatchers } = await import('../review/watchers.ts')
|
|
@@ -591,7 +705,7 @@ async function statesOfFlags(h: Here, o: Record<string, string>, views: boolean)
|
|
|
591
705
|
const kind = (await import('../review/house-kind-defs.ts')).serverKindOf(root, h.unit, word)
|
|
592
706
|
const json = (v: string): boolean => /\.json$/i.test(v)
|
|
593
707
|
if (!kind?.read && !json(o.after)) return null
|
|
594
|
-
if (views || o.
|
|
708
|
+
if (views || o.video || o.audio || o.pano || o.splat || o.mesh) throw new Error(`${o.on}: a version of an object shows its two states and their still (--image) alone, no other picture beside them`)
|
|
595
709
|
const { existsSync, readFileSync } = await import('node:fs')
|
|
596
710
|
const side = async (flag: string, v: string): Promise<import('../review/model.ts').StoredState> => {
|
|
597
711
|
if (json(v)) {
|
|
@@ -602,9 +716,9 @@ async function statesOfFlags(h: Here, o: Record<string, string>, views: boolean)
|
|
|
602
716
|
if (!kind?.read) throw new Error(`--${flag} ${v}: a json file, or a git ref the kind reads; the kind ${word} declares no read`)
|
|
603
717
|
let at: string | undefined
|
|
604
718
|
if (v !== '.') {
|
|
605
|
-
const p =
|
|
606
|
-
at = p.
|
|
607
|
-
if (p.
|
|
719
|
+
const p = realGit.runSync(root, ['rev-parse', '--verify', '--quiet', `${v}^{commit}`])
|
|
720
|
+
at = p.out.trim()
|
|
721
|
+
if (p.code !== 0 || at === '') throw new Error(`--${flag} ${v}: no commit of this repo by that name (a json file, a git ref, or . for the working tree)`)
|
|
608
722
|
}
|
|
609
723
|
const st = await kind.read(key, at)
|
|
610
724
|
if (st === null) throw new Error(`--${flag} ${v}: the kind ${word} reads no ${key} there`)
|
|
@@ -617,6 +731,63 @@ async function statesOfFlags(h: Here, o: Record<string, string>, views: boolean)
|
|
|
617
731
|
return { ...(before ? { before } : {}), after }
|
|
618
732
|
}
|
|
619
733
|
|
|
734
|
+
/** where the stills of a version of an object come from (review/kind-still.ts): `--image`, taken out of the flags so
|
|
735
|
+
* no view reads it, else a shot of the kind's page once the version exists, one a view its state names; null when its
|
|
736
|
+
* kind draws no page */
|
|
737
|
+
async function stillOfFlags(h: Here, o: Record<string, string>, states: { before?: import('../review/model.ts').StoredState; after: import('../review/model.ts').StoredState }, images: readonly string[]) {
|
|
738
|
+
const word = o.on!.slice(0, o.on!.indexOf(':'))
|
|
739
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
740
|
+
const kind = (await import('../review/house-kind-defs.ts')).serverKindOf(findRepoRoot(process.cwd()), h.unit, word)
|
|
741
|
+
const plan = (await import('../review/kind-still.ts')).stillPlan(kind, states, images)
|
|
742
|
+
delete o.image
|
|
743
|
+
return plan ? { plan, kind } : null
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/** the version's stills kept beside its states: each picture given, else a shot of the kind's page through the hub
|
|
747
|
+
* (`mode=thumb`, the view's `view`), as a live view's shot is taken. A state that names views gets one gallery tile a
|
|
748
|
+
* view, else the one still. A still that cannot be shot never holds the version back: the thread then shows a
|
|
749
|
+
* placeholder that opens the page, and the line says why */
|
|
750
|
+
async function keepStill(h: Here, item: import('../review/model.ts').Item, still: NonNullable<Awaited<ReturnType<typeof stillOfFlags>>>): Promise<void> {
|
|
751
|
+
const { setStill, setKindStills } = await import('../review/store.ts')
|
|
752
|
+
const { kindFrames } = await import('../review/kind-still.ts')
|
|
753
|
+
const lone = still.plan.length === 1 && still.plan[0]!.view === null ? still.plan[0]! : null
|
|
754
|
+
if (lone?.image !== undefined) return void (await setStill(h.dir, item.id, { image: lone.image }))
|
|
755
|
+
const { pasteHosts } = await import('../review/paste.ts')
|
|
756
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
757
|
+
const hub = (await pasteHosts(findRepoRoot(process.cwd()))).open.replace(/\/$/, '')
|
|
758
|
+
const drops: (() => void)[] = []
|
|
759
|
+
try {
|
|
760
|
+
const shotOf = async (view: string | undefined) => {
|
|
761
|
+
const plan = kindFrames(still.kind, item, (side) => `${hub}/api/review/${item.id}/state?side=${side}`, { view, mode: 'thumb' })
|
|
762
|
+
if (plan === null) return null
|
|
763
|
+
const shots = await (await import('../review/live-post.ts')).kindStill(hub, plan.page, plan.frames)
|
|
764
|
+
drops.push(shots.drop)
|
|
765
|
+
return shots.files
|
|
766
|
+
}
|
|
767
|
+
if (lone) {
|
|
768
|
+
const files = await shotOf(undefined)
|
|
769
|
+
if (files) await setStill(h.dir, item.id, files)
|
|
770
|
+
return
|
|
771
|
+
}
|
|
772
|
+
const tiles: { view: string; label: string; file: string; before?: string }[] = []
|
|
773
|
+
for (const s of still.plan) {
|
|
774
|
+
const v = s.view!
|
|
775
|
+
if (s.image !== undefined) {
|
|
776
|
+
tiles.push({ view: v.id, label: v.label, file: s.image })
|
|
777
|
+
continue
|
|
778
|
+
}
|
|
779
|
+
const files = await shotOf(v.id)
|
|
780
|
+
if (files === null) return
|
|
781
|
+
tiles.push({ view: v.id, label: v.label, ...('image' in files ? { file: files.image } : { file: files.after, before: files.before }) })
|
|
782
|
+
}
|
|
783
|
+
await setKindStills(h.dir, item.id, tiles)
|
|
784
|
+
} catch (e) {
|
|
785
|
+
h.err(`WARN the version is sent with no still: ${(e as Error).message}. The thread shows a placeholder that opens the page; --image <a.png> gives one${lone ? '' : ', --image <view>=<a.png> one a view'}`)
|
|
786
|
+
} finally {
|
|
787
|
+
for (const d of drops) d()
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
|
|
620
791
|
/** `post --choice`, the older form of a question with media options: each view an option (its note after its label),
|
|
621
792
|
* the title and what its words, posted as the question into the address's thread; it prints the `ask` form */
|
|
622
793
|
async function choiceAsQuestion(h: Here, o: Record<string, string>, views: readonly ViewInput[], many: Record<string, string[]>): Promise<number> {
|
|
@@ -659,16 +830,18 @@ async function saidIntoThread(h: Here, item: import('../review/model.ts').Item,
|
|
|
659
830
|
if (open.length > 0) h.err(`his notes in the thread stay open: ${open.map((x) => `${x.item.id} "${x.item.title}"`).join('; ')}. Close one once done: sk thread fixed <id> "<what was done>"; or name it on the version: --answers <id>`)
|
|
660
831
|
}
|
|
661
832
|
|
|
662
|
-
/** `post <address>` with no media: words that start the address's thread, or a reply in the thread it has
|
|
833
|
+
/** `post <address>` with no media: words that start the address's thread, or a reply in the thread it has. The thread
|
|
834
|
+
* is the one its own address names, as a version's: a part address (`<kind>:<key>/<part>`) is its own thread, never
|
|
835
|
+
* its parent's */
|
|
663
836
|
async function postWords(h: Here, address: string, title: string, what: string, lane: string | undefined, verdict = false): Promise<number> {
|
|
664
837
|
const { agentName, openThread, readAll, specOf } = await import('../review/store.ts')
|
|
665
|
-
const { threadOfAddress } = await import('../review/threads.ts')
|
|
838
|
+
const { threadIdOf, threadOfAddress } = await import('../review/threads.ts')
|
|
666
839
|
if (!title.trim() && !what.trim()) throw new Error('--title "<words>" (and --what): with no media, a post is words')
|
|
667
|
-
const t = threadOfAddress(address, readAll(h.dir).items, specOf(h.dir)
|
|
840
|
+
const t = threadOfAddress(address, readAll(h.dir).items, specOf(h.dir))
|
|
668
841
|
if (t) {
|
|
669
842
|
const m = await wordsIn(h.dir, t.head.item.id, lane?.trim() || agentName(), [title.trim(), what.trim()].filter(Boolean).join('\n'), verdict)
|
|
670
843
|
h.out(`${t.head.item.id}: ${m.id}`)
|
|
671
|
-
h.err(`a word in the thread of ${address}${verdict ? ", waiting for the owner's verdict" : ''}`)
|
|
844
|
+
h.err(`a word in the thread ${threadIdOf(t)} of ${address}${verdict ? ", waiting for the owner's verdict" : ''}`)
|
|
672
845
|
return 0
|
|
673
846
|
}
|
|
674
847
|
const x = await openThread(h.dir, address, { title: title.trim() || what.trim(), ...(what.trim() ? { what } : {}), ...(lane?.trim() ? { lane: lane.trim() } : {}), ...(verdict ? { asksVerdict: true as const } : {}) })
|
|
@@ -682,7 +855,7 @@ async function wordsIn(dir: string, id: string, who: string, text: string, verdi
|
|
|
682
855
|
const { addMessage, appendMessage, readItem } = await import('../review/store.ts')
|
|
683
856
|
if (!verdict) return addMessage(dir, id, who, text, image)
|
|
684
857
|
const { textOf } = await import('../review/model.ts')
|
|
685
|
-
if (!readItem(dir, id)) throw new Error(`no
|
|
858
|
+
if (!readItem(dir, id)) throw new Error(`no item ${id}`)
|
|
686
859
|
const t = textOf(text)
|
|
687
860
|
if ('error' in t) throw new Error(t.error)
|
|
688
861
|
return appendMessage(dir, id, { who, text: t.text, asksVerdict: true }, image !== undefined ? { image } : {})
|
|
@@ -701,6 +874,7 @@ export class ReviewAddViewCommand extends Command {
|
|
|
701
874
|
examples: [
|
|
702
875
|
['a view from above', 'sk thread add-view <id> "from above" top.png'],
|
|
703
876
|
['a before and after', 'sk thread add-view <id> --label "on a phone" --before a.png --after b.png'],
|
|
877
|
+
['a 360° panorama', 'sk thread add-view <id> --label "inside" --pano hall-360.png'],
|
|
704
878
|
],
|
|
705
879
|
})
|
|
706
880
|
args = Option.Proxy()
|
|
@@ -710,16 +884,20 @@ export class ReviewAddViewCommand extends Command {
|
|
|
710
884
|
return helpWithUnit(this.context, this.cli.usage(ReviewAddViewCommand, { detailed: true }), false)
|
|
711
885
|
}
|
|
712
886
|
return run(this.context, async (h) => {
|
|
713
|
-
const {
|
|
887
|
+
const { addViewAlso } = await import('../review/store.ts')
|
|
714
888
|
const keep = this.args.includes('--keep')
|
|
715
889
|
const a = await addViewArgs(this.args.filter((x) => x !== '--keep'), Object.keys(h.unit?.flags ?? {}))
|
|
716
|
-
const v = a.view
|
|
717
890
|
const id = await idOf(h.dir, a.id)
|
|
891
|
+
const posted = await withPoster(a.view)
|
|
892
|
+
const v = posted.view
|
|
718
893
|
const extra = h.unit?.addView ? await h.unit.addView(v, a.repoFlags) : {}
|
|
719
|
-
const item = await
|
|
894
|
+
const { item, added } = await addViewAlso(h.dir, id, v, { ...extra, ...(keep ? { keep: true } : {}) }).finally(posted.drop)
|
|
720
895
|
const { viewNo } = await import('../review/model.ts')
|
|
721
|
-
|
|
722
|
-
for (const
|
|
896
|
+
const { playCopies } = await import('../review/previews.ts')
|
|
897
|
+
for (const n of added) {
|
|
898
|
+
h.out(`${id}: view ${viewNo(n)} "${item.views[n]!.label}" added`)
|
|
899
|
+
for (const line of await playCopies(h.dir, item, n)) h.err(line)
|
|
900
|
+
}
|
|
723
901
|
return 0
|
|
724
902
|
})
|
|
725
903
|
}
|
|
@@ -729,7 +907,7 @@ export class ReviewLsCommand extends Command {
|
|
|
729
907
|
static override paths = [['review'], ['review', 'ls']]
|
|
730
908
|
static override usage = Command.Usage({
|
|
731
909
|
category: 'Review',
|
|
732
|
-
description: "the
|
|
910
|
+
description: "the active threads: status, thread id, title, address; `sk thread <verb>` runs a unit's verb",
|
|
733
911
|
details: `${DETAILS}\n\nsk thread [--all] lists; sk thread <verb> … runs a verb the repo's review unit declares (verbs: {...}).`,
|
|
734
912
|
examples: [['what is open', 'sk thread ls'], ['every thread', 'sk thread ls --all']],
|
|
735
913
|
})
|
|
@@ -770,10 +948,11 @@ export class ReviewLsCommand extends Command {
|
|
|
770
948
|
for (const b of all.broken) h.err(`review: FAIL ${b.id}: ${b.error}`)
|
|
771
949
|
const threads = orderedThreads(all.items).filter((t) => every || isActive(t))
|
|
772
950
|
if (threads.length === 0) h.out(every ? 'review: the store is empty' : 'review: nothing active (--all shows every thread)')
|
|
773
|
-
const { ownAddressesOf, threadTitle } = await import('../review/threads.ts')
|
|
951
|
+
const { ownAddressesOf, threadIdOf, threadTitle } = await import('../review/threads.ts')
|
|
952
|
+
// the thread's own id, never an item's: the items' ids are `sk thread show <thread>`'s
|
|
774
953
|
for (const t of threads) {
|
|
775
954
|
const at = ownAddressesOf(t)[0]
|
|
776
|
-
h.out(`${statusOf(t.head, all.items).padEnd(17)} ${t
|
|
955
|
+
h.out(`${statusOf(t.head, all.items).padEnd(17)} ${threadIdOf(t)} ${threadTitle(t)}${t.versions.length > 1 ? ` (v${t.versions.length})` : ''}${at ? ` ${at}` : ''}`)
|
|
777
956
|
}
|
|
778
957
|
return all.broken.length > 0 ? 1 : 0
|
|
779
958
|
},
|
|
@@ -796,7 +975,7 @@ export class ReviewShowCommand extends Command {
|
|
|
796
975
|
|
|
797
976
|
async execute(): Promise<number> {
|
|
798
977
|
return run(this.context, async (h) => {
|
|
799
|
-
const { readAllCached } = await import('../review/store.ts')
|
|
978
|
+
const { mediaDir, readAllCached } = await import('../review/store.ts')
|
|
800
979
|
const { threadDetail, detail } = await import('../review/format.ts')
|
|
801
980
|
const { threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
802
981
|
const id = await idOf(h.dir, this.id)
|
|
@@ -805,25 +984,25 @@ export class ReviewShowCommand extends Command {
|
|
|
805
984
|
if (!x) throw new Error(`no item ${this.id}`)
|
|
806
985
|
if (this.paste) {
|
|
807
986
|
const { dirname } = await import('node:path')
|
|
808
|
-
const { pasteHosts,
|
|
987
|
+
const { pasteHosts, threadUrl } = await import('../review/paste.ts')
|
|
809
988
|
const { pasteBlock, STATUS_LABEL } = await import('../review/model.ts')
|
|
810
989
|
const { statusOf } = await import('../review/threads.ts')
|
|
811
990
|
const w = await pasteHosts(dirname(dirname(h.dir)))
|
|
812
|
-
h.out(pasteBlock(x.item, STATUS_LABEL[statusOf(x, all.items)], { root: w.root, open:
|
|
991
|
+
h.out(pasteBlock(x.item, STATUS_LABEL[statusOf(x, all.items)], { root: w.root, open: threadUrl(w.open, x.item.id), phone: w.phone ? threadUrl(w.phone, x.item.id) : null }))
|
|
813
992
|
return 0
|
|
814
993
|
}
|
|
815
994
|
const t = threadOfItem(x.item.id, threadsOf(all.items))
|
|
816
|
-
// the
|
|
995
|
+
// the paths it prints are on the disk: a message's image or file the purge let go comes back first
|
|
817
996
|
const { ensureLocal } = await import('../review/media-read.ts')
|
|
818
997
|
const { membersOf } = await import('../review/threads.ts')
|
|
819
|
-
await Promise.all((t ? membersOf(t) : [x]).flatMap((y) => y.thread.flatMap((m) => (m.image ? [ensureLocal(h.dir, y.item.id, `thread/${
|
|
820
|
-
h.out(t && (t.head.item.id === x.item.id || t.answers.length > 0) ? threadDetail(t, h.dir, true, h.say) : detail(x, h.dir, true, false, h.say))
|
|
998
|
+
await Promise.all((t ? membersOf(t) : [x]).flatMap((y) => y.thread.flatMap((m) => [...(m.image ? [m.image] : []), ...(m.files ?? []).map((g) => g.file)].map((n) => ensureLocal(h.dir, y.item.id, `thread/${n}`).catch((e: Error) => h.err(`review: WARN thread/${n}: ${e.message}`))))))
|
|
999
|
+
h.out(t && (t.head.item.id === x.item.id || t.answers.length > 0) ? threadDetail(t, mediaDir(h.dir), true, h.say) : detail(x, mediaDir(h.dir), true, false, h.say))
|
|
821
1000
|
return 0
|
|
822
1001
|
})
|
|
823
1002
|
}
|
|
824
1003
|
}
|
|
825
1004
|
|
|
826
|
-
/** --mine or --session <id>: only the
|
|
1005
|
+
/** --mine or --session <id>: only the items that session opened; null keeps every item */
|
|
827
1006
|
async function sessionOf(mine: boolean, session: string | undefined): Promise<string | null> {
|
|
828
1007
|
if (session !== undefined) return session
|
|
829
1008
|
if (!mine) return null
|
|
@@ -846,10 +1025,10 @@ export class ReviewInboxCommand extends Command {
|
|
|
846
1025
|
session = Option.String('--session', { description: "only the threads that session holds" })
|
|
847
1026
|
subject = Option.String('--subject', { description: 'only items of this subject kind (frame, shot…)' })
|
|
848
1027
|
all = Option.Boolean('--all', false, { description: 'a plain approval too, not only the counted line' })
|
|
849
|
-
hook = Option.Boolean('--hook', false, { description: 'run as a Claude Code hook (UserPromptSubmit, Stop): the hook input on stdin, its json answer on stdout.
|
|
1028
|
+
hook = Option.Boolean('--hook', false, { description: 'run as a Claude Code hook (UserPromptSubmit, Stop, SubagentStop): the hook input on stdin, its json answer on stdout. A thread whose holder is gone passes on first (a lane that ended → its session); the unseen answers join a prompt as context, and a turn does not end while one is unseen, or while a thread of his turn has no watch to hear it' })
|
|
850
1029
|
|
|
851
1030
|
async execute(): Promise<number> {
|
|
852
|
-
const { hookPasses, hookSession, parseHookInput } = await import('../review/inbox-hook.ts')
|
|
1031
|
+
const { endedAgentOf, hookPasses, hookSession, parseHookInput } = await import('../review/inbox-hook.ts')
|
|
853
1032
|
// the hook input is one small json on stdin; a terminal has none
|
|
854
1033
|
const input = this.hook ? parseHookInput(process.stdin.isTTY === true ? '' : await new Response(Bun.stdin.stream()).text().catch(() => '')) : null
|
|
855
1034
|
if (input != null && hookPasses(input)) return 0
|
|
@@ -869,24 +1048,39 @@ export class ReviewInboxCommand extends Command {
|
|
|
869
1048
|
const session = hookSession(input)
|
|
870
1049
|
const { noteHanded, noteSession } = await import('../agent-time/registry.ts')
|
|
871
1050
|
if (session !== null) noteSession(h.dir)
|
|
872
|
-
|
|
873
|
-
|
|
1051
|
+
let stores = [here, ...(session === null ? [] : await storesOf(session, h.dir))]
|
|
1052
|
+
// a SubagentStop fires at every turn a lane ends, one that waits on its background work too: the
|
|
1053
|
+
// registry reads which (agent-time/registry.ts readParties, stopped)
|
|
1054
|
+
const parties = await partiesFor(stores, session, endedAgentOf(input))
|
|
1055
|
+
// rule 2 as a write: a thread whose holder is gone passes on now (review/hand-over.ts)
|
|
1056
|
+
const { handOver, handedLines } = await import('../review/hand-over.ts')
|
|
1057
|
+
const handed = session === null ? [] : stores.flatMap((s) => handOver(s.dir, s.say.spec, parties, s.repo, { onHanded: noteHanded }))
|
|
1058
|
+
if (input.hook_event_name === 'SubagentStop') return 0
|
|
1059
|
+
if (handed.length > 0) stores = [await hereStore(h), ...(session === null ? [] : await storesOf(session, h.dir))]
|
|
874
1060
|
const me = { lane: null, session }
|
|
875
|
-
|
|
1061
|
+
// the session's own watch in a store, or its one house watch for all of them
|
|
1062
|
+
const { laneWatchesOf, watchedBy } = await import('../review/watchers.ts')
|
|
1063
|
+
const watchedIn = watchedBy(session, stores.map((s) => s.dir))
|
|
1064
|
+
const laneWatches = session === null ? [] : laneWatchesOf(session, stores.map((s) => s.dir))
|
|
1065
|
+
const answer = hookReply({ input, me, stores, parties, onHanded: noteHanded, handed: handedLines(handed.filter((x) => x.to === session)), watchedIn, laneWatches })
|
|
876
1066
|
if (answer != null) h.out(answer)
|
|
877
1067
|
return 0
|
|
878
1068
|
}
|
|
879
1069
|
const session = await sessionOf(this.mine, this.session)
|
|
880
|
-
const lane = this.mine ?
|
|
1070
|
+
const lane = this.mine ? callerLane(undefined) : null
|
|
881
1071
|
const parties = session === null && lane === null ? null : await partiesFor([here], session)
|
|
882
1072
|
const since = sinceHeLeft(here.items)
|
|
883
1073
|
if (since && since.moved > 0) h.out(`since you left (${since.at}): ${since.moved} moved, ${since.yours} yours\n`)
|
|
884
1074
|
// his requests for a lane first: the orchestrator's (review/lane-ask.ts)
|
|
885
1075
|
const { laneAsksFor } = await import('../review/inbox-read.ts')
|
|
886
1076
|
for (const l of laneAsksFor(here, { session, lane }, parties ?? { sessions: [], lanes: [] })) h.out(`${l}\n`)
|
|
887
|
-
|
|
1077
|
+
// the owner's words that name another agent are that agent's (wiki tools/shipkit/threads-how-it-fits.md, Mentions)
|
|
1078
|
+
const { wordReaches } = await import('../review/threads.ts')
|
|
1079
|
+
const named = threadByItem(threadsOf(here.items, h.say.spec))
|
|
1080
|
+
const mine = { ...here, say: { ...here.say, to: (x: import('../review/model.ts').ReviewItem, m: import('../review/model.ts').Message) => wordReaches({ session, lane }, x, m, named, parties) } }
|
|
1081
|
+
const sel = selectInbox(mine, (x, byItem) => hears({ session, lane }, x, byItem, parties), { all: this.all, subject: this.subject })
|
|
888
1082
|
if (sel.threads.length === 0 && sel.news.length === 0) h.out('review: no unseen feedback or reply')
|
|
889
|
-
for (const g of sel.threads) h.out(`${selectedText(
|
|
1083
|
+
for (const g of sel.threads) h.out(`${selectedText(mine, g)}\n`)
|
|
890
1084
|
const { ownAddressOf, verdictOf } = await import('../review/model.ts')
|
|
891
1085
|
const owedLine = (t: (typeof sel.owed)[number]): string => {
|
|
892
1086
|
const x = t.head
|
|
@@ -921,23 +1115,15 @@ async function hereStore(h: Here): Promise<import('../review/inbox-read.ts').Sto
|
|
|
921
1115
|
|
|
922
1116
|
/** every other store this session or its lanes wrote in (agent-time/registry.ts), each with its repo's unit bound */
|
|
923
1117
|
async function storesOf(session: string, hereDir: string): Promise<import('../review/inbox-read.ts').StoreRead[]> {
|
|
924
|
-
const {
|
|
925
|
-
const {
|
|
1118
|
+
const { repoNameOf } = await import('../agent-time/registry.ts')
|
|
1119
|
+
const { readAll } = await import('../review/store.ts')
|
|
926
1120
|
const { dirname, resolve } = await import('node:path')
|
|
927
|
-
const dirs: string[] = []
|
|
928
|
-
const gone: string[] = []
|
|
929
|
-
// only a store its commands run in: `sk thread seen` there refuses a folder that is no shipkit repo
|
|
930
|
-
for (const d of (readSessionRecords().find((r) => r.session === session)?.stores ?? []).filter((x) => resolve(x) !== resolve(hereDir)))
|
|
931
|
-
(existsSync(d) && (await reviewRoot(dirname(dirname(d)))) !== null ? dirs : gone).push(d)
|
|
932
|
-
forgetStores(session, gone)
|
|
933
1121
|
const out: import('../review/inbox-read.ts').StoreRead[] = []
|
|
934
|
-
for (const dir of
|
|
1122
|
+
for (const dir of await recordedStores(session, (d) => resolve(d) === resolve(hereDir))) {
|
|
935
1123
|
const root = dirname(dirname(dir))
|
|
936
1124
|
try {
|
|
937
|
-
const {
|
|
938
|
-
|
|
939
|
-
const { unit } = await openReview(root)
|
|
940
|
-
out.push({ repo: repoNameOf(root), root, dir, here: false, ...readAll(dir), say: { spec: specOf(dir), more: (x) => factLines(unit, x) } })
|
|
1125
|
+
const { say } = await hereAt(dir, () => {}, () => {})
|
|
1126
|
+
out.push({ repo: repoNameOf(root), root, dir, here: false, ...readAll(dir), say })
|
|
941
1127
|
} catch {
|
|
942
1128
|
// a store that does not read now: its own repo's hook and inbox say why
|
|
943
1129
|
}
|
|
@@ -945,8 +1131,30 @@ async function storesOf(session: string, hereDir: string): Promise<import('../re
|
|
|
945
1131
|
return out
|
|
946
1132
|
}
|
|
947
1133
|
|
|
1134
|
+
/** the stores the session's record names, but those `skip` keeps out; only a store its commands run in (`sk thread
|
|
1135
|
+
* seen` there refuses a folder that is no shipkit repo), the others leave its record */
|
|
1136
|
+
async function recordedStores(session: string, skip: (dir: string) => boolean): Promise<string[]> {
|
|
1137
|
+
const { forgetStores, readSessionRecord, scratchStore } = await import('../agent-time/registry.ts')
|
|
1138
|
+
const { existsSync } = await import('node:fs')
|
|
1139
|
+
const { dirname } = await import('node:path')
|
|
1140
|
+
const dirs: string[] = []
|
|
1141
|
+
const gone: string[] = []
|
|
1142
|
+
for (const d of (readSessionRecord(session)?.stores ?? []).filter((x) => !skip(x))) (!scratchStore(d) && existsSync(d) && (await reviewRoot(dirname(dirname(d)))) !== null ? dirs : gone).push(d)
|
|
1143
|
+
forgetStores(session, gone)
|
|
1144
|
+
return dirs
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/** the store at `dir` of another repo as a verb works on it, its repo's unit bound */
|
|
1148
|
+
async function hereAt(dir: string, out: (l: string) => void, err: (l: string) => void): Promise<Here> {
|
|
1149
|
+
const { openReview, factLines } = await import('../review/project.ts')
|
|
1150
|
+
const { specOf } = await import('../review/store.ts')
|
|
1151
|
+
const { dirname } = await import('node:path')
|
|
1152
|
+
const { unit } = await openReview(dirname(dirname(dir)))
|
|
1153
|
+
return { dir, unit, say: { spec: specOf(dir), more: (x) => factLines(unit, x) }, out, err }
|
|
1154
|
+
}
|
|
1155
|
+
|
|
948
1156
|
/** the parties these stores' threads name: their holders' sessions and the caller's, with each store's live watches */
|
|
949
|
-
async function partiesFor(stores: readonly import('../review/inbox-read.ts').StoreRead[], self: string | null): Promise<import('../review/parties.ts').Parties> {
|
|
1157
|
+
async function partiesFor(stores: readonly import('../review/inbox-read.ts').StoreRead[], self: string | null, stopped: string | null = null): Promise<import('../review/parties.ts').Parties> {
|
|
950
1158
|
const { readParties } = await import('../agent-time/registry.ts')
|
|
951
1159
|
const { holderOf, threadsOf } = await import('../review/threads.ts')
|
|
952
1160
|
const { liveWatchers } = await import('../review/watchers.ts')
|
|
@@ -955,23 +1163,27 @@ async function partiesFor(stores: readonly import('../review/inbox-read.ts').Sto
|
|
|
955
1163
|
const hs = holderOf(t)?.session
|
|
956
1164
|
if (hs) ids.add(hs)
|
|
957
1165
|
}
|
|
958
|
-
return readParties({ sessions: [...ids], watchers: stores.flatMap((s) => liveWatchers(s.dir)), self })
|
|
1166
|
+
return readParties({ sessions: [...ids], watchers: stores.flatMap((s) => liveWatchers(s.dir)), self, stopped })
|
|
959
1167
|
}
|
|
960
1168
|
|
|
961
|
-
/** the lane that acts on a reply or a seen
|
|
962
|
-
const
|
|
1169
|
+
/** the lane that acts on a reply or a seen, by this process's SK_AGENT (review/parties.ts laneOfCaller) */
|
|
1170
|
+
const callerLane = (as: string | undefined): string | null => laneOfCaller(as, process.env.SK_AGENT)
|
|
963
1171
|
|
|
964
1172
|
/** why the caller may not mark his answer on this item seen (review/threads.ts seenRefusal, rule 4: the holder or its
|
|
965
1173
|
* session), null when it may */
|
|
966
|
-
async function seenRefused(dir: string, id: string, as: string | undefined): Promise<string | null> {
|
|
1174
|
+
async function seenRefused(dir: string, id: string, as: string | undefined): Promise<{ refused: string | null; only?: string[] }> {
|
|
967
1175
|
const { readAll } = await import('../review/store.ts')
|
|
968
|
-
const { seenRefusal, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1176
|
+
const { seenOnly, seenRefusal, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
969
1177
|
const items = readAll(dir).items
|
|
970
1178
|
const x = items.find((y) => y.item.id === id)
|
|
971
|
-
if (x === undefined) return null
|
|
1179
|
+
if (x === undefined) return { refused: null }
|
|
972
1180
|
const t = threadOfItem(id, threadsOf(items))
|
|
973
1181
|
const { me, parties } = await callerParties(dir, t, as)
|
|
974
|
-
|
|
1182
|
+
// a lane the owner's words name reads those words only, on a thread another agent holds
|
|
1183
|
+
const { repoNameOf } = await import('../agent-time/registry.ts')
|
|
1184
|
+
const { dirname } = await import('node:path')
|
|
1185
|
+
const only = seenOnly(x, t, me, parties, repoNameOf(dirname(dirname(dir))))
|
|
1186
|
+
return { refused: seenRefusal(x, t, me, parties), ...(only !== undefined ? { only } : {}) }
|
|
975
1187
|
}
|
|
976
1188
|
|
|
977
1189
|
/** the caller and the parties its thread's holder names */
|
|
@@ -980,23 +1192,19 @@ async function callerParties(dir: string, t: import('../review/threads.ts').Thre
|
|
|
980
1192
|
const { holderOf } = await import('../review/threads.ts')
|
|
981
1193
|
const { readParties } = await import('../agent-time/registry.ts')
|
|
982
1194
|
const { liveWatchers } = await import('../review/watchers.ts')
|
|
983
|
-
const me = { lane:
|
|
1195
|
+
const me = { lane: callerLane(as), session: sessionId() }
|
|
984
1196
|
const hs = t ? holderOf(t)?.session : undefined
|
|
985
1197
|
return { me, parties: await readParties({ sessions: hs ? [hs] : [], watchers: liveWatchers(dir), self: me.session }) }
|
|
986
1198
|
}
|
|
987
1199
|
|
|
988
|
-
/** the caller holds the item's thread
|
|
989
|
-
* may close what that lane claimed, as itself */
|
|
1200
|
+
/** the caller holds the item's thread (review/parties.ts holdsThread): it may close what that thread's lane claimed */
|
|
990
1201
|
async function callerHolds(dir: string, id: string, as: string | undefined): Promise<boolean> {
|
|
991
1202
|
const { readAll } = await import('../review/store.ts')
|
|
992
1203
|
const { holderOf, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
993
|
-
const { maySee } = await import('../review/parties.ts')
|
|
994
1204
|
const t = threadOfItem(id, threadsOf(readAll(dir).items))
|
|
995
|
-
if (t === null) return false
|
|
996
|
-
const h = holderOf(t)
|
|
997
|
-
if (h === null) return false
|
|
1205
|
+
if (t === null || holderOf(t) === null) return false
|
|
998
1206
|
const { me, parties } = await callerParties(dir, t, as)
|
|
999
|
-
return
|
|
1207
|
+
return holdsThread(me, holderOf(t), parties)
|
|
1000
1208
|
}
|
|
1001
1209
|
|
|
1002
1210
|
/** `--replaces <object>`: the thread item `id` is in, and the message id the new object supersedes, once the caller may
|
|
@@ -1015,10 +1223,9 @@ async function replacing(dir: string, ref: string, target: string, as: string |
|
|
|
1015
1223
|
return { id, replaces }
|
|
1016
1224
|
}
|
|
1017
1225
|
|
|
1018
|
-
/** the caller may act as the thread's holder: it holds it, or
|
|
1226
|
+
/** the caller may act as the thread's holder (review/parties.ts maySee): it holds it, or nobody does */
|
|
1019
1227
|
async function mayHold(dir: string, t: import('../review/threads.ts').Thread, as: string | undefined): Promise<boolean> {
|
|
1020
1228
|
const { holderOf } = await import('../review/threads.ts')
|
|
1021
|
-
const { maySee } = await import('../review/parties.ts')
|
|
1022
1229
|
const { me, parties } = await callerParties(dir, t, as)
|
|
1023
1230
|
return maySee(me, holderOf(t), parties)
|
|
1024
1231
|
}
|
|
@@ -1041,7 +1248,7 @@ export class ReviewSeenCommand extends Command {
|
|
|
1041
1248
|
async execute(): Promise<number> {
|
|
1042
1249
|
return run(this.context, async (h) => {
|
|
1043
1250
|
const { markSeen } = await import('../review/store.ts')
|
|
1044
|
-
// every id checked before any is marked: his answer on another lane's
|
|
1251
|
+
// every id checked before any is marked: his answer on another lane's version stays unread for that lane
|
|
1045
1252
|
const ids: [string, string][] = []
|
|
1046
1253
|
const { ID_RE } = await import('../review/model.ts')
|
|
1047
1254
|
for (const ref of this.ids) {
|
|
@@ -1059,11 +1266,12 @@ export class ReviewSeenCommand extends Command {
|
|
|
1059
1266
|
}
|
|
1060
1267
|
ids.push([ref, await idOf(h.dir, ref).catch(() => ref)])
|
|
1061
1268
|
}
|
|
1062
|
-
const
|
|
1269
|
+
const scopes = await Promise.all(ids.map(([, id]) => seenRefused(h.dir, id, this.as)))
|
|
1270
|
+
const refused = scopes.map((s) => s.refused).filter((w) => w !== null)
|
|
1063
1271
|
if (refused.length > 0) throw new Error(`nothing marked: ${refused.join('; ')}`)
|
|
1064
1272
|
let bad = 0
|
|
1065
|
-
for (const [ref, id] of ids) {
|
|
1066
|
-
if (markSeen(h.dir, id)) h.out(`${ref}: seen`)
|
|
1273
|
+
for (const [i, [ref, id]] of ids.entries()) {
|
|
1274
|
+
if (markSeen(h.dir, id, new Date(), scopes[i]!.only)) h.out(`${ref}: seen`)
|
|
1067
1275
|
else {
|
|
1068
1276
|
h.err(`FAIL: review: ${ref}: no such item, or nothing of his to read on it`)
|
|
1069
1277
|
bad++
|
|
@@ -1099,7 +1307,7 @@ export class ThreadWorkingCommand extends Command {
|
|
|
1099
1307
|
const { threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1100
1308
|
const id = await idOf(h.dir, this.ref)
|
|
1101
1309
|
const t = threadOfItem(id, threadsOf(readAll(h.dir).items, h.say.spec))
|
|
1102
|
-
const who =
|
|
1310
|
+
const who = callerLane(this.as) ?? 'agent'
|
|
1103
1311
|
appendMessage(h.dir, t?.head.item.id ?? id, { who, op: 'working', note: line })
|
|
1104
1312
|
h.out(`${this.ref}: ${who} is on it: ${line} (your next act in this thread ends it)`)
|
|
1105
1313
|
return 0
|
|
@@ -1131,19 +1339,23 @@ export class ThreadTakeCommand extends Command {
|
|
|
1131
1339
|
const { dropHanded, readParties, repoNameOf } = await import('../agent-time/registry.ts')
|
|
1132
1340
|
const { liveWatchers } = await import('../review/watchers.ts')
|
|
1133
1341
|
const { sessionId } = await import('../review/store.ts')
|
|
1134
|
-
const lane =
|
|
1342
|
+
const lane = callerLane(this.as)
|
|
1135
1343
|
appendMessage(h.dir, head, { who: lane ?? 'agent', op: 'take' })
|
|
1136
1344
|
// taken here: the ended lane, resumed later, leaves it to its taker
|
|
1137
1345
|
const self = sessionId()
|
|
1138
1346
|
if (self) dropHanded(self, h.dir, head, lane)
|
|
1139
1347
|
const after = threadOfItem(head, threadsOf(readAll(h.dir).items, h.say.spec))
|
|
1140
1348
|
const now = after ? holderOf(after) : null
|
|
1141
|
-
|
|
1349
|
+
// a house watch of the caller hears this store too, within 2 s of the take
|
|
1350
|
+
const { houseWatchesOf } = await import('../review/watchers.ts')
|
|
1351
|
+
const { readSessionRecord } = await import('../agent-time/registry.ts')
|
|
1352
|
+
const house = self ? houseWatchesOf(self, readSessionRecord(self)?.stores ?? []) : []
|
|
1353
|
+
const parties = await readParties({ sessions: [...new Set([was?.session, now?.session].filter((x): x is string => !!x))], watchers: [...liveWatchers(h.dir), ...house], self })
|
|
1142
1354
|
const { dirname } = await import('node:path')
|
|
1143
1355
|
const hearing = after ? hearingOfThread(after, parties, repoNameOf(dirname(dirname(h.dir)))) : null
|
|
1144
1356
|
const wasText = was === null ? 'nobody held it' : `it was held by ${was.lane ?? sessionLabel(was.session, parties)}`
|
|
1145
1357
|
h.out(`${this.ref}: yours now (${hearing?.chip ?? lane ?? 'this session'}), ${wasText}; ${hearing?.words ?? ''}`)
|
|
1146
|
-
if (hearing && hearing.light !== 'hears') h.err(`review: no watch of yours hears it now: sk thread watch --mine under a monitor`)
|
|
1358
|
+
if (hearing && hearing.light !== 'hears') h.err(`review: no watch of yours hears it now: sk thread watch --mine --house under a monitor, one watch for every repo where you hold threads`)
|
|
1147
1359
|
return 0
|
|
1148
1360
|
})
|
|
1149
1361
|
}
|
|
@@ -1172,7 +1384,7 @@ export class ThreadAssignCommand extends Command {
|
|
|
1172
1384
|
const id = await idOf(h.dir, this.ref)
|
|
1173
1385
|
const head = threadOfItem(id, threadsOf(readAll(h.dir).items, h.say.spec))?.head.item.id ?? id
|
|
1174
1386
|
const self = sessionId()
|
|
1175
|
-
const by =
|
|
1387
|
+
const by = callerLane(undefined) ?? (self ? sessionLabel(self, await readParties({ sessions: [], self })) : 'a terminal')
|
|
1176
1388
|
appendMessage(h.dir, head, { who: lane, op: 'take', note: `assigned by ${by}` })
|
|
1177
1389
|
if (self) dropHanded(self, h.dir, head, lane)
|
|
1178
1390
|
h.out(`${this.ref}: given to ${lane} (assigned by ${by}): its first act there (sk thread working ${this.ref} "…") clears his request`)
|
|
@@ -1202,13 +1414,13 @@ export class ReviewReplyCommand extends Command {
|
|
|
1202
1414
|
const r = await replacing(h.dir, this.id, this.replaces, this.as)
|
|
1203
1415
|
const t = textOf(this.text)
|
|
1204
1416
|
if ('error' in t) throw new Error(t.error)
|
|
1205
|
-
const m = appendMessage(h.dir, r.id, { who:
|
|
1417
|
+
const m = appendMessage(h.dir, r.id, { who: callerLane(this.as) ?? agentName(), text: t.text, replaces: r.replaces, ...(this.verdict ? { asksVerdict: true as const } : {}) })
|
|
1206
1418
|
h.out(`${r.id}: ${m.id} supersedes ${r.replaces}`)
|
|
1207
1419
|
return 0
|
|
1208
1420
|
}
|
|
1209
1421
|
const id = await idOrOpen(h, this.id, this.text, this.as)
|
|
1210
|
-
const m = await wordsIn(h.dir, id,
|
|
1211
|
-
if (this.urgent) await urgentOn(h.dir, id,
|
|
1422
|
+
const m = await wordsIn(h.dir, id, callerLane(this.as) ?? agentName(), this.text, this.verdict, this.image)
|
|
1423
|
+
if (this.urgent) await urgentOn(h.dir, id, callerLane(this.as) ?? agentName())
|
|
1212
1424
|
h.out(`${id}: ${m.id}`)
|
|
1213
1425
|
return 0
|
|
1214
1426
|
})
|
|
@@ -1256,14 +1468,14 @@ export class ReviewUpdateCommand extends Command {
|
|
|
1256
1468
|
if ((UPDATE_STATES as readonly string[]).includes(this.state)) throw new Error(`update <address | id> ${this.state} "<one line>": the line is missing`)
|
|
1257
1469
|
const at = await idOrOpen(h, this.id, this.state, this.as)
|
|
1258
1470
|
const on = threadOfId(at, threadsOf(readAll(h.dir).items))?.head.item.id ?? at
|
|
1259
|
-
const m = await wordsIn(h.dir, on,
|
|
1471
|
+
const m = await wordsIn(h.dir, on, callerLane(this.as) ?? agentName(), this.state, this.verdict)
|
|
1260
1472
|
h.out(`${on}: ${m.id}, a line, no state`)
|
|
1261
1473
|
return 0
|
|
1262
1474
|
}
|
|
1263
1475
|
const asked = await idOrOpen(h, this.id, this.text, this.as)
|
|
1264
1476
|
// an update goes where he reads: the thread's newest version
|
|
1265
1477
|
const id = threadOfId(asked, threadsOf(readAll(h.dir).items))?.head.item.id ?? asked
|
|
1266
|
-
const r = await postUpdate(h.dir, id, { who:
|
|
1478
|
+
const r = await postUpdate(h.dir, id, { who: callerLane(this.as) ?? agentName(), state: this.state, text: this.text, files: this.files, ...(this.keep ? { keep: true } : {}) })
|
|
1267
1479
|
const { viewNo, stateOf } = await import('../review/model.ts')
|
|
1268
1480
|
const { readItem } = await import('../review/store.ts')
|
|
1269
1481
|
const x = readItem(h.dir, id)
|
|
@@ -1283,8 +1495,8 @@ export class ReviewWithdrawCommand extends Command {
|
|
|
1283
1495
|
static override paths = [['review', 'withdraw']]
|
|
1284
1496
|
static override usage = Command.Usage({
|
|
1285
1497
|
category: 'Review',
|
|
1286
|
-
description: 'take back an
|
|
1287
|
-
details: `${DETAILS}\n\nA version (or a thread
|
|
1498
|
+
description: 'take back what an agent posted, with the reason: a version by its id, or one message by its id',
|
|
1499
|
+
details: `${DETAILS}\n\nA version (or any other item of a thread) withdrawn asks nothing more: its open questions, changes and words asking the owner's verdict wait on nobody with it. A message id (sk thread show prints them) takes back that one question, change or words alone, a reply posted by mistake included. A thread (its address, or its own id t-…) is refused with the ids of its items: name the one you mean. What the owner wrote or raised is never withdrawn by an agent. --chat "<the owner's words>": the owner answered it in chat; the words are the reason, quoted, so it never stays open in the hub.`,
|
|
1288
1500
|
examples: [
|
|
1289
1501
|
['a version taken back', 'sk thread withdraw 20261120-101500-the-logo --why "a newer one follows"'],
|
|
1290
1502
|
['he answered the question in chat', 'sk thread withdraw 20261120-223154-747-agent-vg49 --chat "B only, keep both kill matrices"'],
|
|
@@ -1308,7 +1520,7 @@ export class ReviewWithdrawCommand extends Command {
|
|
|
1308
1520
|
h.out(`${msg}: withdrawn (${why}); it waits on nobody now`)
|
|
1309
1521
|
continue
|
|
1310
1522
|
}
|
|
1311
|
-
const id = await idOf(h.dir, ref)
|
|
1523
|
+
const id = await idOf(h.dir, ref, { verb: 'withdraw', objects: true })
|
|
1312
1524
|
const r = withdraw(h.dir, id, why)
|
|
1313
1525
|
if ('refused' in r) throw new Error(r.refused)
|
|
1314
1526
|
h.out(r.already ? `${id}: withdrawn already (${r.already}), nothing to do` : `${id}: withdrawn, its open questions and changes with it`)
|
|
@@ -1326,10 +1538,10 @@ export class ReviewReopenCommand extends Command {
|
|
|
1326
1538
|
async execute(): Promise<number> {
|
|
1327
1539
|
return run(this.context, async (h) => {
|
|
1328
1540
|
const { reopen } = await import('../review/store.ts')
|
|
1329
|
-
const { followAnswer } = await import('../releases/from-
|
|
1541
|
+
const { followAnswer } = await import('../releases/from-thread.ts')
|
|
1330
1542
|
const { dirname } = await import('node:path')
|
|
1331
1543
|
for (const ref of this.ids) {
|
|
1332
|
-
const id = await idOf(h.dir, ref)
|
|
1544
|
+
const id = await idOf(h.dir, ref, { verb: 'reopen' })
|
|
1333
1545
|
const v = reopen(h.dir, id)
|
|
1334
1546
|
if (!v) throw new Error(`${id}: no such version, or no answer to reopen`)
|
|
1335
1547
|
await followAnswer(dirname(dirname(h.dir)), id, v.status)
|
|
@@ -1392,12 +1604,37 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
|
|
|
1392
1604
|
urgent = op === 'ask' ? Option.Boolean('--urgent', false, { description: 'brings back a thread he set aside, at once: only under the bar of a ping (an incident, a hard block, a deadline before it comes back)' }) : undefined
|
|
1393
1605
|
login = op === 'ask' ? Option.Boolean('--login', false, { description: 'with --secret: a login, its account (the email or user name) typed and stored beside it' }) : undefined
|
|
1394
1606
|
replaces = op === 'ask' ? Option.String('--replaces', { description: 'the id of your earlier question (or words) this one supersedes: it folds to one line « superseded by … » and leaves the dock, his answers on it kept' }) : undefined
|
|
1607
|
+
keep = op === 'ask' ? Option.Boolean('--keep', false, { description: 'keep his older open questions of the same kind on this thread open beside this one; by default this one supersedes them' }) : undefined
|
|
1395
1608
|
verdict = op === 'ask' ? Option.Boolean('--verdict', false, { description: "refused: a question waits for the owner's answer already, his answer is its verdict" }) : undefined
|
|
1396
1609
|
|
|
1397
|
-
/** the thread item the question goes on and what it supersedes: never a new thread when it supersedes
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1610
|
+
/** the thread item the question goes on and what it supersedes: never a new thread when it supersedes. Named
|
|
1611
|
+
* none, it supersedes the older open questions of its kind on the thread (review/supersede.ts olderQuestions):
|
|
1612
|
+
* the newest by `replaces`, each other withdrawn by `withdrawOlder` once this one has its id; `--keep` none */
|
|
1613
|
+
async target(h: Here, q: { kind: AnswerKind; secret?: string }): Promise<{ id: string; replaces?: string; others: string[] }> {
|
|
1614
|
+
if (this.replaces !== undefined) return { ...(await replacing(h.dir, this.id, this.replaces, this.as)), others: [] }
|
|
1615
|
+
const id = await idOrOpen(h, this.id, this.words ?? '', this.as)
|
|
1616
|
+
if (this.keep) return { id, others: [] }
|
|
1617
|
+
const { readAll } = await import('../review/store.ts')
|
|
1618
|
+
const { membersOf, threadOfItem, threadsOf } = await import('../review/threads.ts')
|
|
1619
|
+
const { olderQuestions } = await import('../review/supersede.ts')
|
|
1620
|
+
const t = threadOfItem(id, threadsOf(readAll(h.dir).items))
|
|
1621
|
+
const older = t === null ? [] : olderQuestions(membersOf(t), q)
|
|
1622
|
+
if (older.length === 0) return { id, others: [] }
|
|
1623
|
+
if (!(await mayHold(h.dir, t!, this.as))) {
|
|
1624
|
+
h.err(` ${older.length} older open question${older.length > 1 ? 's' : ''} of this kind stay open (${older.map((m) => m.id).join(', ')}): another agent holds the thread; sk thread take <address>, then --replaces <id>`)
|
|
1625
|
+
return { id, others: [] }
|
|
1626
|
+
}
|
|
1627
|
+
return { id, replaces: older.at(-1)!.id, others: older.slice(0, -1).map((m) => m.id) }
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
/** the older questions `target` named beside the one it superseded: each withdrawn, « replaced by » the new one */
|
|
1631
|
+
async withdrawOlder(h: Here, t: { replaces?: string; others: string[] }, by: string): Promise<void> {
|
|
1632
|
+
if (t.replaces !== undefined && this.replaces === undefined) h.out(` supersedes ${t.replaces}${t.others.length > 0 ? ` and ${t.others.join(', ')}` : ''}: older open question${t.others.length > 0 ? 's' : ''} of this kind (--keep keeps them)`)
|
|
1633
|
+
const { withdrawObject } = await import('../review/store.ts')
|
|
1634
|
+
for (const re of t.others) {
|
|
1635
|
+
const r = withdrawObject(h.dir, re, `replaced by ${by}`)
|
|
1636
|
+
if ('refused' in r) h.err(` ${re} stays open: ${r.refused}`)
|
|
1637
|
+
}
|
|
1401
1638
|
}
|
|
1402
1639
|
|
|
1403
1640
|
/** after a question: set aside until --after, or brought back by --urgent */
|
|
@@ -1427,7 +1664,7 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
|
|
|
1427
1664
|
|
|
1428
1665
|
async execute(): Promise<number> {
|
|
1429
1666
|
return run(this.context, async (h) => {
|
|
1430
|
-
const { act, readItem } = await import('../review/store.ts')
|
|
1667
|
+
const { act, mediaDir, readItem } = await import('../review/store.ts')
|
|
1431
1668
|
if (op === 'done') h.err(`sk thread done is now sk thread fixed ${this.id} "<what changed>"`)
|
|
1432
1669
|
if (this.verdict) throw new Error("ask --verdict: a question waits for the owner's answer already, his answer is its verdict; a thing made he approves goes in a reply --verdict")
|
|
1433
1670
|
const k = op === 'ask' ? this.kindFlags() : null
|
|
@@ -1439,9 +1676,11 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
|
|
|
1439
1676
|
const who = await (await import('../secrets/who-reads.ts')).whoReads([this.secret], process.cwd())
|
|
1440
1677
|
if (who[this.secret]?.registered !== true) throw new Error(`--secret ${this.secret}: no row in the secret registry, so the vault would refuse the value he types. Add its row first (the name, what it is for, its scope: wiki identities/_common/secrets-registry.md), then ask again`)
|
|
1441
1678
|
}
|
|
1442
|
-
const {
|
|
1679
|
+
const at = await this.target(h, { kind: k.kind, ...(k.kind === 'secret' && this.secret ? { secret: this.secret } : {}) })
|
|
1680
|
+
const { id, replaces } = at
|
|
1443
1681
|
const m = await postAsk(h.dir, id, { who: actor(this.as, false, op), text: this.words, kind: k.kind, ...(k.kind === 'checklist' ? { options: this.checklist ?? [] } : {}), ...(k.kind === 'secret' ? { secret: { name: this.secret ?? '', login: this.login === true } } : {}), ...(replaces ? { replaces } : {}) })
|
|
1444
1682
|
h.out(`${id} asked: ${askStateText(readItem(h.dir, id)?.thread ?? [m], m)}`)
|
|
1683
|
+
await this.withdrawOlder(h, at, m.id)
|
|
1445
1684
|
await this.later(h, id)
|
|
1446
1685
|
if (k.kind === 'secret') h.out(` his answer reads « stored as ${m.ask?.secret?.name} »; then: sk secret get ${m.ask?.secret?.name}`)
|
|
1447
1686
|
return 0
|
|
@@ -1449,11 +1688,13 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
|
|
|
1449
1688
|
if (op === 'ask' && this.options !== undefined) {
|
|
1450
1689
|
const { postAsk } = await import('../review/store.ts')
|
|
1451
1690
|
if (!this.words?.trim()) throw new Error('ask <address | id> "<question>" --option "<a>" --option "<b>" --pick <n>')
|
|
1452
|
-
const
|
|
1691
|
+
const at = await this.target(h, { kind: 'choice' })
|
|
1692
|
+
const { id, replaces } = at
|
|
1453
1693
|
const pick = this.pick === undefined ? undefined : Number(this.pick) - 1
|
|
1454
1694
|
if (pick === undefined) h.err('no --pick: the house rule wants your pick on every question')
|
|
1455
1695
|
const m = await postAsk(h.dir, id, { who: actor(this.as, false, op), text: this.words, options: this.options.map(askOption), ...(pick !== undefined ? { pick } : {}), ...(replaces ? { replaces } : {}) })
|
|
1456
1696
|
h.out(`${id} asked: ${m.ask?.options.map((o, i) => `${i + 1} ${o}${m.ask?.views?.[i] != null ? ' [media]' : ''}${m.ask?.pick === i ? ' (your pick)' : ''}`).join(' · ')}`)
|
|
1697
|
+
await this.withdrawOlder(h, at, m.id)
|
|
1457
1698
|
await this.later(h, id)
|
|
1458
1699
|
return 0
|
|
1459
1700
|
}
|
|
@@ -1478,7 +1719,7 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
|
|
|
1478
1719
|
}
|
|
1479
1720
|
}
|
|
1480
1721
|
if (op === 'done') {
|
|
1481
|
-
// done is asked of
|
|
1722
|
+
// done is asked of an item he answered « fix »: closed already is the goal reached, unanswered is withdraw's
|
|
1482
1723
|
const { readAll } = await import('../review/store.ts')
|
|
1483
1724
|
const { followedIds } = await import('../review/threads.ts')
|
|
1484
1725
|
const was = readItem(h.dir, id)
|
|
@@ -1504,7 +1745,7 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
|
|
|
1504
1745
|
const x = readItem(h.dir, id)
|
|
1505
1746
|
const st = x ? stateOf(x, false) : null
|
|
1506
1747
|
h.out(`${id} ${op}: ${st ? `${st.state}${st.why ? ` (${st.why})` : ''}${st.topic ? ` ${st.topic}` : ''}${st.worker ? ` ${st.worker}` : ''}` : 'gone'}`)
|
|
1507
|
-
if (op === 'claim' && x) h.out(detail(x, h.dir, false, false, h.say))
|
|
1748
|
+
if (op === 'claim' && x) h.out(detail(x, mediaDir(h.dir), false, false, h.say))
|
|
1508
1749
|
return 0
|
|
1509
1750
|
})
|
|
1510
1751
|
}
|
|
@@ -1609,7 +1850,7 @@ export class ReviewNextCommand extends Command {
|
|
|
1609
1850
|
|
|
1610
1851
|
async execute(): Promise<number> {
|
|
1611
1852
|
return run(this.context, async (h) => {
|
|
1612
|
-
const { claimNext } = await import('../review/store.ts')
|
|
1853
|
+
const { claimNext, mediaDir } = await import('../review/store.ts')
|
|
1613
1854
|
const { stateOf } = await import('../review/model.ts')
|
|
1614
1855
|
const { detail } = await import('../review/format.ts')
|
|
1615
1856
|
const lane = this.lane?.trim()
|
|
@@ -1623,7 +1864,7 @@ export class ReviewNextCommand extends Command {
|
|
|
1623
1864
|
}
|
|
1624
1865
|
const topic = stateOf(got, false).topic
|
|
1625
1866
|
const read = topic ? h.say.spec.topics[topic]?.read : undefined
|
|
1626
|
-
h.out(`${detail(got, h.dir, false, false, h.say)}${read?.length ? `\nread first: ${read.join(', ')}` : ''}`)
|
|
1867
|
+
h.out(`${detail(got, mediaDir(h.dir), false, false, h.say)}${read?.length ? `\nread first: ${read.join(', ')}` : ''}`)
|
|
1627
1868
|
return 0
|
|
1628
1869
|
})
|
|
1629
1870
|
}
|
|
@@ -1850,13 +2091,13 @@ export class ReviewStageCommand extends Command {
|
|
|
1850
2091
|
const { isPostRating, POST_RATINGS } = await import('../identities/rating.ts')
|
|
1851
2092
|
const missing = [this.text === undefined ? '--text "<the post>"' : null, this.rating === undefined ? `--rating <${POST_RATINGS.join('|')}>` : null].filter((x) => x !== null)
|
|
1852
2093
|
if (this.text === undefined || this.rating === undefined) throw new Error(`sk thread stage ${this.id} needs ${missing.join(' and ')}`)
|
|
1853
|
-
const { stageInputOf,
|
|
2094
|
+
const { stageInputOf, stageOfThread } = await import('../review/stage-thread.ts')
|
|
1854
2095
|
const { askPolish, fitStage, stagedKind, stageDraft, stageDry } = await import('../social/stage.ts')
|
|
1855
2096
|
const { loadSocialUnit } = await import('../social/unit.ts')
|
|
1856
2097
|
if (!isPostRating(this.rating)) throw new Error(`--rating ${this.rating}: one of ${POST_RATINGS.join(', ')}`)
|
|
1857
2098
|
const root = dirname(dirname(h.dir))
|
|
1858
2099
|
const id = await idOf(h.dir, this.id)
|
|
1859
|
-
const s =
|
|
2100
|
+
const s = stageOfThread(h.dir, id)
|
|
1860
2101
|
let pick: string | undefined
|
|
1861
2102
|
if (this.view) {
|
|
1862
2103
|
// a view's number, or the letter it had before; either alone or after its version's number
|
|
@@ -1910,13 +2151,12 @@ export class ReviewAutoCommand extends Command {
|
|
|
1910
2151
|
if (this.verb === undefined) {
|
|
1911
2152
|
if (rules.length === 0) h.out("no auto rule: the repo's review unit declares none (auto: [...]), and no Veille names this repo")
|
|
1912
2153
|
const now = Date.now()
|
|
1913
|
-
const ago = (t: number): string => `${Math.round(Math.abs(now - t) / 60_000)} min`
|
|
1914
2154
|
for (const r of rules) {
|
|
1915
2155
|
const log = readAutoLog(h.dir, r.id)
|
|
1916
2156
|
const next = nextRun(r, log, now)
|
|
1917
2157
|
h.out(
|
|
1918
|
-
`${r.id} every ${r.every} ${log ? `ran ${
|
|
1919
|
-
`${log?.lastRaised ? ` last item ${log.lastRaised.id}` : ''} next ${next <= now ? 'due now' : `in ${
|
|
2158
|
+
`${r.id} every ${r.every} ${log ? `ran ${ageWords(Date.parse(log.at), now)} (${log.ms.toFixed(1)} ms): ${log.answer}${log.error ? `: ${log.error}` : ''}` : 'never ran'}` +
|
|
2159
|
+
`${log?.lastRaised ? ` last item ${log.lastRaised.id}` : ''} next ${next <= now ? 'due now' : `in ${ageWords(now, next, { short: true })}`}`,
|
|
1920
2160
|
)
|
|
1921
2161
|
}
|
|
1922
2162
|
if (rules.length > 0) h.out(`logs: ${autoLogDir(h.dir)}; the hub's daemon runs them`)
|
|
@@ -1946,191 +2186,322 @@ export class ReviewWatchCommand extends Command {
|
|
|
1946
2186
|
static override usage = Command.Usage({
|
|
1947
2187
|
category: 'Review',
|
|
1948
2188
|
description: 'one line per verdict, reply or raised note as it lands; every unseen one first; ends with its owner',
|
|
1949
|
-
details: `${DETAILS}\n\nRun it under a monitor, unfiltered (a grep holds a burst's last line). It registers itself, so the hub shows who listens. It exits within 2 s once a process above it at start is gone or nothing reads its output. An item nobody takes prints 2 minutes after its last message, then every 2 hours.`,
|
|
1950
|
-
examples: [
|
|
2189
|
+
details: `${DETAILS}\n\nRun it under a monitor, unfiltered (a grep holds a burst's last line). It registers itself, so the hub shows who listens. It exits within 2 s once a process above it at start is gone or nothing reads its output. An item nobody takes prints 2 minutes after its last message, then every 2 hours.\n\n--house: one watch for every repo where the session holds threads, each line headed [<repo>]; it reads the session's record every 2 s, so a repo where it takes a thread later joins with no restart, and the inbox hook counts it as the session's watch in every repo.`,
|
|
2190
|
+
examples: [
|
|
2191
|
+
['the threads this session holds', 'sk thread watch --mine'],
|
|
2192
|
+
['the threads this session holds, in every repo', 'sk thread watch --mine --house'],
|
|
2193
|
+
["one lane's items", 'sk thread watch --lane interaction'],
|
|
2194
|
+
],
|
|
1951
2195
|
})
|
|
1952
2196
|
mine = Option.Boolean('--mine', false, { description: "only the threads this Claude Code session holds" })
|
|
1953
2197
|
session = Option.String('--session', { description: "only the threads that session holds" })
|
|
1954
2198
|
lane = Option.String('--lane', { description: "only that lane's items" })
|
|
2199
|
+
house = Option.Boolean('--house', false, { description: 'with --mine or --session: every repo where the session holds threads, one joined later too, each line headed [<repo>]' })
|
|
1955
2200
|
|
|
1956
2201
|
async execute(): Promise<number> {
|
|
1957
2202
|
return run(this.context, async (h) => {
|
|
1958
|
-
const {
|
|
1959
|
-
const {
|
|
1960
|
-
const {
|
|
1961
|
-
const { AGENT_RE, coversCard, laneOf, UNTAKEN_AGAIN_MS, untakenOf } = await import('../review/model.ts')
|
|
1962
|
-
const { followedIds, unseen } = await import('../review/threads.ts')
|
|
1963
|
-
const { raisedLine, untakenLine, watchLines } = await import('../review/format.ts')
|
|
1964
|
-
const { exitWithOwner, liveWatchers, registerWatch } = await import('../review/watchers.ts')
|
|
2203
|
+
const { AGENT_RE } = await import('../review/model.ts')
|
|
2204
|
+
const { exitWithOwner, liveWatchers } = await import('../review/watchers.ts')
|
|
2205
|
+
const { sessionId } = await import('../review/store.ts')
|
|
1965
2206
|
const session = await sessionOf(this.mine, this.session)
|
|
1966
2207
|
// --mine under SK_AGENT is that lane's watch: a lane shares its session's id, its name tells them apart
|
|
1967
|
-
const lane = this.lane?.trim() || (this.mine ?
|
|
2208
|
+
const lane = this.lane?.trim() || (this.mine ? callerLane(undefined) : null)
|
|
1968
2209
|
if (lane !== null && !AGENT_RE.test(lane)) throw new Error(`--lane: « ${lane} » is no lane id (${AGENT_RE.source})`)
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
// who hears what: the registry, read again every 30 s, so a lane's threads reach its session's watch once it ends
|
|
1972
|
-
const { noteHanded, readParties, repoNameOf } = await import('../agent-time/registry.ts')
|
|
1973
|
-
const { laneAsksFor, resumeOf } = await import('../review/inbox-read.ts')
|
|
1974
|
-
const { dirname } = await import('node:path')
|
|
1975
|
-
const { sessionId } = await import('../review/store.ts')
|
|
1976
|
-
const by = sessionId()
|
|
1977
|
-
let parties: import('../review/parties.ts').Parties | null = null
|
|
1978
|
-
const mine = (x: Parameters<typeof coversCard>[1]): boolean => hears({ session, lane }, x, byItem, parties)
|
|
2210
|
+
// a house watch follows one session's record: an unfiltered one would hear every thread of every repo
|
|
2211
|
+
if (this.house && session === null) throw new Error('--house hears the threads of one session in every repo it holds them in: with --mine, or --session <id>')
|
|
1979
2212
|
if (session === null && lane === null) {
|
|
1980
2213
|
const { bareWatchTaken } = await import('../review/model.ts')
|
|
1981
2214
|
const taken = bareWatchTaken(liveWatchers(h.dir), process.pid)
|
|
1982
2215
|
if (taken !== null) throw new Error(taken)
|
|
1983
2216
|
}
|
|
1984
|
-
const
|
|
1985
|
-
// before any await: a pull that hangs never keeps a watch alive past its owner
|
|
2217
|
+
const by = sessionId()
|
|
2218
|
+
// before any await of a store: a pull that hangs never keeps a watch alive past its owner
|
|
1986
2219
|
exitWithOwner()
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
const me = lane !== null && by !== null ? parties.lanes.filter((l) => l.name === lane && l.session === by) : []
|
|
1995
|
-
if (me.length > 0 && !me.some((l) => l.live)) {
|
|
1996
|
-
h.err(`review watch: exits, its lane ${lane} ended: its threads pass to its session`)
|
|
1997
|
-
process.exit(0)
|
|
1998
|
-
}
|
|
2220
|
+
await restartWatchOnModelMove(h)
|
|
2221
|
+
// the one stream for every store this watch hears, its own lines untagged
|
|
2222
|
+
await watchFeed(h.err)
|
|
2223
|
+
const f = { session, lane, by, house: this.house }
|
|
2224
|
+
if (!this.house || session === null) {
|
|
2225
|
+
await hearStore(h, f)
|
|
2226
|
+
return new Promise<number>(() => {})
|
|
1999
2227
|
}
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
const
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
const
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
const why = (e as Error).message.split('\n')[0] ?? ''
|
|
2013
|
-
if (refused === null) h.err(`review: WARN the store does not read now (${why}): this watch reads again at its next poll`)
|
|
2014
|
-
refused = why
|
|
2015
|
-
}
|
|
2228
|
+
// one process, one loop a store: the store it starts in, then each one the session's record names
|
|
2229
|
+
const { noteSession, repoNameOf } = await import('../agent-time/registry.ts')
|
|
2230
|
+
const { dirname, resolve } = await import('node:path')
|
|
2231
|
+
noteSession(h.dir)
|
|
2232
|
+
const heard = new Set<string>()
|
|
2233
|
+
const retry = new Map<string, number>()
|
|
2234
|
+
const hear = async (x: Here): Promise<string> => {
|
|
2235
|
+
heard.add(resolve(x.dir))
|
|
2236
|
+
const repo = repoNameOf(dirname(dirname(x.dir)))
|
|
2237
|
+
const tagged = (print: (l: string) => void) => (l: string) => print(l.split('\n').map((y) => `[${repo}] ${y}`).join('\n'))
|
|
2238
|
+
await hearStore({ ...x, out: tagged(h.out), err: tagged(h.err) }, f)
|
|
2239
|
+
return repo
|
|
2016
2240
|
}
|
|
2017
|
-
|
|
2018
|
-
const
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
h.out(l)
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2034
|
-
for (const x of unseen(all.items).filter(mine)) {
|
|
2035
|
-
const fresh = watchLines(x, all.items).filter((l) => !shown.has(l.key))
|
|
2036
|
-
for (const l of fresh) {
|
|
2037
|
-
shown.add(l.key)
|
|
2038
|
-
h.out(l.text)
|
|
2039
|
-
}
|
|
2040
|
-
// a session's watch, his message on its ended lane's thread: the way back to that lane
|
|
2041
|
-
const t = byItem.get(x.item.id)
|
|
2042
|
-
const r = fresh.length > 0 && lane === null && t && parties ? resumeOf(h, t, parties) : null
|
|
2043
|
-
if (r) {
|
|
2044
|
-
h.out(` ${r.line}`)
|
|
2045
|
-
noteHanded(r.lane, r.session, r.thread)
|
|
2241
|
+
let busy = false
|
|
2242
|
+
const more = async (): Promise<string[]> => {
|
|
2243
|
+
if (busy) return []
|
|
2244
|
+
busy = true
|
|
2245
|
+
const joined: string[] = []
|
|
2246
|
+
try {
|
|
2247
|
+
for (const dir of await recordedStores(session, (d) => heard.has(resolve(d)) || (retry.get(resolve(d)) ?? 0) > Date.now())) {
|
|
2248
|
+
try {
|
|
2249
|
+
joined.push(await hear(await hereAt(dir, h.out, h.err)))
|
|
2250
|
+
} catch (e) {
|
|
2251
|
+
// a store that does not open now: said once a minute, read again then
|
|
2252
|
+
retry.set(resolve(dir), Date.now() + 60_000)
|
|
2253
|
+
h.err(`review watch: WARN ${dir} does not open now (${(e as Error).message.split('\n')[0]}): tried again in a minute`)
|
|
2254
|
+
}
|
|
2046
2255
|
}
|
|
2256
|
+
} finally {
|
|
2257
|
+
busy = false
|
|
2047
2258
|
}
|
|
2048
|
-
|
|
2049
|
-
const l = raisedLine(x)
|
|
2050
|
-
if (l === null || shown.has(l.key)) continue
|
|
2051
|
-
shown.add(l.key)
|
|
2052
|
-
h.out(l.text)
|
|
2053
|
-
}
|
|
2054
|
-
// an item nobody takes: a --lane watch hears its own lane's, an unfiltered or --mine watch every one
|
|
2055
|
-
const now = new Date()
|
|
2056
|
-
const followed = followedIds(all.items)
|
|
2057
|
-
const watchers = liveWatchers(h.dir)
|
|
2058
|
-
for (const x of all.items) {
|
|
2059
|
-
if (lane !== null && laneOf(x) !== lane) continue
|
|
2060
|
-
const why = untakenOf(x, followed.has(x.item.id), listenersOf(watchers, x, byItem).length > 0, now, h.say.spec.dispatcher)
|
|
2061
|
-
if (why === null) continue
|
|
2062
|
-
const round = Math.floor((now.getTime() - Date.parse(x.thread.at(-1)?.at ?? x.item.created)) / UNTAKEN_AGAIN_MS)
|
|
2063
|
-
const key = `untaken ${x.item.id} ${why} ${round}`
|
|
2064
|
-
if (shown.has(key)) continue
|
|
2065
|
-
shown.add(key)
|
|
2066
|
-
h.out(untakenLine(x, why, lane))
|
|
2067
|
-
}
|
|
2259
|
+
return joined
|
|
2068
2260
|
}
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
setInterval(
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2261
|
+
const first = [await hear(h), ...(await more())]
|
|
2262
|
+
h.err(`review watch: hears ${first.join(', ')}; a repo where this session takes a thread joins within 2 s`)
|
|
2263
|
+
setInterval(
|
|
2264
|
+
() =>
|
|
2265
|
+
void more()
|
|
2266
|
+
.then((js) => js.forEach((r) => h.err(`review watch: hears ${r} too`)))
|
|
2267
|
+
.catch(() => {}),
|
|
2268
|
+
2000,
|
|
2269
|
+
)
|
|
2270
|
+
return new Promise<number>(() => {})
|
|
2271
|
+
})
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
/** a watch outlives a change of the thread model: once a read fails on an item the new model wrote, it runs again with
|
|
2276
|
+
* its args, same pid, onto code that loads (review/model-moved.ts) */
|
|
2277
|
+
async function restartWatchOnModelMove(h: Here): Promise<void> {
|
|
2278
|
+
const { modelWatch, MODEL_FILE } = await import('../review/model-moved.ts')
|
|
2279
|
+
modelWatch.onMove(async (why) => {
|
|
2280
|
+
const { bootEntries, probeLoad } = await import('../core/load-probe.ts')
|
|
2281
|
+
const { OWN_LIB } = await import('../core/last-good.ts')
|
|
2282
|
+
const { join } = await import('node:path')
|
|
2283
|
+
const a = await probeLoad(OWN_LIB, [...bootEntries(OWN_LIB), MODEL_FILE, join(OWN_LIB, 'src/review/store.ts')])
|
|
2284
|
+
if (!a.ok) {
|
|
2285
|
+
h.err(`review watch: WARN ${why}, and ${a.file} fails to load (${a.error}): this watch keeps its model until it loads`)
|
|
2286
|
+
return false
|
|
2287
|
+
}
|
|
2288
|
+
h.err(`review watch: ${why}: it runs again with its args`)
|
|
2289
|
+
const { reexecSelf } = await import('../core/reexec.ts')
|
|
2290
|
+
return reexecSelf()
|
|
2291
|
+
})
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
/** one store heard by a watch of filter `f`, until the process ends: registered beside it, its lines printed through `h` */
|
|
2295
|
+
async function hearStore(h: Here, f: { session: string | null; lane: string | null; by: string | null; house: boolean }): Promise<void> {
|
|
2296
|
+
const { session, lane, by } = f
|
|
2297
|
+
const { existsSync, mkdirSync, watch } = await import('node:fs')
|
|
2298
|
+
const { mediaDir, readAll, scanStamp } = await import('../review/store.ts')
|
|
2299
|
+
const { modelWatch } = await import('../review/model-moved.ts')
|
|
2300
|
+
const { threadsInDb } = await import('../hq/switch.ts')
|
|
2301
|
+
const { coversItem, laneOf, UNTAKEN_AGAIN_MS, untakenOf } = await import('../review/model.ts')
|
|
2302
|
+
const { followedIds, unseen } = await import('../review/threads.ts')
|
|
2303
|
+
const { raisedLine, untakenLine, watchLines } = await import('../review/format.ts')
|
|
2304
|
+
const { liveWatchers, registerWatch } = await import('../review/watchers.ts')
|
|
2305
|
+
const { hears, holderOf, listenersOf, threadByItem, threadsOf, wordReaches } = await import('../review/threads.ts')
|
|
2306
|
+
let byItem = new Map<string, import('../review/threads.ts').Thread>()
|
|
2307
|
+
// who hears what: the registry, read again every 30 s, so a lane's threads reach its session's watch once it ends
|
|
2308
|
+
const { noteHanded, readParties, repoNameOf } = await import('../agent-time/registry.ts')
|
|
2309
|
+
const { laneAsksFor, resumeOf } = await import('../review/inbox-read.ts')
|
|
2310
|
+
const { dirname } = await import('node:path')
|
|
2311
|
+
let parties: import('../review/parties.ts').Parties | null = null
|
|
2312
|
+
const mine = (x: Parameters<typeof coversItem>[1]): boolean => hears({ session, lane }, x, byItem, parties)
|
|
2313
|
+
// the owner's words that name another agent are that agent's (wiki tools/shipkit/threads-how-it-fits.md, Mentions)
|
|
2314
|
+
const to = (x: Parameters<typeof coversItem>[1], m: import('../review/model.ts').Message): boolean => wordReaches({ session, lane }, x, m, byItem, parties)
|
|
2315
|
+
const beat = registerWatch(h.dir, { session, lane }, new Date(), by, f.house)
|
|
2316
|
+
setInterval(() => beat(), 10_000)
|
|
2317
|
+
const known = async (): Promise<void> => {
|
|
2318
|
+
if (session === null && lane === null) return
|
|
2319
|
+
const all = readAll(h.dir)
|
|
2320
|
+
const ids = new Set(threadsOf(all.items, h.say.spec).flatMap((t) => [...(t.head.item.origin.by === 'agent' && t.head.item.origin.session ? [t.head.item.origin.session] : []), ...(holderOf(t)?.session ?? [])]))
|
|
2321
|
+
parties = await readParties({ sessions: [...ids, ...(session ? [session] : [])], watchers: liveWatchers(h.dir), self: by })
|
|
2322
|
+
// a lane's watch ends with its lane: its threads pass to its session, whose hook or watch hears them
|
|
2323
|
+
const me = lane !== null && by !== null ? parties.lanes.filter((l) => l.name === lane && l.session === by) : []
|
|
2324
|
+
if (me.length > 0 && !me.some((l) => l.live)) {
|
|
2325
|
+
h.err(`review watch: exits, its lane ${lane} ended: its threads pass to its session`)
|
|
2326
|
+
process.exit(0)
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
await known().catch(() => {})
|
|
2330
|
+
setInterval(() => void known().catch(() => {}), 30_000)
|
|
2331
|
+
const shown = new Set<string>()
|
|
2332
|
+
// a store refused for a while (a fold or a way back of the daemon file walks): one line, and the next poll
|
|
2333
|
+
// reads again; never a watch that dies and hears nothing more
|
|
2334
|
+
let refused: string | null = null
|
|
2335
|
+
const safely = (fn: () => void): void => {
|
|
2336
|
+
try {
|
|
2337
|
+
fn()
|
|
2338
|
+
if (refused !== null) h.err(`review: ok, the store reads again: this watch goes on`)
|
|
2339
|
+
refused = null
|
|
2340
|
+
} catch (e) {
|
|
2341
|
+
const why = (e as Error).message.split('\n')[0] ?? ''
|
|
2342
|
+
if (refused === null) h.err(`review: WARN the store does not read now (${why}): this watch reads again at its next poll`)
|
|
2343
|
+
refused = why
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
const tick = (): void => safely(read)
|
|
2347
|
+
const read = (): void => {
|
|
2348
|
+
const all = readAll(h.dir)
|
|
2349
|
+
// the model moved under this watch: it runs again, and its broken lines are the old model's
|
|
2350
|
+
if (all.broken.length > 0 && modelWatch.readFailed()) return
|
|
2351
|
+
byItem = threadByItem(threadsOf(all.items, h.say.spec))
|
|
2352
|
+
for (const b of all.broken) {
|
|
2353
|
+
const key = `broken ${b.id} ${b.error}`
|
|
2354
|
+
if (!shown.has(key)) h.err(`review: FAIL ${b.id}: ${b.error}`)
|
|
2355
|
+
shown.add(key)
|
|
2356
|
+
}
|
|
2357
|
+
// his request for a lane, first: a session's watch (or a bare one) is the orchestrator's ear
|
|
2358
|
+
if (lane === null && (parties !== null || session === null)) {
|
|
2359
|
+
for (const l of laneAsksFor({ repo: repoNameOf(dirname(dirname(h.dir))), root: dirname(dirname(h.dir)), dir: h.dir, here: true, ...all, say: h.say }, { session, lane: null }, parties ?? { sessions: [], lanes: [] })) {
|
|
2360
|
+
if (shown.has(l)) continue
|
|
2361
|
+
shown.add(l)
|
|
2362
|
+
h.out(l)
|
|
2082
2363
|
}
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
if (!cardsInDb()) again()
|
|
2090
|
-
})
|
|
2364
|
+
}
|
|
2365
|
+
for (const x of unseen(all.items, to).filter(mine)) {
|
|
2366
|
+
const fresh = watchLines(x, all.items, mediaDir(h.dir), to).filter((l) => !shown.has(l.key))
|
|
2367
|
+
for (const l of fresh) {
|
|
2368
|
+
shown.add(l.key)
|
|
2369
|
+
h.out(l.text)
|
|
2091
2370
|
}
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
if (
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2371
|
+
// a session's watch, his message on its ended lane's thread: the way back to that lane
|
|
2372
|
+
const t = byItem.get(x.item.id)
|
|
2373
|
+
const r = fresh.length > 0 && lane === null && t && parties ? resumeOf(h, t, parties) : null
|
|
2374
|
+
if (r) {
|
|
2375
|
+
h.out(` ${r.line}`)
|
|
2376
|
+
noteHanded(r.lane, r.session, r.thread)
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
for (const x of all.items.filter(mine)) {
|
|
2380
|
+
const l = raisedLine(x)
|
|
2381
|
+
if (l === null || shown.has(l.key)) continue
|
|
2382
|
+
shown.add(l.key)
|
|
2383
|
+
h.out(l.text)
|
|
2384
|
+
}
|
|
2385
|
+
// an item nobody takes: a --lane watch hears its own lane's, an unfiltered or --mine watch every one
|
|
2386
|
+
const now = new Date()
|
|
2387
|
+
const followed = followedIds(all.items)
|
|
2388
|
+
const watchers = liveWatchers(h.dir)
|
|
2389
|
+
for (const x of all.items) {
|
|
2390
|
+
if (lane !== null && laneOf(x) !== lane) continue
|
|
2391
|
+
const why = untakenOf(x, followed.has(x.item.id), listenersOf(watchers, x, byItem).length > 0, now, h.say.spec.dispatcher)
|
|
2392
|
+
if (why === null) continue
|
|
2393
|
+
const round = Math.floor((now.getTime() - Date.parse(x.thread.at(-1)?.at ?? x.item.created)) / UNTAKEN_AGAIN_MS)
|
|
2394
|
+
const key = `untaken ${x.item.id} ${why} ${round}`
|
|
2395
|
+
if (shown.has(key)) continue
|
|
2396
|
+
shown.add(key)
|
|
2397
|
+
h.out(untakenLine(x, why, lane))
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
tick()
|
|
2401
|
+
// the grace and the reminder pass with time alone: one read a minute
|
|
2402
|
+
setInterval(tick, 60_000)
|
|
2403
|
+
// the store the switch names, read again at each poll (a process reads the switch at most once a second), so a
|
|
2404
|
+
// watch follows a move while it runs. The rows: their stamp is a query of a few µs, asked every 50 ms, read at
|
|
2405
|
+
// once. The files: a watch of the folder asks again (debounced), and a stat stamp every 5 s catches a missed event
|
|
2406
|
+
let soon: ReturnType<typeof setTimeout> | null = null
|
|
2407
|
+
const again = (): void => {
|
|
2408
|
+
if (soon) clearTimeout(soon)
|
|
2409
|
+
soon = setTimeout(() => {
|
|
2410
|
+
soon = null
|
|
2411
|
+
tick()
|
|
2412
|
+
}, threadsInDb() ? 0 : 150)
|
|
2413
|
+
}
|
|
2414
|
+
// the store's own poll, for a watch the daemon's stream does not feed: no home, a store it serves no hub for, a
|
|
2415
|
+
// daemon that does not answer (review/watch-feed.ts)
|
|
2416
|
+
let polling = false
|
|
2417
|
+
let folderWatched = false
|
|
2418
|
+
const watchFolder = (): void => {
|
|
2419
|
+
if (folderWatched) return
|
|
2420
|
+
folderWatched = true
|
|
2421
|
+
if (!existsSync(h.dir)) mkdirSync(h.dir, { recursive: true })
|
|
2422
|
+
watch(h.dir, { recursive: true }, () => {
|
|
2423
|
+
if (polling && !threadsInDb()) again()
|
|
2116
2424
|
})
|
|
2117
2425
|
}
|
|
2426
|
+
let stamp = ''
|
|
2427
|
+
let scanned = Date.now()
|
|
2428
|
+
let loop: ReturnType<typeof setInterval> | null = null
|
|
2429
|
+
const poll = (on: boolean): void => {
|
|
2430
|
+
polling = on
|
|
2431
|
+
if (!on) {
|
|
2432
|
+
if (loop) clearInterval(loop)
|
|
2433
|
+
loop = null
|
|
2434
|
+
return
|
|
2435
|
+
}
|
|
2436
|
+
if (loop) return
|
|
2437
|
+
if (!threadsInDb()) watchFolder()
|
|
2438
|
+
stamp = ''
|
|
2439
|
+
loop = setInterval(() => {
|
|
2440
|
+
const rows = threadsInDb()
|
|
2441
|
+
// the files' stamp walks every item: once every 5 s, never at the rows' pace
|
|
2442
|
+
if (!rows) {
|
|
2443
|
+
watchFolder()
|
|
2444
|
+
if (Date.now() - scanned < 5000) return
|
|
2445
|
+
}
|
|
2446
|
+
scanned = Date.now()
|
|
2447
|
+
// a refused stamp, or one read again after a refusal: the read says it, once
|
|
2448
|
+
try {
|
|
2449
|
+
const now = scanStamp(h.dir)
|
|
2450
|
+
if (now !== stamp || refused !== null) again()
|
|
2451
|
+
stamp = now
|
|
2452
|
+
} catch {
|
|
2453
|
+
again()
|
|
2454
|
+
}
|
|
2455
|
+
}, 50)
|
|
2456
|
+
}
|
|
2457
|
+
// the sources: pulled now and every 30 s, a new item lands and the tick prints it
|
|
2458
|
+
await pull(h)
|
|
2459
|
+
if (h.unit?.sources?.length) setInterval(() => void pull(h), 30_000)
|
|
2460
|
+
const feed = await watchFeed(h.err)
|
|
2461
|
+
if (feed === null) return poll(true)
|
|
2462
|
+
// a daemon down is said once for the whole watch by the feed; a store it serves no hub for, once here
|
|
2463
|
+
let saidAlone = false
|
|
2464
|
+
feed.hear(h.dir, {
|
|
2465
|
+
moved: again,
|
|
2466
|
+
push: () => {
|
|
2467
|
+
poll(false)
|
|
2468
|
+
again()
|
|
2469
|
+
},
|
|
2470
|
+
poll: (why) => {
|
|
2471
|
+
if (why !== null && !saidAlone) h.err(`review watch: ${why}: this watch reads the store itself`)
|
|
2472
|
+
if (why !== null) saidAlone = true
|
|
2473
|
+
poll(true)
|
|
2474
|
+
},
|
|
2475
|
+
})
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
/** the one stream of the daemon's store moves this process hears, null where no home runs (SHIPKIT_NO_HOME, CI, a
|
|
2479
|
+
* machine with none): a watch then polls its store */
|
|
2480
|
+
let feedHeld: import('../review/watch-feed.ts').WatchFeed | null | undefined
|
|
2481
|
+
/** `say`: the watch's own line, untagged: the first caller's, the command's before any store */
|
|
2482
|
+
async function watchFeed(say: (l: string) => void): Promise<import('../review/watch-feed.ts').WatchFeed | null> {
|
|
2483
|
+
if (feedHeld !== undefined) return feedHeld
|
|
2484
|
+
const set = (v: string | undefined): boolean => v != null && v !== ''
|
|
2485
|
+
const { homeWanted } = await import('../home/home-start.ts')
|
|
2486
|
+
if (set(process.env.SHIPKIT_NO_HOME) || set(process.env.CI) || !homeWanted()) return (feedHeld = null)
|
|
2487
|
+
const { daemonUrl } = await import('../home/home-paths.ts')
|
|
2488
|
+
const { WatchFeed } = await import('../review/watch-feed.ts')
|
|
2489
|
+
return (feedHeld = new WatchFeed(daemonUrl(), { say }))
|
|
2118
2490
|
}
|
|
2119
2491
|
|
|
2120
2492
|
/** the review folders of this machine's house, its archived repos included: what a move carries */
|
|
2121
2493
|
async function houseStores(): Promise<string[]> {
|
|
2122
2494
|
const { findRepoRoot } = await import('../ts/config.ts')
|
|
2123
|
-
const { houseRepos } = await import('../
|
|
2495
|
+
const { houseRepos } = await import('../house/project-gutter.ts')
|
|
2124
2496
|
const { homedir } = await import('node:os')
|
|
2125
2497
|
const { storeDir } = await import('../review/store.ts')
|
|
2126
2498
|
const house = houseRepos(findRepoRoot(process.cwd()), homedir())
|
|
2127
2499
|
if (house.index == null) throw new Error(`${process.cwd()} is in no house repo: run it from the house checkout, whose repos it moves`)
|
|
2128
2500
|
const { existsSync } = await import('node:fs')
|
|
2129
2501
|
const repos = [...house.repos, ...house.archived].map((r) => r.path)
|
|
2130
|
-
// a lane's worktree holds the
|
|
2502
|
+
// a lane's worktree holds the items it sent there: they join their repo's rows
|
|
2131
2503
|
const trees = repos.flatMap((r) => {
|
|
2132
|
-
|
|
2133
|
-
return (p.stdout?.toString() ?? '').split('\n').flatMap((l) => (l.startsWith('worktree ') && l.slice(9) !== r ? [l.slice(9)] : []))
|
|
2504
|
+
return realGit.runSync(r, ['worktree', 'list', '--porcelain']).out.split('\n').flatMap((l) => (l.startsWith('worktree ') && l.slice(9) !== r ? [l.slice(9)] : []))
|
|
2134
2505
|
})
|
|
2135
2506
|
return [...repos, ...trees.filter((t) => existsSync(storeDir(t)))].map((r) => storeDir(r))
|
|
2136
2507
|
}
|
|
@@ -2156,17 +2527,16 @@ export class ReviewMoveCommand extends Command {
|
|
|
2156
2527
|
const stores = await houseStores()
|
|
2157
2528
|
const { moveBack, moveGo, tidyFiles } = await import('../review/move.ts')
|
|
2158
2529
|
const dry = !this.go
|
|
2159
|
-
// one move or look of the
|
|
2160
|
-
const {
|
|
2161
|
-
const
|
|
2162
|
-
|
|
2163
|
-
if (!dry && lease == null) throw new Error(`a look of the hq threads job or another move runs (pid ${leaseHolder(cardsLease())?.pid ?? '?'}): run it again once it ended`)
|
|
2530
|
+
// one move or look of the threads job at a time: the job would send what the move is writing
|
|
2531
|
+
const { threadsLeaseHolder, tryThreadsLease } = await import('../hq/thread-sync.ts')
|
|
2532
|
+
const lease = dry ? null : tryThreadsLease('review move')
|
|
2533
|
+
if (!dry && lease == null) throw new Error(`a look of the hq threads job or another move runs (pid ${threadsLeaseHolder()?.pid ?? '?'}): run it again once it ended`)
|
|
2164
2534
|
try {
|
|
2165
2535
|
const r = this.tidy ? await tidyFiles(stores, { dry, proof: await tidyProof(stores) }) : this.back ? await moveBack(stores, { dry }) : await moveGo(stores, { dry, hqDiff: hqDiffOf(stores) })
|
|
2166
2536
|
for (const l of r.lines) (l.startsWith('WARN') ? err : out)(l)
|
|
2167
|
-
const {
|
|
2537
|
+
const { threadsInDb } = await import('../hq/switch.ts')
|
|
2168
2538
|
const { BACK_FIRST } = await import('../review/move.ts')
|
|
2169
|
-
if (
|
|
2539
|
+
if (threadsInDb()) out(BACK_FIRST)
|
|
2170
2540
|
if (dry) out(`a look: nothing ${this.tidy ? 'removed' : 'moved'}. sk thread move ${this.tidy ? '--tidy --go removes' : this.back ? '--back --go moves' : '--go moves'}`)
|
|
2171
2541
|
return r.ok ? 0 : 1
|
|
2172
2542
|
} finally {
|
|
@@ -2182,18 +2552,18 @@ export class ReviewMoveCommand extends Command {
|
|
|
2182
2552
|
/** what the tidy proves outside the store: the names of each repo's rows the hq lacks or holds at another rev (the
|
|
2183
2553
|
* check hq-cards, the hq asked once), and the Space's word on each file */
|
|
2184
2554
|
async function tidyProof(stores: readonly string[]): Promise<import('../review/move.ts').TidyProof> {
|
|
2185
|
-
const {
|
|
2555
|
+
const { threadsDiff, threadsOn, heldRepos } = await import('../hq/thread-sync.ts')
|
|
2186
2556
|
const { confirmedUp } = await import('../media-store/remote.ts')
|
|
2187
2557
|
const up = (key: string, size: number): Promise<boolean> => confirmedUp(key, size)
|
|
2188
|
-
if (!
|
|
2558
|
+
if (!threadsOn()) return { hqLacks: async () => ({ refused: 'the switch hq-cards is off: no hq holds them' }), up }
|
|
2189
2559
|
const { myHq } = await import('../hq/hq-local.ts')
|
|
2190
2560
|
const hq = myHq()
|
|
2191
2561
|
if ('refused' in hq) return { hqLacks: async () => ({ refused: `the hq is not reached (${hq.refused})` }), up }
|
|
2192
2562
|
const { dirname } = await import('node:path')
|
|
2193
2563
|
const { held, left } = await heldRepos(stores.map((d) => ({ name: d, path: dirname(dirname(d)) })))
|
|
2194
|
-
const diff = await
|
|
2564
|
+
const diff = await threadsDiff(hq, held)
|
|
2195
2565
|
if ('refused' in diff) return { hqLacks: async () => ({ refused: `the hq refused the check: ${diff.refused}` }), up }
|
|
2196
|
-
const { repoIdOf } = await import('../review/
|
|
2566
|
+
const { repoIdOf } = await import('../review/item-db.ts')
|
|
2197
2567
|
const byRepo = new Map(diff.map((d) => [d.repo, new Set([...d.onlyHere, ...d.differ])]))
|
|
2198
2568
|
return {
|
|
2199
2569
|
hqLacks: async (dir) => {
|
|
@@ -2209,14 +2579,14 @@ async function tidyProof(stores: readonly string[]): Promise<import('../review/m
|
|
|
2209
2579
|
* proof that nothing it leaves behind is missing elsewhere. Null with the switch off */
|
|
2210
2580
|
function hqDiffOf(stores: readonly string[]): () => Promise<string[] | null> {
|
|
2211
2581
|
return async () => {
|
|
2212
|
-
const {
|
|
2213
|
-
if (!
|
|
2582
|
+
const { threadsDiff, threadsOn, heldRepos } = await import('../hq/thread-sync.ts')
|
|
2583
|
+
if (!threadsOn()) return null
|
|
2214
2584
|
const { myHq } = await import('../hq/hq-local.ts')
|
|
2215
2585
|
const hq = myHq()
|
|
2216
2586
|
if ('refused' in hq) return [`the hq is not reached (${hq.refused}): the check hq-cards cannot prove both sides equal`]
|
|
2217
2587
|
const { dirname } = await import('node:path')
|
|
2218
2588
|
const { held } = await heldRepos(stores.map((d) => ({ name: d, path: dirname(dirname(d)) })))
|
|
2219
|
-
const diff = await
|
|
2589
|
+
const diff = await threadsDiff(hq, held)
|
|
2220
2590
|
if ('refused' in diff) return [`the hq refused the check: ${diff.refused}`]
|
|
2221
2591
|
return diff.flatMap((d) => (d.onlyHere.length + d.onlyHq.length + d.differ.length === 0 ? [] : [`${d.repo}: ${d.onlyHere.length} only here, ${d.onlyHq.length} only in the hq, ${d.differ.length} at two revs (${[...d.onlyHere, ...d.onlyHq, ...d.differ].slice(0, 3).join(', ')})`]))
|
|
2222
2592
|
}
|
|
@@ -2236,24 +2606,24 @@ export class ReviewExportCommand extends Command {
|
|
|
2236
2606
|
|
|
2237
2607
|
async execute(): Promise<number> {
|
|
2238
2608
|
return run(this.context, async (h) => {
|
|
2239
|
-
const {
|
|
2609
|
+
const { threadsInDb } = await import('../hq/switch.ts')
|
|
2240
2610
|
const { resolve } = await import('node:path')
|
|
2241
2611
|
if (this.all === this.ids.length > 0) throw new Error('give item ids or --all')
|
|
2242
2612
|
const to = resolve(this.to)
|
|
2243
2613
|
if (to === resolve(h.dir)) throw new Error(`--to ${this.to}: the store itself; sk thread move --back --go writes the rows into the store`)
|
|
2244
2614
|
const ids = this.all ? undefined : await Promise.all(this.ids.map((r) => idOf(h.dir, r)))
|
|
2245
2615
|
let r: import('../review/move.ts').Moved
|
|
2246
|
-
if (
|
|
2616
|
+
if (threadsInDb()) r = (await import('../review/move.ts')).exportRows(h.dir, { to, ...(ids ? { ids } : {}) })
|
|
2247
2617
|
else {
|
|
2248
2618
|
// the files are the store: a copy of each folder is the export
|
|
2249
2619
|
const { cpSync, existsSync } = await import('node:fs')
|
|
2250
|
-
const {
|
|
2620
|
+
const { itemIds } = await import('../review/store.ts')
|
|
2251
2621
|
const { join } = await import('node:path')
|
|
2252
|
-
const want = ids ??
|
|
2622
|
+
const want = ids ?? itemIds(h.dir)
|
|
2253
2623
|
for (const id of want) if (!existsSync(join(to, id))) cpSync(join(h.dir, id), join(to, id), { recursive: true })
|
|
2254
|
-
r = { dir: h.dir,
|
|
2624
|
+
r = { dir: h.dir, items: want.length, heads: want.length, msgs: 0, gone: 0, same: 0, files: 0, kept: [], broken: [], read: [] }
|
|
2255
2625
|
}
|
|
2256
|
-
h.out(`review: ${r.
|
|
2626
|
+
h.out(`review: ${r.items} items written into ${to} (${r.heads} heads, ${r.msgs} messages${r.media ? `, ${r.media.copied} media files` : ''})`)
|
|
2257
2627
|
for (const k of r.kept) h.out(` kept: ${k}`)
|
|
2258
2628
|
for (const b of r.broken) h.err(` does not read: ${b}`)
|
|
2259
2629
|
if (r.media && r.media.missing.length > 0) h.out(` ${r.media.missing.length} media files this machine no longer holds (the Space has them by their key in the head): ${r.media.missing.slice(0, 5).join(', ')}`)
|
|
@@ -2376,8 +2746,8 @@ export class ThreadAttachCommand extends Command {
|
|
|
2376
2746
|
static override paths = [['thread', 'attach']]
|
|
2377
2747
|
static override usage = Command.Usage({
|
|
2378
2748
|
category: 'Review',
|
|
2379
|
-
description: '
|
|
2380
|
-
details: `${DETAILS}\n\
|
|
2749
|
+
description: 'link one more object to a thread, never its own address: that object then finds the thread',
|
|
2750
|
+
details: `${DETAILS}\n\nThe thread is its address or an id. The object's thread control then finds the thread. A link: many threads may link one object. Page: wiki tools/shipkit/threads.md`,
|
|
2381
2751
|
examples: [['link a media', 'sk thread attach 20261119-233610-trailer-v15 media:thumbnail-v3']],
|
|
2382
2752
|
})
|
|
2383
2753
|
thread = Option.String()
|
|
@@ -2396,7 +2766,11 @@ export class ThreadAttachCommand extends Command {
|
|
|
2396
2766
|
// a kind with actions of its own (a reflection: accept, rework, discard): they are the owner's answer on the link
|
|
2397
2767
|
const { HOUSE_KINDS } = await import('../review/kinds.ts')
|
|
2398
2768
|
const k = a.slice(0, a.indexOf(':'))
|
|
2399
|
-
|
|
2769
|
+
const kind = specOf(h.dir).kinds[k] ?? HOUSE_KINDS[k]
|
|
2770
|
+
if (Object.keys(kind?.actions ?? {}).length > 0) throw new Error(`attach ${a} --verdict: the kind ${k} declares its own actions, which are the owner's answer on the link; attach it without --verdict`)
|
|
2771
|
+
// a draft is settled by what he does with it (publish, drop), never approved
|
|
2772
|
+
// only the house kinds' acts are read (review/settle.ts): a repo's own kind keeps the verdict
|
|
2773
|
+
if (!(k in specOf(h.dir).kinds) && Object.keys(kind?.acts ?? {}).length > 0) throw new Error(`attach ${a} --verdict: the kind ${k} is answered by its own acts (${Object.values(kind!.acts!).map((x) => x.label).join(', ')}), never a verdict${k === 'draft' ? '; show it here with sk social draft save <slug> <file|-> --thread <this thread>' : ''}`)
|
|
2400
2774
|
}
|
|
2401
2775
|
attachTo(h.dir, id, actor(this.as, false, 'attach'), this.address, new Date(), this.verdict ? { asksVerdict: true } : {})
|
|
2402
2776
|
h.out(`${id} links ${this.address}${this.verdict ? ", waiting for the owner's verdict" : ''}`)
|
|
@@ -2424,16 +2798,16 @@ export class ReviewMigrateCommand extends Command {
|
|
|
2424
2798
|
const { dirname } = await import('node:path')
|
|
2425
2799
|
const { openReview } = await import('../review/project.ts')
|
|
2426
2800
|
const { foldStore } = await import('../review/thread-fold.ts')
|
|
2427
|
-
const { repoIdOf } = await import('../review/
|
|
2428
|
-
const {
|
|
2801
|
+
const { repoIdOf } = await import('../review/item-db.ts')
|
|
2802
|
+
const { threadsInDb } = await import('../hq/switch.ts')
|
|
2429
2803
|
const { existsSync } = await import('node:fs')
|
|
2430
2804
|
const dirs = this.all ? await houseStores() : [h.dir]
|
|
2431
2805
|
const seen = new Set<string>()
|
|
2432
2806
|
const stores = dirs.filter((d) => {
|
|
2433
|
-
const key =
|
|
2807
|
+
const key = threadsInDb() ? repoIdOf(d) : d
|
|
2434
2808
|
if (seen.has(key)) return false
|
|
2435
2809
|
seen.add(key)
|
|
2436
|
-
return
|
|
2810
|
+
return threadsInDb() || existsSync(d)
|
|
2437
2811
|
})
|
|
2438
2812
|
const plans = []
|
|
2439
2813
|
for (const d of stores) {
|