rvlib-shipkit 2.31.0 → 2.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/package.json +1 -1
- package/src/advisors/acts.ts +16 -15
- package/src/advisors/advice.ts +56 -102
- package/src/advisors/advisor-view.ts +98 -73
- package/src/advisors/app-graph.ts +1 -1
- package/src/advisors/app.ts +3 -11
- package/src/advisors/cf-api.ts +1 -1
- package/src/advisors/dir-bucket.ts +4 -3
- package/src/advisors/edge/api.ts +26 -198
- package/src/advisors/edge/bucket.ts +2 -2
- package/src/advisors/edge/handler.ts +13 -155
- package/src/advisors/edge/here.ts +5 -5
- package/src/advisors/edge/pages.ts +12 -9
- package/src/advisors/edge/shell.ts +6 -5
- package/src/advisors/edge/sign-in.ts +101 -36
- package/src/advisors/edge/status.ts +19 -6
- package/src/advisors/edge/types.ts +36 -60
- package/src/advisors/expose.ts +29 -29
- package/src/advisors/here.ts +12 -12
- package/src/advisors/invite-send.ts +79 -35
- package/src/advisors/invite.ts +31 -8
- package/src/advisors/job.ts +24 -16
- package/src/advisors/login.ts +40 -15
- package/src/advisors/owner-store.ts +46 -22
- package/src/advisors/photos.ts +3 -3
- package/src/advisors/project.ts +25 -23
- package/src/advisors/reach.ts +89 -0
- package/src/advisors/rights.ts +1 -1
- package/src/advisors/routes.ts +55 -74
- package/src/advisors/scan.ts +0 -4
- package/src/advisors/setup-run.ts +14 -14
- package/src/advisors/share-trace.ts +3 -3
- package/src/advisors/{door-probe.ts → sign-in-probe.ts} +7 -6
- package/src/advisors/speaks.ts +29 -0
- package/src/advisors/sync.ts +92 -182
- package/src/advisors/tunnel.ts +6 -5
- package/src/advisors/users-listen.ts +92 -0
- package/src/advisors/users-router.ts +257 -85
- package/src/advisors/users-store.ts +81 -0
- package/src/agent-time/blocked-scan.ts +181 -0
- package/src/agent-time/registry.ts +12 -5
- package/src/agent-time/store.ts +9 -109
- package/src/asks/ask-bar-fold.ts +2 -1
- package/src/asks/ask-close.ts +2 -1
- package/src/asks/ask-doc.ts +2 -1
- package/src/asks/ask-migrate.ts +3 -2
- package/src/asks/ask-steps-fold.ts +2 -1
- package/src/asks/ask-store.ts +4 -3
- package/src/check.ts +3 -43
- package/src/checks/SK001-package-json-shape.check.ts +4 -55
- package/src/checks/SK004-gitignore-policy.check.ts +24 -69
- package/src/checks/SK013-one-way-in-policy.check.ts +3 -7
- package/src/checks/SK017-vscode-hub-task.check.ts +4 -4
- package/src/checks/SK019-tests-run-in-units.check.ts +3 -14
- package/src/checks/SK020-self-spawning-check.check.ts +5 -7
- package/src/checks/SK035-public-clean.check.ts +1 -1
- package/src/checks/SK039-vscode-watch-generated.check.ts +1 -1
- package/src/checks/SK042-post-kinds.check.ts +5 -14
- package/src/checks/SK054-agent-allow-list.check.ts +5 -74
- package/src/checks/SK055-retired-config-keys.check.ts +45 -0
- package/src/cli/cmd_Advisors.ts +11 -45
- package/src/cli/cmd_Asks.ts +3 -10
- package/src/cli/cmd_Backup.ts +25 -127
- package/src/cli/cmd_BackupTargets.ts +1 -1
- package/src/cli/cmd_Checks.ts +0 -14
- package/src/cli/cmd_Db.ts +3 -82
- package/src/cli/cmd_Home.ts +4 -32
- package/src/cli/cmd_Hq.ts +0 -17
- package/src/cli/cmd_Releases.ts +57 -4
- package/src/cli/cmd_Review.ts +333 -354
- package/src/cli/cmd_SocialDrafts.ts +6 -13
- package/src/cli/cmd_ThreadSyncNeeds.ts +6 -2
- package/src/cli/cmd_Time.ts +1 -1
- package/src/cli/cmd_Trailer.ts +1 -1
- package/src/cli/inbox-hook-run.ts +5 -23
- package/src/cli/registry-heads.ts +5 -55
- package/src/cli/registry.ts +1 -5
- package/src/cli/review-here.ts +1 -1
- package/src/cli.ts +2 -2
- package/src/collections/collection-types.ts +1 -1
- package/src/collections/review.ts +5 -4
- package/src/core/agent-allow-policy.ts +32 -2
- package/src/core/agent-env.ts +8 -0
- package/src/core/allow-rows.ts +74 -0
- package/src/core/check-file-names.ts +19 -106
- package/src/core/footprint.ts +17 -13
- package/src/core/identities-root.ts +1 -4
- package/src/core/layout.ts +1 -2
- package/src/core/machine-db.ts +33 -208
- package/src/core/machine-layout.ts +14 -127
- package/src/core/mask-source.ts +60 -0
- package/src/core/memory-watch.ts +17 -14
- package/src/core/motherhome.ts +8 -35
- package/src/core/one-way-in-policy.ts +0 -3
- package/src/core/repo-walk.ts +0 -9
- package/src/core/retention.ts +1 -9
- package/src/core/retired-checks.ts +2 -0
- package/src/core/tmux-policy.ts +1 -1
- package/src/core/tree-watch.ts +2 -2
- package/src/core/when.ts +7 -45
- package/src/gate/discover-checks.ts +42 -32
- package/src/gate/gate-checks.ts +21 -131
- package/src/gate/pre-commit-discovery.ts +16 -25
- package/src/gate/run-check.ts +0 -4
- package/src/gate/run-fix.ts +5 -17
- package/src/gate/run-fixers.ts +6 -42
- package/src/home/app-sign.ts +2 -2
- package/src/home/backup-status.ts +52 -92
- package/src/home/backup-verdict.ts +2 -2
- package/src/home/daemon-jobs.ts +51 -95
- package/src/home/database-words.ts +1 -2
- package/src/home/databases.ts +9 -25
- package/src/home/home-launchd.ts +0 -6
- package/src/home/home-paths.ts +8 -4
- package/src/home/home-routes.ts +3 -10
- package/src/home/home-state.ts +2 -14
- package/src/home/inbox-shape.ts +14 -15
- package/src/home/inbox.ts +1 -1
- package/src/home/machine-repair.ts +102 -103
- package/src/home/resume.ts +1 -15
- package/src/home/run-daemon.ts +4 -11
- package/src/home/space-page.ts +3 -2
- package/src/home/supervise.ts +3 -7
- package/src/hooks/hook-config.ts +6 -7
- package/src/hooks/leak-guard.ts +1 -1
- package/src/hooks/run-hooks.ts +0 -5
- package/src/hq/daemon-db.ts +8 -8
- package/src/hq/door.ts +3 -16
- package/src/hq/hq-db.ts +4 -3
- package/src/hq/hq-local.ts +1 -2
- package/src/hq/hq-store.ts +0 -15
- package/src/hq/item-direct.ts +8 -10
- package/src/hq/item-fill.ts +37 -0
- package/src/hq/kinds/item-gone.ts +7 -10
- package/src/hq/kinds/item-msg.ts +12 -18
- package/src/hq/kinds/item.ts +13 -19
- package/src/hq/kinds/report.ts +3 -4
- package/src/hq/owner-switch.ts +3 -3
- package/src/hq/report.ts +5 -9
- package/src/hq/switch.ts +2 -11
- package/src/hq/thread-sync.ts +5 -17
- package/src/hq/{shapes-words.ts → threads-words.ts} +2 -12
- package/src/http/owner-word.ts +1 -1
- package/src/identities/machine.ts +16 -0
- package/src/init-repo.ts +0 -1
- package/src/ledger/check-stats.ts +6 -5
- package/src/ledger/db.ts +2 -4
- package/src/ledger/record-kept.ts +117 -48
- package/src/ledger/run-log.ts +21 -2
- package/src/ledger/slow-tests.ts +96 -0
- package/src/ledger/store.ts +3 -86
- package/src/ledger/suite-log.ts +8 -2
- package/src/media-store/backup/facts.ts +3 -37
- package/src/media-store/backup/keys.ts +1 -8
- package/src/media-store/backup/manifest.ts +6 -67
- package/src/media-store/backup/restore.ts +4 -13
- package/src/media-store/backup/retention.ts +13 -1
- package/src/media-store/backup/run.ts +6 -267
- package/src/media-store/backup/snapshot.ts +2 -38
- package/src/media-store/backup/sources.ts +3 -113
- package/src/media-store/backup/target-send.ts +5 -29
- package/src/media-store/db.ts +8 -7
- package/src/media-store/forget-one.ts +1 -1
- package/src/media-store/forget.ts +1 -80
- package/src/orchestrator/guards.ts +0 -1
- package/src/orchestrator/presence.ts +2 -2
- package/src/orchestrator/routes.ts +1 -1
- package/src/orchestrator/started.ts +0 -9
- package/src/orchestrator/talk-key.ts +3 -4
- package/src/orchestrator/unheard.ts +1 -1
- package/src/recordings/edit.ts +3 -3
- package/src/recordings/marks-draw.ts +17 -6
- package/src/recordings/marks.ts +120 -9
- package/src/reflections/reflections-queue.ts +3 -10
- package/src/release/notes.ts +1 -1
- package/src/release/public-clean.ts +66 -6
- package/src/release/run-bump.ts +11 -0
- package/src/release/run-release.ts +4 -0
- package/src/releases/from-thread.ts +3 -3
- package/src/releases/model.ts +186 -36
- package/src/releases/store.ts +13 -3
- package/src/releases/validate.ts +83 -0
- package/src/repo-config.ts +29 -64
- package/src/review/answer-kinds.ts +61 -4
- package/src/review/blocked-guard.ts +11 -0
- package/src/review/blocked-object.ts +298 -0
- package/src/review/cells.ts +116 -229
- package/src/review/close.ts +39 -1
- package/src/review/doc-save.ts +3 -2
- package/src/review/draft-item.ts +1 -1
- package/src/review/events.ts +3 -7
- package/src/review/expect.ts +23 -39
- package/src/review/format.ts +79 -46
- package/src/review/glyphs.ts +1 -0
- package/src/review/hand-over.ts +3 -3
- package/src/review/heard.ts +1 -1
- package/src/review/holds-sync.ts +2 -1
- package/src/review/inbox-hook.ts +2 -2
- package/src/review/inbox-read.ts +39 -33
- package/src/review/instruction-guards.ts +12 -0
- package/src/review/instructions.ts +0 -1
- package/src/review/item-db.ts +13 -43
- package/src/review/item-hq.ts +2 -2
- package/src/review/item-rows.ts +3 -14
- package/src/review/kind-catalog.ts +3 -1
- package/src/review/kinds.ts +18 -8
- package/src/review/live-view.ts +3 -0
- package/src/review/media-kind.ts +1 -1
- package/src/review/mentions.ts +1 -2
- package/src/review/model.ts +158 -114
- package/src/review/move.ts +149 -0
- package/src/review/need-threads.ts +3 -2
- package/src/review/object-card.ts +11 -0
- package/src/review/object-read.ts +6 -1
- package/src/review/one-block.ts +1 -1
- package/src/review/owner-read.ts +1 -1
- package/src/review/phone-push.ts +10 -9
- package/src/review/previews.ts +32 -4
- package/src/review/push.ts +2 -2
- package/src/review/recap.ts +129 -0
- package/src/review/referring.ts +6 -3
- package/src/review/reflection-object.ts +4 -3
- package/src/review/routes.ts +49 -19
- package/src/review/secret-route.ts +3 -2
- package/src/review/settle.ts +0 -6
- package/src/review/snooze.ts +5 -3
- package/src/review/speaker.ts +68 -0
- package/src/review/start-title.ts +19 -0
- package/src/review/store.ts +86 -59
- package/src/review/{wakes.ts → thread-events.ts} +92 -7
- package/src/review/thread-md.ts +35 -14
- package/src/review/thread-state.ts +798 -0
- package/src/review/threads.ts +29 -347
- package/src/review/traces.ts +104 -7
- package/src/review/trailer-item.ts +1 -1
- package/src/review/unit.ts +7 -9
- package/src/review/verdict-items.ts +12 -10
- package/src/review/view-layout.ts +25 -1
- package/src/review/watch-feed.ts +1 -2
- package/src/review/working-guards.ts +2 -3
- package/src/rules/untrack-generated.ts +1 -15
- package/src/secrets/lapse.ts +2 -1
- package/src/serve/hub-app/advisor-app.tsx +4 -4
- package/src/serve/hub-app/advisor-face.tsx +9 -3
- package/src/serve/hub-app/advisor-host.ts +27 -27
- package/src/serve/hub-app/advisors-model.ts +17 -8
- package/src/serve/hub-app/advisors-rights.tsx +1 -1
- package/src/serve/hub-app/advisors-st.ts +15 -14
- package/src/serve/hub-app/advisors-view.tsx +13 -11
- package/src/serve/hub-app/app-bridge.ts +23 -3
- package/src/serve/hub-app/asks-page.tsx +1 -1
- package/src/serve/hub-app/auto-text.tsx +71 -16
- package/src/serve/hub-app/check-view.tsx +0 -8
- package/src/serve/hub-app/controls.css +14 -3
- package/src/serve/hub-app/database-view.tsx +1 -2
- package/src/serve/hub-app/git-view.tsx +3 -1
- package/src/serve/hub-app/hub.css +12 -5
- package/src/serve/hub-app/icons.tsx +1 -1
- package/src/serve/hub-app/inbox-view.tsx +1 -2
- package/src/serve/hub-app/live-sources.ts +2 -2
- package/src/serve/hub-app/main-panel.tsx +2 -1
- package/src/serve/hub-app/panel-repo.ts +0 -9
- package/src/serve/hub-app/pic.tsx +29 -12
- package/src/serve/hub-app/polled.ts +16 -2
- package/src/serve/hub-app/recordings-st.ts +23 -2
- package/src/serve/hub-app/recordings-view.tsx +68 -10
- package/src/serve/hub-app/ref-pill.ts +1 -1
- package/src/serve/hub-app/repo-st.ts +1 -2
- package/src/serve/hub-app/review/advisor-add.tsx +1 -1
- package/src/serve/hub-app/review/advisor-invite.tsx +1 -1
- package/src/serve/hub-app/review/draft-body.tsx +2 -2
- package/src/serve/hub-app/review/heard-line.tsx +1 -1
- package/src/serve/hub-app/review/instructions-view.tsx +1 -8
- package/src/serve/hub-app/review/kind-states.tsx +14 -9
- package/src/serve/hub-app/review/kit.tsx +4 -11
- package/src/serve/hub-app/review/lane-bar.tsx +3 -3
- package/src/serve/hub-app/review/lightbox.tsx +15 -11
- package/src/serve/hub-app/review/line-window.ts +4 -1
- package/src/serve/hub-app/review/live-bar-st.ts +2 -2
- package/src/serve/hub-app/review/live-view.tsx +57 -1
- package/src/serve/hub-app/review/object-panel.tsx +20 -8
- package/src/serve/hub-app/review/question-views.tsx +181 -54
- package/src/serve/hub-app/review/recap-bar.tsx +40 -0
- package/src/serve/hub-app/review/request-cell.tsx +48 -0
- package/src/serve/hub-app/review/review-cells.tsx +154 -96
- package/src/serve/hub-app/review/review-host.ts +2 -2
- package/src/serve/hub-app/review/review-kit.ts +17 -11
- package/src/serve/hub-app/review/review-list.tsx +23 -31
- package/src/serve/hub-app/review/review-st.ts +30 -40
- package/src/serve/hub-app/review/review-thread.tsx +139 -85
- package/src/serve/hub-app/review/review-views.tsx +124 -68
- package/src/serve/hub-app/review/share-lines.tsx +4 -4
- package/src/serve/hub-app/review/start-st.ts +2 -5
- package/src/serve/hub-app/review/superseded-runs.ts +4 -3
- package/src/serve/hub-app/review/thread-close.tsx +10 -7
- package/src/serve/hub-app/review/thread-st.ts +372 -201
- package/src/serve/hub-app/review/tone-bar.tsx +126 -0
- package/src/serve/hub-app/review/tones.ts +35 -0
- package/src/serve/hub-app/review/trailer-body.tsx +2 -2
- package/src/serve/hub-app/review/trailer-st.ts +3 -2
- package/src/serve/hub-app/review/trailer-voices-st.ts +3 -2
- package/src/serve/hub-app/review.css +180 -106
- package/src/serve/hub-app/search-view.tsx +1 -1
- package/src/serve/hub-app/social/social-model.ts +0 -4
- package/src/serve/hub-app/source-acts.ts +2 -1
- package/src/serve/hub-app/stores/stores-page.tsx +2 -2
- package/src/serve/hub-app/terminal-sources.tsx +2 -1
- package/src/serve/hub-app/thread-row.tsx +3 -4
- package/src/serve/hub-app/tree-build.ts +0 -4
- package/src/serve/hub-app/urls-view.tsx +2 -1
- package/src/serve/hub-app/view-layout.css +13 -3
- package/src/serve/hub-app/wikis-view.tsx +5 -2
- package/src/serve/hub-runtime.ts +7 -37
- package/src/serve/project-gutter-route.ts +6 -2
- package/src/serve/read-thread.ts +20 -2
- package/src/serve/read-worker.ts +9 -1
- package/src/serve/record-pages.ts +46 -0
- package/src/serve/serve-hub.ts +2 -2
- package/src/serve/terminal-host.ts +1 -1
- package/src/serve/terminal-route.ts +1 -3
- package/src/serve/tracked-watch.ts +1 -3
- package/src/setup-house.ts +2 -2
- package/src/shipkit-files.ts +1 -1
- package/src/shipkit.ts +1 -6
- package/src/shot/film-box.ts +0 -20
- package/src/social/drafts.ts +1 -1
- package/src/social/kinds.ts +6 -29
- package/src/social/load.ts +2 -2
- package/src/social/post-object.ts +3 -2
- package/src/social/release-stage.ts +1 -1
- package/src/social/stage.ts +2 -2
- package/src/stores/model.ts +4 -0
- package/src/stores/routes.ts +11 -3
- package/src/suite/judge-suites.ts +58 -0
- package/src/suite/red-alone.ts +54 -18
- package/src/suite/runner-shapes.ts +2 -2
- package/src/suite/suite-cli.ts +67 -14
- package/src/suite/test-units.ts +2 -1
- package/src/urls/fill.ts +1 -1
- package/src/urls/places.ts +1 -2
- package/src/vault/vault-config.ts +2 -2
- package/src/vault/vault-init.ts +1 -5
- package/src/wiki/graph-page.ts +14 -2
- package/src/advisors/copy-truth.ts +0 -49
- package/src/advisors/door-child.ts +0 -112
- package/src/advisors/door-serve.ts +0 -52
- package/src/advisors/door.ts +0 -118
- package/src/checks/SK016-legacy-check-shapes.check.ts +0 -189
- package/src/checks/SK029-explicit-check-files.check.ts +0 -112
- package/src/checks/SK048-one-local-file.check.ts +0 -36
- package/src/core/config-rewrite.ts +0 -111
- package/src/core/daemon-port.ts +0 -10
- package/src/core/legacy-shapes.ts +0 -263
- package/src/core/migrate-layout.ts +0 -638
- package/src/core/port-check-cli.ts +0 -52
- package/src/core/port-check-file.ts +0 -295
- package/src/core/port-check-files.ts +0 -31
- package/src/gate/discover-legacy-checks.ts +0 -26
- package/src/home/home-move.ts +0 -527
- package/src/home/machine-fold.ts +0 -810
- package/src/hq/item-shapes.ts +0 -54
- package/src/hq/kinds/items-read.ts +0 -4
- package/src/media-store/backup/daemon.ts +0 -220
- package/src/media-store/backup/kept.ts +0 -241
- package/src/media-store/backup/prune.ts +0 -359
- package/src/media-store/backup/secret.ts +0 -88
- package/src/media-store/backup/ssh-space.ts +0 -202
- package/src/media-store/backup/watch.ts +0 -117
- package/src/review/band.ts +0 -182
- package/src/review/folders.ts +0 -216
- package/src/review/hook-ask.ts +0 -58
- package/src/review/role.ts +0 -48
- package/src/review/thread-fold.ts +0 -64
- package/src/review/wait.ts +0 -91
- package/src/rules/rule.ts +0 -43
- package/src/serve/hook-thread.ts +0 -37
- package/src/serve/hook-work.ts +0 -92
- package/src/serve/hook-worker.ts +0 -57
- package/src/serve/hub-app/review/dock.tsx +0 -147
- package/src/serve/hub-app/review/faces.tsx +0 -18
- package/src/serve/hub-app/review/item-verdict.tsx +0 -112
- package/src/serve/hub-app/review/review-board.tsx +0 -48
- /package/src/{scaffold → core}/jsonc-spans.ts +0 -0
|
@@ -15,8 +15,8 @@ import type { BackupRetention } from './retention.ts'
|
|
|
15
15
|
import { copyName, homeRelative, houseSsh, SAFE, sha256, sshPrune, sshPut, type Ssh } from './ssh-target.ts'
|
|
16
16
|
|
|
17
17
|
/** the stores the status follows; the folder each keeps its copies under on a target, one folder a machine */
|
|
18
|
-
export type StoreId = 'vault' | 'hq'
|
|
19
|
-
export const STORE_DIRS: Record<StoreId, string> = { vault: 'vault-snapshots', hq: 'hq-snapshots'
|
|
18
|
+
export type StoreId = 'vault' | 'hq'
|
|
19
|
+
export const STORE_DIRS: Record<StoreId, string> = { vault: 'vault-snapshots', hq: 'hq-snapshots' }
|
|
20
20
|
|
|
21
21
|
/** a failure keeps the time of the last good send, so a glitch is told apart from a copy that is gone stale */
|
|
22
22
|
export type TargetSent = { at: number; name: string; bytes: number; sha: string } | { at: number; failed: string; okAt?: number; more?: true }
|
|
@@ -47,12 +47,6 @@ export function newestVaultSnap(dir: string): { file: string; mtime: number } |
|
|
|
47
47
|
const failedOld = (s: TargetSent | null, now: number): boolean => s != null && 'failed' in s && now - s.at >= RETRY_MS
|
|
48
48
|
/** the vault's newest snapshot is due to a target when it never went there, or went older than the snapshot */
|
|
49
49
|
export const vaultDueTo = (s: TargetSent | null, snapAt: number, now: number): boolean => s == null || failedOld(s, now) || (!('failed' in s) && s.at < snapAt)
|
|
50
|
-
/** the newest run is due to an ssh target that does not hold it yet: its name is the run's key */
|
|
51
|
-
export const filesDueTo = (s: TargetSent | null, run: string, now: number): boolean => s == null || ('failed' in s ? s.more === true || now - s.at >= RETRY_MS : s.name !== run)
|
|
52
|
-
/** the restore drill of an ssh target's mirror, once a week, once its newest run is there whole */
|
|
53
|
-
export const DRILL_EVERY_MS = 7 * 24 * 60 * 60_000
|
|
54
|
-
/** a drill that failed is done again after an hour: a glitch never holds the band red for the week */
|
|
55
|
-
export const filesDrillDue = (sent: TargetSent | null, drill: { at: number; failed: number } | null, now: number): boolean => sent != null && !('failed' in sent) && (drill == null || now - drill.at >= (drill.failed > 0 ? 60 * 60_000 : DRILL_EVERY_MS))
|
|
56
50
|
export const hqDueTo = (s: TargetSent | null, now: number): boolean => s == null || failedOld(s, now) || (!('failed' in s) && now - s.at >= HQ_EVERY_MS)
|
|
57
51
|
|
|
58
52
|
export type SendDeps = {
|
|
@@ -99,22 +93,20 @@ export async function sendTo(store: StoreId, t: BackupTarget, f: { name: string;
|
|
|
99
93
|
|
|
100
94
|
/** what is due now: the vault's newest snapshot to each target that lacks it, the hq's file to each whose copy is an
|
|
101
95
|
* hour old. Cheap: rows of the machine db and one directory read */
|
|
102
|
-
export function targetsDue(targets: readonly BackupTarget[], o: { vaultDir: string | null; carriesHq: boolean; now: number;
|
|
96
|
+
export function targetsDue(targets: readonly BackupTarget[], o: { vaultDir: string | null; carriesHq: boolean; now: number; stream?: ReplicaPlace | null }): { vault: BackupTarget[]; hq: BackupTarget[] } {
|
|
103
97
|
const to = sealedTargets(targets)
|
|
104
98
|
const streamed = (t: BackupTarget): boolean => t.address.kind === 's3' && t.address.config === o.stream
|
|
105
99
|
const snap = o.vaultDir == null ? null : newestVaultSnap(o.vaultDir)
|
|
106
100
|
return {
|
|
107
101
|
vault: snap == null ? [] : to.filter((t) => vaultDueTo(lastSentTo('vault', t.id), snap.mtime, o.now)),
|
|
108
102
|
hq: o.carriesHq ? to.filter((t) => !streamed(t) && hqDueTo(lastSentTo('hq', t.id), o.now)) : [],
|
|
109
|
-
files: o.run == null ? [] : to.filter((t) => t.address.kind === 'ssh' && filesDueTo(lastSentTo('files', t.id), o.run!, o.now)),
|
|
110
|
-
drill: to.filter((t) => t.address.kind === 'ssh' && filesDrillDue(lastSentTo('files', t.id), machineGet<{ at: number; failed: number }>(`target-drill:files:${t.id}`), o.now)),
|
|
111
103
|
}
|
|
112
104
|
}
|
|
113
105
|
|
|
114
106
|
/** the job: each due send made, every line said. The hq's copy is made once for every target due */
|
|
115
|
-
export async function targetsTick(o: { targets: readonly BackupTarget[]; vaultDir: string | null; hqFile: string | null; deps: SendDeps;
|
|
107
|
+
export async function targetsTick(o: { targets: readonly BackupTarget[]; vaultDir: string | null; hqFile: string | null; deps: SendDeps; stream?: ReplicaPlace | null }): Promise<string[]> {
|
|
116
108
|
const now = o.deps.now.getTime()
|
|
117
|
-
const due = targetsDue(o.targets, { vaultDir: o.vaultDir, carriesHq: o.hqFile != null, now,
|
|
109
|
+
const due = targetsDue(o.targets, { vaultDir: o.vaultDir, carriesHq: o.hqFile != null, now, stream: o.stream ?? null })
|
|
118
110
|
const lines: string[] = []
|
|
119
111
|
if (due.vault.length > 0) {
|
|
120
112
|
const snap = newestVaultSnap(o.vaultDir!)!
|
|
@@ -142,21 +134,5 @@ export async function targetsTick(o: { targets: readonly BackupTarget[]; vaultDi
|
|
|
142
134
|
rmSync(dir, { recursive: true, force: true })
|
|
143
135
|
}
|
|
144
136
|
}
|
|
145
|
-
for (const t of due.files) {
|
|
146
|
-
const okAt = okAtOf(lastSentTo('files', t.id))
|
|
147
|
-
try {
|
|
148
|
-
const m = await o.mirror!(t)
|
|
149
|
-
if (m.run == null || m.left > 0 || (m.why !== '' && m.why !== 'up to date')) {
|
|
150
|
-
machineSet(sentKey('files', t.id), { at: now, failed: m.why, ...(okAt == null ? {} : { okAt }), ...(m.left > 0 ? { more: true as const } : {}) } satisfies TargetSent)
|
|
151
|
-
lines.push(`${m.left > 0 ? 'ok:' : 'WARN'} files to ${t.label}: ${m.sent} objects sent (${(m.bytes / 1e6).toFixed(0)} MB); ${m.why}`)
|
|
152
|
-
continue
|
|
153
|
-
}
|
|
154
|
-
machineSet(sentKey('files', t.id), { at: now, name: m.run, bytes: m.bytes, sha: '' } satisfies TargetSent)
|
|
155
|
-
lines.push(`ok: files to ${t.label}: ${m.run} and the ${m.sent} objects it lacked (${(m.bytes / 1e6).toFixed(0)} MB), each checked by its sha there`)
|
|
156
|
-
} catch (e) {
|
|
157
|
-
machineSet(sentKey('files', t.id), { at: now, failed: (e as Error).message, ...(okAt == null ? {} : { okAt }) } satisfies TargetSent)
|
|
158
|
-
lines.push(`WARN files to ${t.label}: ${(e as Error).message}`)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
137
|
return lines
|
|
162
138
|
}
|
package/src/media-store/db.ts
CHANGED
|
@@ -3,19 +3,20 @@
|
|
|
3
3
|
// the truth, and a deleted index builds again from them (a file's place in the Space is found again by a HEAD). It holds
|
|
4
4
|
// each file a kind names (local or not), each Space object (up or waiting, its retries), when a purged file was fetched
|
|
5
5
|
// back (a use the purge counts), the review store's item reads by the code that read them. Beside them, never derived:
|
|
6
|
-
// `forgotten_media`, each key its owner forgot (sk media forget: who, when, the words): no prefix,
|
|
7
|
-
//
|
|
6
|
+
// `forgotten_media`, each key its owner forgot (sk media forget: who, when, the words): no prefix, and a drop of the
|
|
7
|
+
// cache leaves it (home/machine-repair.ts, STORES `kept`)
|
|
8
8
|
import type { Database } from 'bun:sqlite'
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { join } from 'node:path'
|
|
10
|
+
import { machineDbPath, openMachineFile } from '../core/machine-db.ts'
|
|
11
|
+
import { homeDir } from '../home/home-paths.ts'
|
|
11
12
|
|
|
12
13
|
/** the file that holds the index's tables for one process (a suite, a scratch); else the machine db */
|
|
13
14
|
export const MEDIA_DB_ENV = 'SHIPKIT_MEDIA_DB'
|
|
14
|
-
export const mediaDbPath = (): string => process.env[MEDIA_DB_ENV] ||
|
|
15
|
+
export const mediaDbPath = (): string => process.env[MEDIA_DB_ENV] || machineDbPath()
|
|
15
16
|
|
|
16
17
|
/** `forgotten_media` as a file of the home, written by forget-one.ts: the log's copy a backup run takes, since no run
|
|
17
18
|
* holds the machine db */
|
|
18
|
-
export const forgottenFilePath = (): string => join(
|
|
19
|
+
export const forgottenFilePath = (): string => join(homeDir(), 'media-forgotten.jsonl')
|
|
19
20
|
|
|
20
21
|
const SCHEMA = `
|
|
21
22
|
create table if not exists media_codes (store text not null, code text not null, used integer not null, primary key (store, code)) without rowid;
|
|
@@ -28,7 +29,7 @@ create table if not exists media_fetched (store text not null, item text not nul
|
|
|
28
29
|
create table if not exists forgotten_media (key text not null, at integer not null, sha text not null, by text not null, words text not null, copy text not null, state text not null, primary key (key, at)) without rowid;
|
|
29
30
|
`
|
|
30
31
|
|
|
31
|
-
/** the index's tables, made where they are not
|
|
32
|
+
/** the index's tables, made where they are not */
|
|
32
33
|
export const createMediaTables = (db: Database): void => void db.exec(SCHEMA)
|
|
33
34
|
|
|
34
35
|
let open: { path: string; db: Database } | null = null
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { existsSync, mkdirSync, statSync, writeFileSync } from 'node:fs'
|
|
6
6
|
import { dirname, join } from 'node:path'
|
|
7
7
|
import { MEDIA_KINDS, codeKinds } from '../media-kinds.ts'
|
|
8
|
-
import { AGENT_ENV } from '../
|
|
8
|
+
import { AGENT_ENV } from '../core/agent-env.ts'
|
|
9
9
|
import { shaOf, shaOfKey } from './content.ts'
|
|
10
10
|
import type { CopyEnds } from './copy/config.ts'
|
|
11
11
|
import { forgottenFilePath, mediaDb } from './db.ts'
|
|
@@ -80,86 +80,7 @@ export function checkBackupKeys(keys: Iterable<string>): void {
|
|
|
80
80
|
for (const key of keys) if (!isBackupObject(key)) throw new Error(`${key} is no backup object: nothing is deleted`)
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
/** the
|
|
84
|
-
* caller is the prune (media-store/backup/prune.ts), which decides what goes. Every key is checked before any call;
|
|
85
|
-
* each key's index row goes before its object, so no run ever takes a deleted object for one still up. A plain
|
|
86
|
-
* delete: the bucket keeps its versions behind a delete marker, gone from every listing, until emptyBackupTrash
|
|
87
|
-
* removes them TRASH_DAYS later; until then deleting the marker brings the object back */
|
|
88
|
-
export async function forgetBackupObjects(keys: readonly string[], o: { jobs?: number; remove?: (key: string) => Promise<void> } = {}): Promise<{ gone: string[]; failed: { key: string; error: string }[] }> {
|
|
89
|
-
checkBackupKeys(keys)
|
|
90
|
-
if (keys.length === 0) return { gone: [], failed: [] }
|
|
91
|
-
let remove = o.remove
|
|
92
|
-
if (!remove) {
|
|
93
|
-
const { config, why } = await houseSpaceConfig()
|
|
94
|
-
if (!config) throw new Error(`nothing is deleted: ${why}`)
|
|
95
|
-
remove = async (key) => void (await signedDelete(config, key, {}))
|
|
96
|
-
}
|
|
97
|
-
const db = mediaDb()
|
|
98
|
-
if (!db) throw new Error('the media index does not open: nothing is deleted')
|
|
99
|
-
const unindex = db.query('delete from media_objects where key = ?')
|
|
100
|
-
const gone: string[] = []
|
|
101
|
-
const failed: { key: string; error: string }[] = []
|
|
102
|
-
let next = 0
|
|
103
|
-
const work = async (): Promise<void> => {
|
|
104
|
-
for (let i = next++; i < keys.length; i = next++) {
|
|
105
|
-
const key = keys[i]!
|
|
106
|
-
try {
|
|
107
|
-
unindex.run(key)
|
|
108
|
-
await remove(key)
|
|
109
|
-
gone.push(key)
|
|
110
|
-
} catch (e) {
|
|
111
|
-
failed.push({ key, error: (e as Error).message })
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
await Promise.all(Array.from({ length: Math.max(1, o.jobs ?? 8) }, work))
|
|
116
|
-
return { gone, failed }
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** how long a pruned backup object stays behind its delete marker, recoverable */
|
|
120
|
-
export const TRASH_DAYS = 7
|
|
121
|
-
|
|
122
|
-
/** the backup's trash emptied: under `backup/`, each key whose newest entry is a delete marker older than TRASH_DAYS
|
|
123
|
-
* loses the versions and the marker the listing named, by their ids, so a version put after the listing stays. Its
|
|
124
|
-
* one caller is the prune */
|
|
125
|
-
export async function emptyBackupTrash(o: { now?: number; jobs?: number } = {}): Promise<{ keys: number; bytes: number; failed: { key: string; error: string }[] }> {
|
|
126
|
-
const { config, why } = await houseSpaceConfig()
|
|
127
|
-
if (!config) throw new Error(`nothing is deleted: ${why}`)
|
|
128
|
-
const { eachVersion } = await import('./space-listing.ts')
|
|
129
|
-
const now = o.now ?? Date.now()
|
|
130
|
-
const byKey = new Map<string, { ids: string[]; bytes: number; trashed: boolean }>()
|
|
131
|
-
await eachVersion(config, { prefix: 'backup/' }, (v) => {
|
|
132
|
-
let k = byKey.get(v.key)
|
|
133
|
-
if (!k) {
|
|
134
|
-
k = { ids: [], bytes: 0, trashed: false }
|
|
135
|
-
byKey.set(v.key, k)
|
|
136
|
-
}
|
|
137
|
-
k.ids.push(v.versionId)
|
|
138
|
-
k.bytes += v.size
|
|
139
|
-
if (v.latest && v.marker && v.modified != null && now - v.modified > TRASH_DAYS * 86_400_000) k.trashed = true
|
|
140
|
-
})
|
|
141
|
-
const due = [...byKey].filter(([key, k]) => k.trashed && isBackupObject(key))
|
|
142
|
-
const failed: { key: string; error: string }[] = []
|
|
143
|
-
let keys = 0
|
|
144
|
-
let bytes = 0
|
|
145
|
-
let next = 0
|
|
146
|
-
const work = async (): Promise<void> => {
|
|
147
|
-
for (let i = next++; i < due.length; i = next++) {
|
|
148
|
-
const [key, k] = due[i]!
|
|
149
|
-
try {
|
|
150
|
-
for (const v of k.ids) if (v !== '') await signedDelete(config, key, { versionId: v })
|
|
151
|
-
keys++
|
|
152
|
-
bytes += k.bytes
|
|
153
|
-
} catch (e) {
|
|
154
|
-
failed.push({ key, error: (e as Error).message })
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
await Promise.all(Array.from({ length: Math.max(1, o.jobs ?? 8) }, work))
|
|
159
|
-
return { keys, bytes, failed }
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/** the undo of a prune within TRASH_DAYS: under `backup/`, each key named (or every key deleted at or after `since`)
|
|
83
|
+
/** the undo of a past prune (its objects stay behind their delete markers): under `backup/`, each key named (or every key deleted at or after `since`)
|
|
163
84
|
* whose newest entry is a delete marker loses that marker, so its newest version is the object again. Deletes only
|
|
164
85
|
* markers. Its one caller is `sk backup undelete` */
|
|
165
86
|
export async function undeleteBackup(o: { keys?: readonly string[]; since?: number }): Promise<{ back: string[]; failed: { key: string; error: string }[] }> {
|
|
@@ -29,10 +29,10 @@ export function lanePresent(r: LiveRow, repo: string): Present {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/** each lane with the open thread it holds by name (review/threads.ts holderOf), the one that moved last */
|
|
32
|
-
export function withThreads(ps: Present[], rows: readonly Pick<ThreadRow, 'head' | 'title' | 'updated' | '
|
|
32
|
+
export function withThreads(ps: Present[], rows: readonly Pick<ThreadRow, 'head' | 'title' | 'updated' | 'state' | 'addresses'>[]): Present[] {
|
|
33
33
|
return ps.map((p) => {
|
|
34
34
|
if (p.kind !== 'lane') return p
|
|
35
|
-
const held = rows.filter((r) => r.turn !== 'done' && r.holder?.lane === p.name).sort((a, b) => b.updated.localeCompare(a.updated))
|
|
35
|
+
const held = rows.filter((r) => r.state.turn !== 'done' && r.state.holder?.lane === p.name).sort((a, b) => b.updated.localeCompare(a.updated))
|
|
36
36
|
const first = held[0]
|
|
37
37
|
return first ? { ...p, thread: { head: first.head, title: first.title, address: first.addresses[0] ?? '', more: held.length - 1 } } : p
|
|
38
38
|
})
|
|
@@ -214,7 +214,7 @@ export function orchestratorRoutes(house: string, rootOf?: (repo: unknown) => Pr
|
|
|
214
214
|
const dir = storeDir(root)
|
|
215
215
|
const files = stagedFiles(dir, b.files)
|
|
216
216
|
const address = `talk:${talkKey(text)}`
|
|
217
|
-
const r = await noteOn(dir, { subject: { kind: 'object', address }, origin: { by: 'owner', from: 'new thread' }, name: 'new thread', title: talkTitle(text), text, files })
|
|
217
|
+
const r = await noteOn(dir, { subject: { kind: 'object', address }, origin: { by: 'owner', from: 'new thread' }, name: 'new thread', title: talkTitle(text, files), text, files })
|
|
218
218
|
if (to !== null) appendMessage(dir, r.id, { who: 'agent', op: 'take', session: to.session, note: `the owner sent it to ${to.name}` })
|
|
219
219
|
dropStaged(files)
|
|
220
220
|
return Response.json({ ...r, address, repo: b.repo, ...(to !== null ? { to: to.name } : {}) }, { headers: NO_STORE })
|
|
@@ -39,15 +39,6 @@ export function markStarted(repo: string, s: Start, file = startsFile()): void {
|
|
|
39
39
|
writeStarts({ ...readStarts(file), [repo]: s }, file)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
/** false when `repo` had none */
|
|
43
|
-
export function forgetStart(repo: string, file = startsFile()): boolean {
|
|
44
|
-
const all = readStarts(file)
|
|
45
|
-
if (!(repo in all)) return false
|
|
46
|
-
const { [repo]: _, ...rest } = all
|
|
47
|
-
writeStarts(rest, file)
|
|
48
|
-
return true
|
|
49
|
-
}
|
|
50
|
-
|
|
51
42
|
/** the account of his newest start, '' for the shell's own, null before his first */
|
|
52
43
|
export function lastAccount(starts: Record<string, Start>): string | null {
|
|
53
44
|
const newest = Object.values(starts).sort((a, b) => b.at.localeCompare(a.at))[0]
|
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
import { dayStamp } from '../core/day-stamp.ts'
|
|
4
4
|
import { stampOf } from '../core/log-stamp.ts'
|
|
5
5
|
import { slugOf } from '../core/slug.ts'
|
|
6
|
+
import { startTitle } from '../review/start-title.ts'
|
|
6
7
|
|
|
7
8
|
/** a file's tag in the words (`[image 2]`, hub-app attach-st.ts): no word of his */
|
|
8
9
|
const TAG = /\[image \d+\]/g
|
|
9
10
|
|
|
10
|
-
/** a new conversation's title: his first line, its file tags dropped */
|
|
11
|
-
export
|
|
12
|
-
return (text.replace(TAG, ' ').trim().split('\n')[0] ?? '').replace(/\s+/g, ' ').trim() || 'a new thread'
|
|
13
|
-
}
|
|
11
|
+
/** a new conversation's title: his first line, its file tags dropped, else his first file's name (review/start-title.ts) */
|
|
12
|
+
export const talkTitle = (text: string, files: readonly { name: string }[] = []): string => startTitle('', text, files)
|
|
14
13
|
|
|
15
14
|
/** a new conversation's key: the day, then the first words the owner wrote */
|
|
16
15
|
export function talkKey(text: string, now = new Date()): string {
|
|
@@ -24,7 +24,7 @@ export async function unheardOf(dir: string, now = Date.now()): Promise<Unheard[
|
|
|
24
24
|
const { liveWatchers } = await import('../review/watchers.ts')
|
|
25
25
|
const { readParties, repoNameOf } = await import('../agent-time/registry.ts')
|
|
26
26
|
const { orchestratorFor } = await import('../review/parties.ts')
|
|
27
|
-
const { wakingUnread } = await import('../review/
|
|
27
|
+
const { wakingUnread } = await import('../review/thread-events.ts')
|
|
28
28
|
const { hearsHolder, ownAddressesOf, threadByItem, threadsOf, unseen, wordReaches } = await import('../review/threads.ts')
|
|
29
29
|
const { agentsNamed } = await import('../review/model.ts')
|
|
30
30
|
const items = readAll(dir).items
|
package/src/recordings/edit.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// mute no sound
|
|
7
7
|
// arrow, rect, text, step, blur the marks drawn on it, each with an optional span (marks.ts)
|
|
8
8
|
// The export is one ffmpeg pass into `out.<ext>`; the hub's editor writes the same text
|
|
9
|
-
import { boundsOf, MARK_VERBS, parseMark, printMark, style, type Mark, type Span } from './marks.ts'
|
|
9
|
+
import { arrowExtent, boundsOf, MARK_VERBS, parseMark, printMark, style, type Mark, type Span } from './marks.ts'
|
|
10
10
|
|
|
11
11
|
export type { Span }
|
|
12
12
|
export type Crop = { w: number; h: number; x: number; y: number }
|
|
@@ -142,9 +142,9 @@ export function canvasOf(e: Pick<Edit, 'marks'>, frame: { width: number; height:
|
|
|
142
142
|
const pad = st.stroke * 3
|
|
143
143
|
for (const m of e.marks) {
|
|
144
144
|
if (m.kind === 'blur') continue
|
|
145
|
-
// the mark's own extent (an arrow's
|
|
145
|
+
// the mark's own extent (an arrow's curve, a box, a step's disc, a text's estimate): a side grows only where
|
|
146
146
|
// the mark itself goes past the take, then by a margin its stroke and its head fit in
|
|
147
|
-
const b = m.kind === 'arrow' ?
|
|
147
|
+
const b = m.kind === 'arrow' ? arrowExtent(m) : boundsOf(m, frame)
|
|
148
148
|
if (b.x < 0) x0 = Math.min(x0, Math.floor(b.x - pad))
|
|
149
149
|
if (b.y < 0) y0 = Math.min(y0, Math.floor(b.y - pad))
|
|
150
150
|
if (b.x + b.w > frame.width) x1 = Math.max(x1, Math.ceil(b.x + b.w + pad))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// a mark drawn on a 2D canvas, the ONE drawing of every mark: the page draws its preview with it on a browser canvas,
|
|
2
2
|
// the export draws the PNG it burns in with it on @napi-rs/canvas, so what he sees is what ships. Blur is no drawing
|
|
3
3
|
// (ffmpeg blurs the box): here it is only a dashed frame, for the page
|
|
4
|
-
import { HEX, stepNumber, style, type Mark, type Pt } from './marks.ts'
|
|
4
|
+
import { arrowCurve, arrowPoints, headAngle, HEX, stepNumber, style, type Mark, type Pt } from './marks.ts'
|
|
5
5
|
|
|
6
6
|
/** what both canvases offer that the marks use */
|
|
7
7
|
export interface Ctx2D {
|
|
@@ -16,6 +16,7 @@ export interface Ctx2D {
|
|
|
16
16
|
beginPath(): void
|
|
17
17
|
moveTo(x: number, y: number): void
|
|
18
18
|
lineTo(x: number, y: number): void
|
|
19
|
+
bezierCurveTo(ax: number, ay: number, bx: number, by: number, x: number, y: number): void
|
|
19
20
|
closePath(): void
|
|
20
21
|
stroke(): void
|
|
21
22
|
fill(): void
|
|
@@ -30,9 +31,8 @@ export interface Ctx2D {
|
|
|
30
31
|
|
|
31
32
|
const FONT = '600 {px}px -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif'
|
|
32
33
|
|
|
33
|
-
/** the arrow's head: a filled triangle whose tip is the point, sized from the stroke */
|
|
34
|
-
function head(ctx: Ctx2D,
|
|
35
|
-
const a = Math.atan2(to.y - from.y, to.x - from.x)
|
|
34
|
+
/** the arrow's head: a filled triangle whose tip is the point, along angle `a`, sized from the stroke */
|
|
35
|
+
function head(ctx: Ctx2D, to: Pt, a: number, stroke: number): Pt {
|
|
36
36
|
const len = stroke * 4.5
|
|
37
37
|
const wide = stroke * 2.6
|
|
38
38
|
const back = { x: to.x - Math.cos(a) * len, y: to.y - Math.sin(a) * len }
|
|
@@ -66,14 +66,25 @@ export function drawMark(ctx: Ctx2D, marks: readonly Mark[], i: number, frame: {
|
|
|
66
66
|
// a dark edge under every mark: it reads on a white page and on a dark one
|
|
67
67
|
const edge = m.color === 'black' ? 'rgba(255,255,255,0.8)' : 'rgba(0,0,0,0.45)'
|
|
68
68
|
if (m.kind === 'arrow') {
|
|
69
|
+
const ps = arrowPoints(m)
|
|
70
|
+
const segs = arrowCurve(ps)
|
|
71
|
+
const a = headAngle(ps)
|
|
69
72
|
for (const [w, c] of [[s.stroke + 2, edge], [s.stroke, color]] as const) {
|
|
70
73
|
ctx.strokeStyle = c
|
|
71
74
|
ctx.fillStyle = c
|
|
72
75
|
ctx.lineWidth = w
|
|
73
|
-
|
|
76
|
+
// the line stops at the head's base, its last handle moved with it: the tip stays sharp, the turn the same
|
|
77
|
+
const back = head(ctx, m.to, a, s.stroke)
|
|
78
|
+
const dx = back.x - m.to.x
|
|
79
|
+
const dy = back.y - m.to.y
|
|
74
80
|
ctx.beginPath()
|
|
75
81
|
ctx.moveTo(m.from.x, m.from.y)
|
|
76
|
-
|
|
82
|
+
segs.forEach((g, i) => {
|
|
83
|
+
const last = i === segs.length - 1
|
|
84
|
+
const c2 = last ? { x: g.c2.x + dx, y: g.c2.y + dy } : g.c2
|
|
85
|
+
const to = last ? back : g.to
|
|
86
|
+
ctx.bezierCurveTo(g.c1.x, g.c1.y, c2.x, c2.y, to.x, to.y)
|
|
87
|
+
})
|
|
77
88
|
ctx.stroke()
|
|
78
89
|
}
|
|
79
90
|
} else if (m.kind === 'rect') {
|
package/src/recordings/marks.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// steps and blurred boxes, one line each in the edit, in the take's pixels, each with an optional span of the take's
|
|
3
3
|
// time (none: the whole clip). Their order is the drawing order, and the steps count in it. Pure: the page imports it
|
|
4
4
|
// arrow 100,200 400,300 red 0:02-0:05
|
|
5
|
+
// arrow 100,200 250,120 400,300 red its tail, each point it bends through, its point
|
|
5
6
|
// rect 400x300+100+200 yellow
|
|
6
7
|
// text 120,80 "the bug is here" 48px white
|
|
7
8
|
// step 300,400 blue
|
|
@@ -15,14 +16,13 @@ export type Box = { w: number; h: number; x: number; y: number }
|
|
|
15
16
|
export type Span = { from: number; to: number }
|
|
16
17
|
|
|
17
18
|
export type Mark =
|
|
18
|
-
| { kind: 'arrow'; from: Pt; to: Pt; color: MarkColor; span: Span | null }
|
|
19
|
+
| { kind: 'arrow'; from: Pt; via: Pt[]; to: Pt; color: MarkColor; span: Span | null }
|
|
19
20
|
| { kind: 'rect'; box: Box; color: MarkColor; span: Span | null }
|
|
20
21
|
| { kind: 'text'; at: Pt; text: string; size: number | null; color: MarkColor; span: Span | null }
|
|
21
22
|
| { kind: 'step'; at: Pt; color: MarkColor; span: Span | null }
|
|
22
23
|
| { kind: 'blur'; box: Box; span: Span | null }
|
|
23
24
|
|
|
24
25
|
export const MARK_VERBS = ['arrow', 'rect', 'text', 'step', 'blur'] as const
|
|
25
|
-
export type MarkKind = Mark['kind']
|
|
26
26
|
|
|
27
27
|
/** a line's words: a double quoted run is one word, its quotes gone, `\"` a quote inside it */
|
|
28
28
|
export function words(line: string): string[] {
|
|
@@ -70,8 +70,12 @@ function options(rest: string[], verb: string, parseTime: (t: string) => number,
|
|
|
70
70
|
export function parseMark(line: string, parseTime: (t: string) => number): Mark {
|
|
71
71
|
const [verb, ...rest] = words(line)
|
|
72
72
|
if (verb === 'arrow') {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
// every point word in a row: two at least, the tail and the point
|
|
74
|
+
let n = 0
|
|
75
|
+
while (n < rest.length && PT.test(rest[n]!)) n++
|
|
76
|
+
const ps = [...Array(Math.max(n, 2)).keys()].map((k) => pt(rest[k], 'arrow'))
|
|
77
|
+
const o = options(rest.slice(ps.length), verb, parseTime, { color: true, size: false })
|
|
78
|
+
return { kind: 'arrow', from: ps[0]!, via: ps.slice(1, -1), to: ps[ps.length - 1]!, color: o.color, span: o.span }
|
|
75
79
|
}
|
|
76
80
|
if (verb === 'rect' || verb === 'blur') {
|
|
77
81
|
const o = options(rest.slice(1), verb, parseTime, { color: verb === 'rect', size: false })
|
|
@@ -97,7 +101,7 @@ export function printMark(m: Mark, printTime: (s: number) => string): string {
|
|
|
97
101
|
const sp = m.span ? ` ${printTime(m.span.from)}-${printTime(m.span.to)}` : ''
|
|
98
102
|
const sg = (n: number): string => (n < 0 ? String(n) : `+${n}`)
|
|
99
103
|
const bx = (b: Box): string => `${b.w}x${b.h}${sg(b.x)}${sg(b.y)}`
|
|
100
|
-
if (m.kind === 'arrow') return `arrow ${m.
|
|
104
|
+
if (m.kind === 'arrow') return `arrow ${arrowPoints(m).map((p) => `${p.x},${p.y}`).join(' ')} ${m.color}${sp}`
|
|
101
105
|
if (m.kind === 'rect') return `rect ${bx(m.box)} ${m.color}${sp}`
|
|
102
106
|
if (m.kind === 'blur') return `blur ${bx(m.box)}${sp}`
|
|
103
107
|
if (m.kind === 'text') return `text ${m.at.x},${m.at.y} ${quote(m.text)}${m.size ? ` ${m.size}px` : ''} ${m.color}${sp}`
|
|
@@ -111,7 +115,7 @@ export const stepNumber = (marks: readonly Mark[], i: number): number => marks.s
|
|
|
111
115
|
export function moved(m: Mark, dx: number, dy: number): Mark {
|
|
112
116
|
const p = (q: Pt): Pt => ({ x: Math.round(q.x + dx), y: Math.round(q.y + dy) })
|
|
113
117
|
const b = (q: Box): Box => ({ ...q, x: Math.round(q.x + dx), y: Math.round(q.y + dy) })
|
|
114
|
-
if (m.kind === 'arrow') return { ...m, from: p(m.from), to: p(m.to) }
|
|
118
|
+
if (m.kind === 'arrow') return { ...m, from: p(m.from), via: m.via.map(p), to: p(m.to) }
|
|
115
119
|
if (m.kind === 'rect' || m.kind === 'blur') return { ...m, box: b(m.box) }
|
|
116
120
|
return { ...m, at: p(m.at) }
|
|
117
121
|
}
|
|
@@ -120,10 +124,9 @@ export function moved(m: Mark, dx: number, dy: number): Mark {
|
|
|
120
124
|
export function boundsOf(m: Mark, frame: { width: number; height: number }): Box {
|
|
121
125
|
const s = style(frame)
|
|
122
126
|
if (m.kind === 'arrow') {
|
|
123
|
-
const
|
|
124
|
-
const y = Math.min(m.from.y, m.to.y)
|
|
127
|
+
const b = arrowExtent(m)
|
|
125
128
|
const pad = s.stroke * 3
|
|
126
|
-
return { x: x - pad, y: y - pad, w:
|
|
129
|
+
return { x: b.x - pad, y: b.y - pad, w: b.w + pad * 2, h: b.h + pad * 2 }
|
|
127
130
|
}
|
|
128
131
|
if (m.kind === 'rect' || m.kind === 'blur') return m.box
|
|
129
132
|
if (m.kind === 'step') return { x: m.at.x - s.step, y: m.at.y - s.step, w: s.step * 2, h: s.step * 2 }
|
|
@@ -136,3 +139,111 @@ export function style(frame: { width: number; height: number }): { stroke: numbe
|
|
|
136
139
|
const short = Math.min(frame.width, frame.height)
|
|
137
140
|
return { stroke: Math.max(3, Math.round(short / 160)), text: Math.max(16, Math.round(short / 22)), step: Math.max(12, Math.round(short / 34)), blur: Math.max(8, Math.round(short / 60)) }
|
|
138
141
|
}
|
|
142
|
+
|
|
143
|
+
// ---- the arrow's path: ONE smooth curve through its points (Catmull-Rom as cubic Béziers) for the page, the export
|
|
144
|
+
// and every hit; two points are the straight line they always were
|
|
145
|
+
|
|
146
|
+
type Arrow = Extract<Mark, { kind: 'arrow' }>
|
|
147
|
+
/** one piece of the curve: from the end of the piece before to `to`, bent by its two handles */
|
|
148
|
+
export type Seg = { c1: Pt; c2: Pt; to: Pt }
|
|
149
|
+
|
|
150
|
+
/** the arrow's points in order: its tail, each point it bends through, its point */
|
|
151
|
+
export const arrowPoints = (m: Arrow): Pt[] => [m.from, ...m.via, m.to]
|
|
152
|
+
|
|
153
|
+
/** the arrow again on these points (two at least): the first its tail, the last its point */
|
|
154
|
+
export const withPoints = (m: Arrow, ps: readonly Pt[]): Arrow => ({ ...m, from: ps[0]!, via: ps.slice(1, -1), to: ps[ps.length - 1]! })
|
|
155
|
+
|
|
156
|
+
/** the curve through every point, one piece between each two: each piece ends on its point, and the last handle lies
|
|
157
|
+
* on the line from the point before the tip, so the head turns as the last segment does */
|
|
158
|
+
export function arrowCurve(ps: readonly Pt[]): Seg[] {
|
|
159
|
+
const at = (i: number): Pt => ps[Math.max(0, Math.min(ps.length - 1, i))]!
|
|
160
|
+
const out: Seg[] = []
|
|
161
|
+
for (let i = 0; i + 1 < ps.length; i++) {
|
|
162
|
+
const [a, b, c, d] = [at(i - 1), at(i), at(i + 1), at(i + 2)]
|
|
163
|
+
out.push({ c1: { x: b.x + (c.x - a.x) / 6, y: b.y + (c.y - a.y) / 6 }, c2: { x: c.x - (d.x - b.x) / 6, y: c.y - (d.y - b.y) / 6 }, to: c })
|
|
164
|
+
}
|
|
165
|
+
return out
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** the point at `t` (0 to 1) of a piece that starts at `from` */
|
|
169
|
+
export function onSeg(from: Pt, s: Seg, t: number): Pt {
|
|
170
|
+
const u = 1 - t
|
|
171
|
+
const [k0, k1, k2, k3] = [u * u * u, 3 * u * u * t, 3 * u * t * t, t * t * t]
|
|
172
|
+
return { x: k0 * from.x + k1 * s.c1.x + k2 * s.c2.x + k3 * s.to.x, y: k0 * from.y + k1 * s.c1.y + k2 * s.c2.y + k3 * s.to.y }
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** the curve as close points, each with the piece it lies on */
|
|
176
|
+
export function arrowSamples(ps: readonly Pt[], per = 24): { p: Pt; seg: number }[] {
|
|
177
|
+
const out: { p: Pt; seg: number }[] = [{ p: ps[0]!, seg: 0 }]
|
|
178
|
+
arrowCurve(ps).forEach((s, i) => {
|
|
179
|
+
for (let k = 1; k <= per; k++) out.push({ p: onSeg(ps[i]!, s, k / per), seg: i })
|
|
180
|
+
})
|
|
181
|
+
return out
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** the way the head points, in radians: along the last segment, into the tip */
|
|
185
|
+
export function headAngle(ps: readonly Pt[]): number {
|
|
186
|
+
const segs = arrowCurve(ps)
|
|
187
|
+
const last = segs[segs.length - 1]!
|
|
188
|
+
return Math.atan2(last.to.y - last.c2.y, last.to.x - last.c2.x)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** the box the curve itself covers, no stroke around it */
|
|
192
|
+
export function arrowExtent(m: Arrow): Box {
|
|
193
|
+
const ps = arrowSamples(arrowPoints(m)).map((s) => s.p)
|
|
194
|
+
const xs = ps.map((p) => p.x)
|
|
195
|
+
const ys = ps.map((p) => p.y)
|
|
196
|
+
const x = Math.min(...xs)
|
|
197
|
+
const y = Math.min(...ys)
|
|
198
|
+
return { x, y, w: Math.max(...xs) - x, h: Math.max(...ys) - y }
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** the point of the curve nearest `p`, the piece it lies on, and how far it is */
|
|
202
|
+
export function nearestOnArrow(m: Arrow, p: Pt): { at: Pt; seg: number; dist: number } {
|
|
203
|
+
const ps = arrowPoints(m)
|
|
204
|
+
const segs = arrowCurve(ps)
|
|
205
|
+
const N = 32
|
|
206
|
+
let best = { at: m.from, seg: 0, t: 0, dist: Infinity }
|
|
207
|
+
const consider = (seg: number, t: number): void => {
|
|
208
|
+
const q = onSeg(ps[seg]!, segs[seg]!, t)
|
|
209
|
+
const d = Math.hypot(q.x - p.x, q.y - p.y)
|
|
210
|
+
if (d < best.dist) best = { at: q, seg, t, dist: d }
|
|
211
|
+
}
|
|
212
|
+
segs.forEach((_, i) => {
|
|
213
|
+
for (let k = 0; k <= N; k++) consider(i, k / N)
|
|
214
|
+
})
|
|
215
|
+
// then finer around the closest: a point lands on the line, not a sample's step off it
|
|
216
|
+
for (let step = 1 / N; step > 1e-4; step /= 4) {
|
|
217
|
+
const { seg, t } = best
|
|
218
|
+
for (let k = -4; k <= 4; k++) consider(seg, Math.max(0, Math.min(1, t + (k * step) / 4)))
|
|
219
|
+
}
|
|
220
|
+
return { at: best.at, seg: best.seg, dist: best.dist }
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** the arrow with a new point where its curve passes nearest `p`, between the two points of that piece */
|
|
224
|
+
export function addArrowPoint(m: Arrow, p: Pt): Arrow {
|
|
225
|
+
const n = nearestOnArrow(m, p)
|
|
226
|
+
const ps = arrowPoints(m)
|
|
227
|
+
ps.splice(n.seg + 1, 0, { x: Math.round(n.at.x), y: Math.round(n.at.y) })
|
|
228
|
+
return withPoints(m, ps)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** the arrow with its point `k` (arrowPoints' order) at `p` */
|
|
232
|
+
export const moveArrowPoint = (m: Arrow, k: number, p: Pt): Arrow => withPoints(m, arrowPoints(m).map((q, j) => (j === k ? { x: Math.round(p.x), y: Math.round(p.y) } : q)))
|
|
233
|
+
|
|
234
|
+
/** the arrow without its middle point `k`; its tail and its point always stay */
|
|
235
|
+
export const removeArrowPoint = (m: Arrow, k: number): Arrow => (k <= 0 || k > m.via.length ? m : withPoints(m, arrowPoints(m).filter((_, j) => j !== k)))
|
|
236
|
+
|
|
237
|
+
/** the arrow's point within `r` of `p` (arrowPoints' order), the nearest; null when none is */
|
|
238
|
+
export function arrowPointAt(m: Arrow, p: Pt, r: number): number | null {
|
|
239
|
+
let best: number | null = null
|
|
240
|
+
let bd = r
|
|
241
|
+
arrowPoints(m).forEach((q, k) => {
|
|
242
|
+
const d = Math.hypot(q.x - p.x, q.y - p.y)
|
|
243
|
+
if (d <= bd) {
|
|
244
|
+
best = k
|
|
245
|
+
bd = d
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
return best
|
|
249
|
+
}
|
|
@@ -9,23 +9,16 @@
|
|
|
9
9
|
// lines only: a substring scan of the whole file called any note mentioning
|
|
10
10
|
// "proposed change" a malformed request, and satisfied `scope claimed` from
|
|
11
11
|
// ordinary prose.
|
|
12
|
-
import {
|
|
12
|
+
import { readdirSync, readFileSync } from 'fs'
|
|
13
13
|
import { join } from 'path'
|
|
14
14
|
import { mainCheckoutOf } from '../core/foreign.ts'
|
|
15
15
|
import { LAYOUT } from '../core/layout.ts'
|
|
16
|
-
import { LEGACY_CONTRACT_PREFIX } from '../core/migrate-layout.ts'
|
|
17
16
|
|
|
18
17
|
export const REFLECTIONS_DIR = LAYOUT.reflections
|
|
19
18
|
|
|
20
19
|
/** where a repo's queue sits: its main checkout's, from a lane worktree too, since the folder is gitignored and dies with
|
|
21
|
-
* the worktree while its link lives in the repo's one thread store
|
|
22
|
-
|
|
23
|
-
* the old layout */
|
|
24
|
-
export const queueDir = (root: string): string => {
|
|
25
|
-
const main = mainCheckoutOf(root)
|
|
26
|
-
const legacy = join(main, `${LEGACY_CONTRACT_PREFIX}reflections`)
|
|
27
|
-
return !existsSync(join(main, REFLECTIONS_DIR)) && existsSync(legacy) ? legacy : join(main, REFLECTIONS_DIR)
|
|
28
|
-
}
|
|
20
|
+
* the worktree while its link lives in the repo's one thread store */
|
|
21
|
+
export const queueDir = (root: string): string => join(mainCheckoutOf(root), REFLECTIONS_DIR)
|
|
29
22
|
|
|
30
23
|
export const REQUEST_SECTIONS = [
|
|
31
24
|
'what i was doing',
|
package/src/release/notes.ts
CHANGED
|
@@ -81,7 +81,7 @@ function folderNotes(root: string, u: ReleaseUnit, dir: string): UnitNotes {
|
|
|
81
81
|
},
|
|
82
82
|
promote: (v, date) => {
|
|
83
83
|
if (nextError != null) return { error: nextError }
|
|
84
|
-
if (next == null) return { error: `${rel} has no ${fileOf(NEXT)}:
|
|
84
|
+
if (next == null) return { error: `${rel} has no ${fileOf(NEXT)}: sk releases check --write-template writes one to fill, then bump` }
|
|
85
85
|
if (existsSync(join(dir, fileOf(v)))) return { error: `${rel}/${fileOf(v)} exists already: that version is written` }
|
|
86
86
|
let done: Release
|
|
87
87
|
try {
|