rvlib-shipkit 2.26.0 → 2.27.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 +20 -0
- package/package.json +1 -1
- package/src/agent-time/diet.ts +77 -0
- package/src/agent-time/family.ts +72 -0
- package/src/agent-time/hooks.ts +6 -4
- package/src/agent-time/limits.ts +44 -0
- package/src/agent-time/live.ts +1 -3
- package/src/agent-time/mask.ts +96 -18
- package/src/agent-time/refused.ts +45 -0
- package/src/agent-time/render.ts +122 -21
- package/src/agent-time/report-cache.ts +57 -0
- package/src/agent-time/report.ts +314 -40
- package/src/agent-time/shape.ts +50 -3
- package/src/agent-time/store.ts +320 -99
- package/src/agent-time/timeline.ts +140 -21
- package/src/agent-time/turns.ts +18 -8
- package/src/annex/offload.ts +17 -6
- package/src/annex/tidy.ts +70 -10
- package/src/asks/ask-after.ts +40 -0
- package/src/asks/asks-queue.ts +205 -47
- package/src/assets/kit-config.ts +7 -3
- package/src/assets/kits/identity-kit.ts +289 -10
- package/src/check.ts +3 -1
- package/src/checks/SK004-gitignore-policy.check.ts +12 -5
- package/src/checks/SK013-one-way-in-policy.check.ts +8 -3
- package/src/checks/SK026-asks-autoclose.check.ts +5 -5
- package/src/checks/SK028-readme.check.ts +7 -66
- package/src/checks/SK030-cache-audit.check.ts +6 -1
- package/src/checks/SK031-trace-audit.check.ts +2 -0
- package/src/checks/SK033-global-contribution.check.ts +3 -1
- package/src/checks/SK035-public-clean.check.ts +2 -2
- package/src/checks/SK043-scratch-on-the-mac.check.ts +59 -4
- package/src/checks/SK047-login-in-description.check.ts +36 -0
- package/src/checks/SK048-one-local-file.check.ts +36 -0
- package/src/cli/cmd_Asks.ts +71 -5
- package/src/cli/cmd_Backup.ts +2 -2
- package/src/cli/cmd_Capacity.ts +2 -2
- package/src/cli/cmd_CrossRepoActivity.ts +5 -4
- package/src/cli/cmd_Db.ts +253 -0
- package/src/cli/cmd_History.ts +212 -0
- package/src/cli/cmd_Home.ts +31 -3
- package/src/cli/cmd_Hq.ts +516 -0
- package/src/cli/cmd_Machines.ts +36 -0
- package/src/cli/cmd_Media.ts +38 -6
- package/src/cli/cmd_Reflect.ts +23 -2
- package/src/cli/cmd_Review.ts +548 -116
- package/src/cli/cmd_Secret.ts +62 -12
- package/src/cli/cmd_Social.ts +83 -1
- package/src/cli/cmd_Space.ts +324 -0
- package/src/cli/cmd_Time.ts +76 -5
- package/src/cli/cmd_Tmp.ts +28 -4
- package/src/cli/cmd_Trailer.ts +14 -10
- package/src/cli/cmd_Urls.ts +56 -0
- package/src/cli/cmd_Vault.ts +583 -0
- package/src/cli/family-help.ts +4 -2
- package/src/cli/family-pages.ts +1 -1
- package/src/cli/registry.ts +24 -3
- package/src/collections/actions.ts +63 -13
- package/src/collections/collection-types.ts +23 -1
- package/src/collections/providers.ts +117 -23
- package/src/collections/review.ts +4 -4
- package/src/contracts/contract-manifests.ts +6 -5
- package/src/contracts/contract-types.ts +6 -4
- package/src/contracts/contracts-engine.ts +11 -0
- package/src/contracts/manifests/chrome-web-store.contract.ts +31 -0
- package/src/core/budget.ts +12 -17
- package/src/core/capacity.ts +27 -18
- package/src/core/check-runner.ts +7 -4
- package/src/core/layout.ts +3 -0
- package/src/core/machine-busy.ts +127 -0
- package/src/core/machine-commit.ts +6 -1
- package/src/core/machine-db.ts +368 -20
- package/src/core/machine-layout.ts +137 -0
- package/src/core/machine-read.ts +81 -0
- package/src/core/migrate-layout.ts +1 -1
- package/src/core/one-way-in-policy.ts +64 -7
- package/src/core/polling-policy.ts +27 -0
- package/src/core/retention.ts +16 -2
- package/src/core/scope.ts +107 -14
- package/src/core/slots.ts +5 -4
- package/src/drill/clean.ts +25 -1
- package/src/drill/run.ts +1 -1
- package/src/drill/seal.ts +27 -4
- package/src/home/activity-shape.ts +2 -0
- package/src/home/activity.ts +66 -3
- package/src/home/app-sign.ts +15 -4
- package/src/home/daemon-jobs.ts +149 -7
- package/src/home/database-projects.ts +111 -0
- package/src/home/database-words.ts +203 -0
- package/src/home/databases.ts +460 -0
- package/src/home/global-units.ts +6 -0
- package/src/home/gui-app/ShipkitGui.swift +122 -1
- package/src/home/gui-app.ts +6 -3
- package/src/home/home-move.ts +514 -0
- package/src/home/home-paths.ts +12 -3
- package/src/home/home-routes.ts +68 -0
- package/src/home/inbox-shape.ts +24 -14
- package/src/home/machine-fold.ts +820 -0
- package/src/home/machine-host.ts +20 -5
- package/src/home/machine-repair.ts +503 -0
- package/src/home/machine-stores.ts +66 -15
- package/src/home/machine-temp.ts +547 -86
- package/src/home/resume.ts +79 -0
- package/src/home/run-daemon.ts +25 -4
- package/src/home/run-pm.ts +18 -5
- package/src/home/serve-daemon.ts +18 -3
- package/src/home/serve-web.ts +175 -7
- package/src/home/space-job.ts +115 -0
- package/src/home/space-page.ts +257 -0
- package/src/home/space-route.ts +167 -0
- package/src/home/space-words.ts +103 -0
- package/src/home/time-page-shape.ts +202 -0
- package/src/home/time-page.ts +64 -0
- package/src/home/vault-page.ts +482 -0
- package/src/home/vault-words.ts +132 -0
- package/src/hooks/leak-guard.ts +40 -13
- package/src/hooks/one-way-in-guard.ts +17 -4
- package/src/hq/cards.ts +581 -0
- package/src/hq/door-route.ts +43 -0
- package/src/hq/door.ts +163 -0
- package/src/hq/files-send.ts +348 -0
- package/src/hq/forgotten-log.ts +35 -0
- package/src/hq/history-check.ts +255 -0
- package/src/hq/history-place.ts +146 -0
- package/src/hq/history-send.ts +487 -0
- package/src/hq/hq-db.ts +99 -0
- package/src/hq/hq-local.ts +469 -0
- package/src/hq/hq-routes.ts +196 -0
- package/src/hq/hq-store.ts +599 -0
- package/src/hq/kinds/ask.ts +147 -0
- package/src/hq/kinds/card-gone.ts +83 -0
- package/src/hq/kinds/card-msg.ts +66 -0
- package/src/hq/kinds/card.ts +99 -0
- package/src/hq/kinds/index.ts +21 -0
- package/src/hq/kinds/kind.ts +126 -0
- package/src/hq/kinds/media.ts +125 -0
- package/src/hq/kinds/prompt.ts +219 -0
- package/src/hq/kinds/reflection.ts +128 -0
- package/src/hq/kinds/report.ts +55 -0
- package/src/hq/kinds/time-day.ts +236 -0
- package/src/hq/ledger.ts +473 -0
- package/src/hq/machine-key.ts +44 -0
- package/src/hq/machine-notes.ts +131 -0
- package/src/hq/outbox.ts +372 -0
- package/src/hq/replica.ts +168 -0
- package/src/hq/repo-id.ts +4 -0
- package/src/hq/report-facts.ts +117 -0
- package/src/hq/report.ts +274 -0
- package/src/hq/switch.ts +151 -0
- package/src/hq/vault-grant.ts +92 -0
- package/src/identities/identities.ts +15 -3
- package/src/identities/steps.ts +31 -0
- package/src/ledger/db.ts +73 -26
- package/src/ledger/gate-checks.ts +6 -2
- package/src/ledger/run-log.ts +11 -3
- package/src/ledger/store.ts +26 -4
- package/src/media-store/backup/daemon.ts +25 -17
- package/src/media-store/backup/kept.ts +241 -0
- package/src/media-store/backup/restore.ts +14 -4
- package/src/media-store/backup/run.ts +11 -11
- package/src/media-store/backup/secret.ts +6 -4
- package/src/media-store/backup/snapshot.ts +4 -2
- package/src/media-store/backup/sources.ts +67 -16
- package/src/media-store/copy/config.ts +77 -0
- package/src/media-store/copy/copy.ts +194 -0
- package/src/media-store/copy/lifecycle.ts +43 -0
- package/src/media-store/copy/night.ts +90 -0
- package/src/media-store/copy/proof.ts +151 -0
- package/src/media-store/copy/snapshot.ts +152 -0
- package/src/media-store/copy/store.ts +62 -0
- package/src/media-store/copy/stream.ts +176 -0
- package/src/media-store/daemon.ts +66 -16
- package/src/media-store/db.ts +22 -11
- package/src/media-store/forget.ts +23 -3
- package/src/media-store/hand.ts +4 -3
- package/src/media-store/hq-find.ts +75 -0
- package/src/media-store/hq-send.ts +277 -0
- package/src/media-store/kind.ts +2 -0
- package/src/media-store/purge.ts +18 -15
- package/src/media-store/put.ts +24 -8
- package/src/media-store/remote.ts +16 -7
- package/src/media-store/space-listing.ts +240 -0
- package/src/media-store/space.ts +40 -21
- package/src/media-store/sync.ts +5 -5
- package/src/media-store/tidy.ts +98 -0
- package/src/media-store/upload.ts +3 -3
- package/src/media-store/webp.ts +66 -0
- package/src/messages/model.ts +16 -7
- package/src/messages/routes.ts +14 -4
- package/src/messages/score.ts +2 -2
- package/src/messages/suggest.ts +96 -0
- package/src/pages/frame-client.ts +10 -0
- package/src/plan/planner.ts +28 -17
- package/src/recordings/media-kind.ts +1 -0
- package/src/recordings/model.ts +1 -1
- package/src/recordings/recorder-app/Capture.swift +9 -7
- package/src/reflect/hq-corpus.ts +56 -0
- package/src/reflect/prompt-corpus.ts +3 -1
- package/src/reflect/transcript.ts +129 -37
- package/src/release/machine-words.ts +67 -0
- package/src/release/public-clean.ts +8 -3
- package/src/releases/from-card.ts +1 -1
- package/src/releases/routes.ts +10 -5
- package/src/releases/store.ts +10 -1
- package/src/repo-config.ts +32 -2
- package/src/review/anim.ts +2 -2
- package/src/review/auto.ts +2 -2
- package/src/review/card-db.ts +244 -0
- package/src/review/card-rows.ts +266 -0
- package/src/review/cells.ts +76 -5
- package/src/review/draft-card.ts +41 -0
- package/src/review/draft-model.ts +78 -0
- package/src/review/format.ts +29 -10
- package/src/review/gone.ts +98 -0
- package/src/review/inbox-hook.ts +4 -4
- package/src/review/marks.ts +1 -1
- package/src/review/media-kind.ts +7 -5
- package/src/review/media-read.ts +9 -7
- package/src/review/media.ts +32 -5
- package/src/review/model.ts +202 -39
- package/src/review/move.ts +491 -0
- package/src/review/notes.ts +12 -20
- package/src/review/previews.ts +15 -19
- package/src/review/project.ts +1 -1
- package/src/review/rev.ts +8 -0
- package/src/review/role.ts +1 -1
- package/src/review/routes.ts +64 -13
- package/src/review/stage-card.ts +8 -4
- package/src/review/stage-routes.ts +1 -1
- package/src/review/store.ts +529 -83
- package/src/review/thread-fold.ts +51 -0
- package/src/review/threads.ts +147 -9
- package/src/review/trailer-auto-mock.ts +63 -0
- package/src/review/trailer-card.ts +4 -4
- package/src/review/trailer-desk.ts +41 -7
- package/src/review/trailer-media.ts +1 -0
- package/src/review/trailer-model.ts +8 -0
- package/src/review/trailer-notes.ts +1 -1
- package/src/review/trailer-routes.ts +9 -1
- package/src/review/unit.ts +6 -6
- package/src/review/watchers.ts +1 -1
- package/src/rules/untrack-generated.ts +92 -8
- package/src/secrets/held.ts +16 -0
- package/src/secrets/keychain.ts +113 -0
- package/src/secrets/list.ts +16 -6
- package/src/secrets/manager.ts +24 -10
- package/src/secrets/read.ts +257 -0
- package/src/secrets/who-reads.ts +49 -0
- package/src/serve/door-forward.ts +268 -0
- package/src/serve/door-names.ts +47 -0
- package/src/serve/embed.ts +1 -1
- package/src/serve/hub-app/activity-view.tsx +56 -32
- package/src/serve/hub-app/activity.css +7 -1
- package/src/serve/hub-app/asks-page.tsx +48 -0
- package/src/serve/hub-app/asks-st.ts +25 -0
- package/src/serve/hub-app/clock-svc.ts +1 -2
- package/src/serve/hub-app/col-card.tsx +64 -13
- package/src/serve/hub-app/col-list-page.tsx +122 -0
- package/src/serve/hub-app/col-list-st.ts +103 -0
- package/src/serve/hub-app/col-tables-view.tsx +10 -41
- package/src/serve/hub-app/col-tables.ts +76 -8
- package/src/serve/hub-app/cols-svc.ts +70 -16
- package/src/serve/hub-app/database-st.ts +260 -0
- package/src/serve/hub-app/database-view.tsx +289 -0
- package/src/serve/hub-app/database.css +32 -0
- package/src/serve/hub-app/entry-bar.css +14 -0
- package/src/serve/hub-app/entry-bar.tsx +33 -0
- package/src/serve/hub-app/entry-pick.ts +31 -0
- package/src/serve/hub-app/floating.tsx +1 -0
- package/src/serve/hub-app/hash-route.ts +11 -1
- package/src/serve/hub-app/header-bar.tsx +14 -18
- package/src/serve/hub-app/home-st.ts +89 -9
- package/src/serve/hub-app/home-strip.css +5 -19
- package/src/serve/hub-app/home-strip.tsx +58 -92
- package/src/serve/hub-app/home.html +7 -0
- package/src/serve/hub-app/hub-app.tsx +31 -142
- package/src/serve/hub-app/hub-types.ts +3 -1
- package/src/serve/hub-app/hub.css +109 -23
- package/src/serve/hub-app/icons.tsx +18 -1
- package/src/serve/hub-app/identities-st.ts +56 -6
- package/src/serve/hub-app/identities-view.tsx +100 -58
- package/src/serve/hub-app/identities.css +17 -15
- package/src/serve/hub-app/identity-address.ts +5 -0
- package/src/serve/hub-app/inbox-st.ts +41 -24
- package/src/serve/hub-app/inbox-view.tsx +37 -41
- package/src/serve/hub-app/inbox.css +2 -5
- package/src/serve/hub-app/index.html +7 -0
- package/src/serve/hub-app/kept-cols.tsx +7 -0
- package/src/serve/hub-app/keys.ts +28 -15
- package/src/serve/hub-app/later.tsx +26 -0
- package/src/serve/hub-app/list-filter.tsx +14 -0
- package/src/serve/hub-app/list-walk.ts +72 -3
- package/src/serve/hub-app/machines-st.ts +251 -0
- package/src/serve/hub-app/machines-view.tsx +224 -0
- package/src/serve/hub-app/machines.css +76 -0
- package/src/serve/hub-app/md-copy.tsx +79 -0
- package/src/serve/hub-app/media-view.tsx +2 -0
- package/src/serve/hub-app/messages/messages-page.tsx +79 -7
- package/src/serve/hub-app/messages/messages-st.ts +99 -3
- package/src/serve/hub-app/messages.css +14 -0
- package/src/serve/hub-app/page-keys.ts +175 -0
- package/src/serve/hub-app/pages-frames.tsx +11 -3
- package/src/serve/hub-app/palette-st.ts +58 -11
- package/src/serve/hub-app/palette-view.tsx +3 -1
- package/src/serve/hub-app/project-list.css +54 -8
- package/src/serve/hub-app/project-list.tsx +128 -59
- package/src/serve/hub-app/projects-svc.ts +78 -7
- package/src/serve/hub-app/reader-chips.tsx +13 -0
- package/src/serve/hub-app/readme-view.tsx +2 -3
- package/src/serve/hub-app/readme.css +27 -5
- package/src/serve/hub-app/reflections-page.tsx +42 -0
- package/src/serve/hub-app/reflections-st.ts +17 -0
- package/src/serve/hub-app/releases/releases-page.tsx +25 -2
- package/src/serve/hub-app/releases/releases-st.ts +1 -1
- package/src/serve/hub-app/repo-sections.ts +9 -5
- package/src/serve/hub-app/repo-st.ts +35 -8
- package/src/serve/hub-app/review/draft-card.tsx +163 -0
- package/src/serve/hub-app/review/kit.tsx +50 -7
- package/src/serve/hub-app/review/note-place.ts +1 -1
- package/src/serve/hub-app/review/review-board.tsx +2 -2
- package/src/serve/hub-app/review/review-cells.tsx +145 -65
- package/src/serve/hub-app/review/review-kit.ts +27 -1
- package/src/serve/hub-app/review/review-list.tsx +68 -30
- package/src/serve/hub-app/review/review-page.tsx +7 -8
- package/src/serve/hub-app/review/review-st.ts +111 -24
- package/src/serve/hub-app/review/review-thread.tsx +49 -19
- package/src/serve/hub-app/review/review-views.tsx +475 -144
- package/src/serve/hub-app/review/thread-control-st.ts +115 -0
- package/src/serve/hub-app/review/thread-control.tsx +74 -0
- package/src/serve/hub-app/review/thread-st.ts +73 -26
- package/src/serve/hub-app/review/trailer-card.tsx +1 -1
- package/src/serve/hub-app/review/trailer-page.tsx +37 -16
- package/src/serve/hub-app/review/trailer-st.ts +41 -7
- package/src/serve/hub-app/review.css +267 -61
- package/src/serve/hub-app/side-lists.ts +72 -0
- package/src/serve/hub-app/sidebar.tsx +6 -3
- package/src/serve/hub-app/site/site-part.tsx +2 -8
- package/src/serve/hub-app/site/site-st.ts +4 -4
- package/src/serve/hub-app/social/comms-page.tsx +20 -5
- package/src/serve/hub-app/social/kit.tsx +30 -4
- package/src/serve/hub-app/social/post-card.tsx +139 -49
- package/src/serve/hub-app/social/serial-writes.ts +13 -0
- package/src/serve/hub-app/social/social-model.ts +11 -0
- package/src/serve/hub-app/social/social-page.tsx +94 -35
- package/src/serve/hub-app/social/social-st.ts +120 -36
- package/src/serve/hub-app/social/stage-popup.tsx +1 -1
- package/src/serve/hub-app/social/stage-st.ts +1 -1
- package/src/serve/hub-app/social/step-layout.ts +1 -1
- package/src/serve/hub-app/social.css +3 -0
- package/src/serve/hub-app/space-st.ts +209 -0
- package/src/serve/hub-app/space-view.tsx +196 -0
- package/src/serve/hub-app/space.css +27 -0
- package/src/serve/hub-app/stores/stores-page.tsx +91 -23
- package/src/serve/hub-app/stores/stores-st.ts +44 -19
- package/src/serve/hub-app/stores.css +6 -1
- package/src/serve/hub-app/theme-st.ts +22 -9
- package/src/serve/hub-app/time-charts.tsx +291 -0
- package/src/serve/hub-app/time-pages.tsx +749 -0
- package/src/serve/hub-app/time-st.ts +162 -0
- package/src/serve/hub-app/time-view.tsx +76 -0
- package/src/serve/hub-app/time.css +138 -0
- package/src/serve/hub-app/tree-build.ts +52 -42
- package/src/serve/hub-app/tree-row.tsx +4 -4
- package/src/serve/hub-app/tree-svc.ts +18 -9
- package/src/serve/hub-app/urls-svc.ts +154 -0
- package/src/serve/hub-app/urls-view.tsx +117 -0
- package/src/serve/hub-app/urls.css +30 -0
- package/src/serve/hub-app/vault-st.ts +127 -0
- package/src/serve/hub-app/vault-view.tsx +154 -0
- package/src/serve/hub-app/vault.css +38 -0
- package/src/serve/hub-app/veille/veille-st.ts +12 -10
- package/src/serve/hub-app/waiting-svc.ts +29 -0
- package/src/serve/hub-app/wikis-view.tsx +2 -2
- package/src/serve/hub-runtime.ts +15 -2
- package/src/serve/project-gutter-route.ts +27 -14
- package/src/serve/project-gutter.ts +25 -12
- package/src/serve/same-origin.ts +10 -0
- package/src/serve/serve-hub.ts +13 -4
- package/src/shipkit-files.ts +16 -2
- package/src/shipkit.ts +1 -1
- package/src/shot/shooter.ts +616 -420
- package/src/shot/shot-ask.ts +246 -155
- package/src/site/desk.ts +2 -2
- package/src/smoke/run-smoke.ts +3 -2
- package/src/social/cover.ts +202 -0
- package/src/social/discord-layout.ts +37 -13
- package/src/social/drafts.ts +3 -0
- package/src/social/load.ts +23 -2
- package/src/social/media-kind.ts +2 -1
- package/src/social/publish/discord.ts +5 -2
- package/src/social/publish/secret.ts +2 -2
- package/src/social/release-stage.ts +28 -13
- package/src/social/routes.ts +26 -1
- package/src/social/stage.ts +1 -1
- package/src/social/stats.ts +12 -9
- package/src/social/strip.ts +4 -1
- package/src/social/thumbnail.ts +255 -0
- package/src/stores/collection.ts +15 -11
- package/src/stores/desk.ts +236 -42
- package/src/stores/model.ts +72 -6
- package/src/stores/routes.ts +37 -12
- package/src/stores/unit.ts +14 -8
- package/src/suite/judge-suites.ts +41 -11
- package/src/suite/select.ts +45 -3
- package/src/suite/suite-cli.ts +16 -10
- package/src/trailer/bed.ts +1 -1
- package/src/trailer/build.ts +134 -21
- package/src/trailer/ffmpeg.ts +7 -0
- package/src/trailer/fonts.ts +3 -2
- package/src/trailer/grammar.ts +201 -2
- package/src/trailer/graph.ts +42 -5
- package/src/trailer/look.ts +21 -0
- package/src/trailer/mock.ts +154 -0
- package/src/trailer/passage.ts +65 -26
- package/src/trailer/score/heard.ts +89 -0
- package/src/trailer/score/sound.ts +14 -8
- package/src/trailer/sound/run.ts +16 -6
- package/src/trailer/stitch.ts +26 -5
- package/src/trailer/titles.ts +82 -19
- package/src/trailer/versions.ts +1 -3
- package/src/trailer/vertical.ts +3 -1
- package/src/urls/frame.ts +195 -0
- package/src/urls/routes.ts +43 -0
- package/src/urls/rows.ts +171 -0
- package/src/urls/unit.ts +73 -0
- package/src/vault/house-keys.ts +42 -0
- package/src/vault/layout.ts +50 -0
- package/src/vault/policy.ts +165 -0
- package/src/vault/vault-audit.ts +276 -0
- package/src/vault/vault-client.ts +40 -0
- package/src/vault/vault-config.ts +159 -0
- package/src/vault/vault-destroy.ts +78 -0
- package/src/vault/vault-handover.ts +305 -0
- package/src/vault/vault-http.ts +352 -0
- package/src/vault/vault-import.ts +208 -0
- package/src/vault/vault-init.ts +328 -0
- package/src/vault/vault-minter.ts +271 -0
- package/src/vault/vault-restore.ts +333 -0
- package/src/vault/vault-serve.ts +342 -0
- package/src/vault/vault-snapshot.ts +281 -0
- package/src/veille/asks.ts +1 -1
- package/src/veille/desk.ts +2 -2
package/src/messages/model.ts
CHANGED
|
@@ -8,7 +8,8 @@ import { join } from 'node:path'
|
|
|
8
8
|
export const MESSAGES_DIR = '.shipkit/messages'
|
|
9
9
|
|
|
10
10
|
export type Candidate = { id: string; text: string; source: string; words: number; seconds: number }
|
|
11
|
-
|
|
11
|
+
/** `toFill`: the fields written with no value (`- truth:`), a slot an agent or the owner completes */
|
|
12
|
+
export type Message = { id: string; title: string; fields: Record<string, string>; toFill: string[]; candidates: Candidate[] }
|
|
12
13
|
export type Persona = { id: string; kind: 'reader' | 'gatekeeper'; who: string }
|
|
13
14
|
/** `shot`: a trailer line's surface, the picture it sits over (a title or the narrator's line in a 1 to 2 s cut) */
|
|
14
15
|
export type Surface = { id: string; title: string; budget?: number; shot?: string; options: { id: string; headline: string; second: string }[] }
|
|
@@ -26,7 +27,7 @@ export function parseMessages(md: string): Message[] {
|
|
|
26
27
|
const out: Message[] = []
|
|
27
28
|
for (const line of dropComments(md).split('\n')) {
|
|
28
29
|
const head = /^## ([\w-]+): (.+)$/.exec(line)
|
|
29
|
-
if (head) out.push({ id: head[1]!, title: head[2]!, fields: {}, candidates: [] })
|
|
30
|
+
if (head) out.push({ id: head[1]!, title: head[2]!, fields: {}, toFill: [], candidates: [] })
|
|
30
31
|
const cur = out.at(-1)
|
|
31
32
|
if (!cur || head) continue
|
|
32
33
|
const cand = /^- `([\w-]+)` "([^"]+)"\s*(.*)$/.exec(line)
|
|
@@ -35,8 +36,10 @@ export function parseMessages(md: string): Message[] {
|
|
|
35
36
|
cur.candidates.push({ id: cand[1]!, text: cand[2]!, source: cand[3]!, words, seconds: Math.round((words / WORDS_A_SECOND) * 10) / 10 })
|
|
36
37
|
continue
|
|
37
38
|
}
|
|
38
|
-
const field = /^- (\w+):
|
|
39
|
-
|
|
39
|
+
const field = /^- (\w+):(.*)$/.exec(line)
|
|
40
|
+
const value = field?.[2]!.trim()
|
|
41
|
+
if (field && value) cur.fields[field[1]!] = value
|
|
42
|
+
else if (field) cur.toFill.push(field[1]!)
|
|
40
43
|
}
|
|
41
44
|
return out
|
|
42
45
|
}
|
|
@@ -105,7 +108,8 @@ export function lint(messages: Message[], guard: Guard): string[] {
|
|
|
105
108
|
const out: string[] = []
|
|
106
109
|
const seen = new Set<string>()
|
|
107
110
|
for (const m of messages) {
|
|
108
|
-
for (const k of
|
|
111
|
+
for (const k of m.toFill) out.push(`${m.id}: ${k} to fill`)
|
|
112
|
+
for (const k of ['meaning', 'value']) if (!m.fields[k] && !m.toFill.includes(k)) out.push(`${m.id}: no ${k}`)
|
|
109
113
|
if (!m.candidates.length) out.push(`${m.id}: no candidate`)
|
|
110
114
|
for (const c of m.candidates) {
|
|
111
115
|
if (seen.has(c.id)) out.push(`${c.id}: the id is used twice`)
|
|
@@ -131,16 +135,21 @@ export function lintSurfaces(surfaces: Surface[], guard: Guard): string[] {
|
|
|
131
135
|
}
|
|
132
136
|
|
|
133
137
|
/** the store's files read whole; a store with no personas.md or surfaces.md reads as none */
|
|
134
|
-
|
|
138
|
+
/** `hash`: messages.md as read, so a write from the page refuses a file that changed under it (suggest.ts) */
|
|
139
|
+
export type Store = { dir: string; hash: string; messages: Message[]; personas: Persona[]; surfaces: Surface[]; brief: Brief }
|
|
140
|
+
|
|
141
|
+
export const hashOf = (text: string): string => Bun.hash(text).toString(36)
|
|
135
142
|
|
|
136
143
|
const readIf = (f: string): string => (existsSync(f) ? readFileSync(f, 'utf8') : '')
|
|
137
144
|
|
|
138
145
|
export function readStore(root: string): Store {
|
|
139
146
|
const dir = join(root, MESSAGES_DIR)
|
|
140
147
|
if (!existsSync(join(dir, 'messages.md'))) throw new Error(`messages: no store here: write ${MESSAGES_DIR}/messages.md (wiki tools/shipkit/messages.md)`)
|
|
148
|
+
const md = readFileSync(join(dir, 'messages.md'), 'utf8')
|
|
141
149
|
return {
|
|
142
150
|
dir,
|
|
143
|
-
|
|
151
|
+
hash: hashOf(md),
|
|
152
|
+
messages: parseMessages(md),
|
|
144
153
|
personas: parsePersonas(readIf(join(dir, 'personas.md'))),
|
|
145
154
|
surfaces: parseSurfaces(readIf(join(dir, 'surfaces.md'))),
|
|
146
155
|
brief: parseBrief(readIf(join(dir, 'brief.md'))),
|
package/src/messages/routes.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
// the messages page's
|
|
2
|
-
//
|
|
1
|
+
// the messages page's routes (wiki tools/shipkit/messages.md, The page): the whole store read fresh on each load, and
|
|
2
|
+
// the owner's suggestions appended to messages.md (suggest.ts). Every other edit of the store is made as text
|
|
3
3
|
import { bad, NO_STORE } from '../review/http.ts'
|
|
4
4
|
import { storeView } from './score.ts'
|
|
5
|
+
import { Changed, suggest, type Suggestion } from './suggest.ts'
|
|
5
6
|
|
|
6
|
-
/** the messages
|
|
7
|
-
export function messagesRoutes(root: string, req: Request, path: string): Response | null {
|
|
7
|
+
/** the messages routes of the repo at `root`; null for any other path */
|
|
8
|
+
export async function messagesRoutes(root: string, req: Request, path: string): Promise<Response | null> {
|
|
9
|
+
if (path === '/api/messages/suggest' && req.method === 'POST') {
|
|
10
|
+
try {
|
|
11
|
+
const body = (await req.json()) as Suggestion & { expect?: string }
|
|
12
|
+
const made = suggest(root, body.expect, body)
|
|
13
|
+
return Response.json({ ...made, view: storeView(root) }, { headers: NO_STORE })
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return e instanceof Changed ? bad(e, 409) : bad(e, 400)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
8
18
|
if (path !== '/api/messages') return null
|
|
9
19
|
if (req.method !== 'GET') return bad(`messages: no route ${req.method} ${path}`, 404)
|
|
10
20
|
try {
|
package/src/messages/score.ts
CHANGED
|
@@ -153,7 +153,7 @@ export type RunView = {
|
|
|
153
153
|
notes: Record<string, string>
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
export type StoreView = Pick<Store, 'messages' | 'personas' | 'surfaces'> & { takeaways: Takeaway[]; runs: RunView[] }
|
|
156
|
+
export type StoreView = Pick<Store, 'hash' | 'messages' | 'personas' | 'surfaces'> & { takeaways: Takeaway[]; runs: RunView[] }
|
|
157
157
|
|
|
158
158
|
function runView(dir: string, id: string, takeaways: readonly Takeaway[]): RunView {
|
|
159
159
|
const readings = jsonsIn(join(dir, 'readings')).map((f) => [f.slice(0, -5), readJson<unknown[]>(join(dir, 'readings', f))] as const)
|
|
@@ -178,5 +178,5 @@ function runView(dir: string, id: string, takeaways: readonly Takeaway[]): RunVi
|
|
|
178
178
|
export function storeView(root: string): StoreView {
|
|
179
179
|
const s = readStore(root)
|
|
180
180
|
const runs = runsOf(s.dir).map((id) => runView(join(s.dir, 'runs', id), id, s.brief.takeaways))
|
|
181
|
-
return { messages: s.messages, personas: s.personas, surfaces: s.surfaces, takeaways: s.brief.takeaways, runs }
|
|
181
|
+
return { hash: s.hash, messages: s.messages, personas: s.personas, surfaces: s.surfaces, takeaways: s.brief.takeaways, runs }
|
|
182
182
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// the owner's suggestions from the messages page (wiki tools/shipkit/messages.md, The page): a message in the owner's words, or
|
|
2
|
+
// one more phrasing of a message, written into messages.md. Append only: every line already there stays byte for byte,
|
|
3
|
+
// and a write refuses a file that changed since the page read it (another session shares the tree)
|
|
4
|
+
import { readFileSync, writeFileSync } from 'node:fs'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
import { hashOf, MESSAGES_DIR, parseMessages } from './model.ts'
|
|
7
|
+
|
|
8
|
+
/** the source of a phrasing the owner wrote, as the store marks its sources */
|
|
9
|
+
export const OWNER = 'owner'
|
|
10
|
+
/** the fields a suggested message carries, each written empty when none was given: the lint and the page say « to fill » */
|
|
11
|
+
const FIELDS = ['meaning', 'value', 'truth', 'never'] as const
|
|
12
|
+
|
|
13
|
+
export type MessageSuggestion = { title: string; family?: string; meaning?: string; value?: string; phrasing?: string }
|
|
14
|
+
export type Suggestion = ({ kind: 'message' } & MessageSuggestion) | { kind: 'phrasing'; message: string; text: string }
|
|
15
|
+
|
|
16
|
+
/** one line: the store reads a field, a title or a phrasing up to its line's end */
|
|
17
|
+
const oneLine = (s: string | undefined): string => (s ?? '').replace(/\s+/g, ' ').trim()
|
|
18
|
+
/** a phrasing sits between straight quotes, so its own quotes turn typographic */
|
|
19
|
+
const quoted = (s: string): string => oneLine(s).replace(/"([^"]*)"/g, '“$1”').replace(/"/g, '”')
|
|
20
|
+
|
|
21
|
+
const STOP = new Set(['a', 'an', 'the', 'to', 'of', 'in', 'on', 'for', 'and', 'or', 'with', 'your', 'you', 'any', 'it', 'is', 'as', 'by', 'from', 'can', 'that', 'this', 'all', 'one'])
|
|
22
|
+
|
|
23
|
+
/** a message id from its title: two telling words, unique in the store */
|
|
24
|
+
function messageId(title: string, taken: Set<string>): string {
|
|
25
|
+
const words = title.toLowerCase().normalize('NFKD').replace(/[^a-z0-9\s]/g, ' ').split(/\s+/).filter((w) => w && !STOP.has(w))
|
|
26
|
+
const base = words.slice(0, 2).join('-') || 'message'
|
|
27
|
+
let id = base
|
|
28
|
+
for (let n = 2; taken.has(id); n++) id = `${base}-${n}`
|
|
29
|
+
return id
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** the next phrasing id under a prefix, past every id of the store that already uses it */
|
|
33
|
+
function nextUnder(prefix: string, ids: string[]): string {
|
|
34
|
+
const re = new RegExp(`^${prefix.replace(/[^\w]/g, '\\$&')}(\\d+)$`)
|
|
35
|
+
const top = Math.max(0, ...ids.map((i) => Number(re.exec(i)?.[1] ?? 0)))
|
|
36
|
+
return `${prefix}${top + 1}`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** the comments blanked line for line, so a line index of the parse is a line index of the file */
|
|
40
|
+
const lines = (md: string): string[] => md.replace(/<!--[\s\S]*?-->/g, (c) => c.replace(/[^\n]/g, ' ')).split('\n')
|
|
41
|
+
|
|
42
|
+
export function withMessage(md: string, s: MessageSuggestion): { md: string; id: string; phrasing?: string } {
|
|
43
|
+
const title = oneLine(s.title)
|
|
44
|
+
if (!title) throw new Error('a message needs its title')
|
|
45
|
+
const messages = parseMessages(md)
|
|
46
|
+
const ids = messages.flatMap((m) => m.candidates.map((c) => c.id))
|
|
47
|
+
const id = messageId(title, new Set(messages.map((m) => m.id)))
|
|
48
|
+
const text = quoted(s.phrasing ?? '')
|
|
49
|
+
const given: Record<string, string> = { meaning: oneLine(s.meaning), value: oneLine(s.value) }
|
|
50
|
+
const prefix = [...Array(id.length).keys()].map((n) => id.replace(/-/g, '').slice(0, n + 1)).find((p) => !ids.some((i) => new RegExp(`^${p}\\d+$`).test(i))) ?? id
|
|
51
|
+
const phrasing = text ? nextUnder(prefix, ids) : undefined
|
|
52
|
+
const family = oneLine(s.family)
|
|
53
|
+
const block = [
|
|
54
|
+
`## ${id}: ${title}`,
|
|
55
|
+
...(family ? [`- family: ${family}`] : []),
|
|
56
|
+
...FIELDS.map((k) => (given[k] ? `- ${k}: ${given[k]}` : `- ${k}:`)),
|
|
57
|
+
...(phrasing ? [`- \`${phrasing}\` "${text}" ${OWNER}`] : []),
|
|
58
|
+
]
|
|
59
|
+
const body = md.endsWith('\n') ? md : `${md}\n`
|
|
60
|
+
const gap = body.trim() === '' || body.endsWith('\n\n') ? '' : '\n'
|
|
61
|
+
return { md: `${body}${gap}${block.join('\n')}\n`, id, ...(phrasing ? { phrasing } : {}) }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function withPhrasing(md: string, message: string, raw: string): { md: string; id: string } {
|
|
65
|
+
const text = quoted(raw)
|
|
66
|
+
if (!text) throw new Error('a phrasing needs its words')
|
|
67
|
+
const m = parseMessages(md).find((x) => x.id === message)
|
|
68
|
+
if (!m) throw new Error(`messages.md has no message ${message}`)
|
|
69
|
+
const ids = parseMessages(md).flatMap((x) => x.candidates.map((c) => c.id))
|
|
70
|
+
const prefix = m.candidates[0]?.id.replace(/\d+$/, '') || m.id
|
|
71
|
+
const id = nextUnder(prefix, ids)
|
|
72
|
+
const ls = lines(md)
|
|
73
|
+
const head = ls.findIndex((l) => l.startsWith(`## ${message}: `))
|
|
74
|
+
const next = ls.findIndex((l, i) => i > head && l.startsWith('## '))
|
|
75
|
+
let at = (next === -1 ? ls.length : next) - 1
|
|
76
|
+
while (at > head && ls[at]!.trim() === '') at--
|
|
77
|
+
const raws = md.split('\n')
|
|
78
|
+
raws.splice(at + 1, 0, `- \`${id}\` "${text}" ${OWNER}`)
|
|
79
|
+
return { md: raws.join('\n'), id }
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** the suggestion written into the store at `root`, refused when messages.md is no longer the text hashed `expect` */
|
|
83
|
+
export function suggest(root: string, expect: string | undefined, s: Suggestion): { id: string; phrasing?: string } {
|
|
84
|
+
const file = join(root, MESSAGES_DIR, 'messages.md')
|
|
85
|
+
const md = readFileSync(file, 'utf8')
|
|
86
|
+
if (expect !== hashOf(md)) throw new Changed()
|
|
87
|
+
const { md: next, ...made } = s.kind === 'message' ? withMessage(md, s) : withPhrasing(md, s.message, s.text)
|
|
88
|
+
writeFileSync(file, next)
|
|
89
|
+
return made
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export class Changed extends Error {
|
|
93
|
+
constructor() {
|
|
94
|
+
super('messages.md changed since this page read it (another session edited it). The page shows it again now: check your words are still wanted, then send again')
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -31,6 +31,10 @@ export interface PageFrame {
|
|
|
31
31
|
setTitle(title: string, badge?: FrameBadge | null): void
|
|
32
32
|
/** another hub page, by its address (`#page:review:<id>`) */
|
|
33
33
|
open(hash: string): void
|
|
34
|
+
/** the threads that name one of the page's objects (wiki tools/shipkit/threads-page.md, A thread on any object) */
|
|
35
|
+
threads(address: string): void
|
|
36
|
+
/** his note on one of the page's objects: it goes into the thread its address has, else starts one, then opens */
|
|
37
|
+
note(address: string, name: string, text: string): void
|
|
34
38
|
stop(): void
|
|
35
39
|
}
|
|
36
40
|
|
|
@@ -108,6 +112,12 @@ export function frameClient(o: FrameOpts): PageFrame {
|
|
|
108
112
|
open(hash) {
|
|
109
113
|
up({ shipkit: 'open', hash })
|
|
110
114
|
},
|
|
115
|
+
threads(address) {
|
|
116
|
+
up({ shipkit: 'threads', address })
|
|
117
|
+
},
|
|
118
|
+
note(address, name, text) {
|
|
119
|
+
up({ shipkit: 'note', address, name, text })
|
|
120
|
+
},
|
|
111
121
|
stop() {
|
|
112
122
|
window.removeEventListener('message', onMessage)
|
|
113
123
|
window.removeEventListener('keydown', onKey)
|
package/src/plan/planner.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// is due next and why. The only thing that starts a run nobody asked for. A
|
|
3
3
|
// save makes the checks whose answer it moved `changed`; a check's `every` or
|
|
4
4
|
// `cron` makes it `scheduled`; a `wait` check of an inactive repo turns `late`
|
|
5
|
-
// and runs once the repo is active again
|
|
5
|
+
// and runs once the repo is active again, except a failed one, asked again
|
|
6
|
+
// once a day; a click or a terminal is `asked`.
|
|
6
7
|
//
|
|
7
8
|
// the one constraint a reader breaks first: the planner owns no clock. The host
|
|
8
9
|
// calls tick() on its own beat (the daemon's tick, or one interval in a hub of
|
|
@@ -13,11 +14,12 @@
|
|
|
13
14
|
// quiet (QUIET_MS, or MAX_WAIT_MS into a burst that never stops), a check a
|
|
14
15
|
// save moved waits COST_FACTOR times its last measured run and GATED_HOLD_MS
|
|
15
16
|
// after the latest gate someone else started in its repo, and nothing it
|
|
16
|
-
// starts on its own starts while
|
|
17
|
-
import { availableParallelism, loadavg } from 'os'
|
|
17
|
+
// starts on its own starts while every core is taken and has a queue (LOAD_MAX).
|
|
18
18
|
import { CATCH_UP_BEAT_MS, resumeCatchUp, type CatchUpStore } from './catch-up.ts'
|
|
19
19
|
import { nextDue, resolveCadence, resolveWhenInactive, stablePoint, type EveryValue, type LastResult, type PlanDecl } from './cadence.ts'
|
|
20
20
|
import { yieldLoop } from '../core/loop-watch.ts'
|
|
21
|
+
import { effectiveLoad, machineWords, type MachineLoad } from '../core/machine-busy.ts'
|
|
22
|
+
import { machineLoad } from '../core/machine-read.ts'
|
|
21
23
|
|
|
22
24
|
export type PlanReason = 'changed' | 'scheduled' | 'late' | 'asked'
|
|
23
25
|
|
|
@@ -93,18 +95,23 @@ export const MAX_WAIT_MS = 10 * 60_000
|
|
|
93
95
|
* measured run: a 30s suite at most every 10 minutes, a 200ms lint at once */
|
|
94
96
|
export const COST_FACTOR = 20
|
|
95
97
|
|
|
98
|
+
/** a failure on record in an inactive repo is asked again this often, even by
|
|
99
|
+
* a check that waits for its repo: a red nobody can refresh would stay for good */
|
|
100
|
+
export const RED_REASK_MS = 24 * 3_600_000
|
|
101
|
+
export const RED_REASK_MAX_MS = 7 * 24 * 3_600_000
|
|
102
|
+
/** how long a red of an inactive repo waits before it is asked again: a day, doubled for each run in a row that failed,
|
|
103
|
+
* a week at most. A red that is true (a slow benchmark, a real finding) costs its run time each time it is asked */
|
|
104
|
+
export const redReask = (streak: number): number => Math.min(RED_REASK_MAX_MS, RED_REASK_MS * 2 ** Math.max(0, Math.min(10, streak - 1)))
|
|
105
|
+
|
|
96
106
|
/** a save moved check waits this long after the latest run someone else
|
|
97
107
|
* started in its repo (a terminal, an agent, a click): whoever gates that
|
|
98
108
|
* tree is still at work, and its own gate measures what it changed */
|
|
99
109
|
export const GATED_HOLD_MS = 10 * 60_000
|
|
100
110
|
|
|
101
|
-
/** above this
|
|
102
|
-
*
|
|
111
|
+
/** above this effective load per core (core/machine-busy.ts), the plan starts nothing on its own: every core is
|
|
112
|
+
* taken and already has a process waiting for it. A long run queue with free cores holds nothing */
|
|
103
113
|
export const LOAD_MAX = 1
|
|
104
114
|
|
|
105
|
-
/** the machine's 1 minute load average per core */
|
|
106
|
-
export const machineLoad = (): number => loadavg()[0]! / Math.max(1, availableParallelism())
|
|
107
|
-
|
|
108
115
|
/** a decided fact whose probe could not answer retries after this, doubled
|
|
109
116
|
* per skip in a row, up to ONCE_RETRY_MAX_MS. From its run on record, so a
|
|
110
117
|
* restart changes nothing */
|
|
@@ -147,8 +154,7 @@ export class Planner {
|
|
|
147
154
|
private readonly timers: PlanTimers
|
|
148
155
|
private readonly quietMs: number
|
|
149
156
|
private readonly maxWaitMs: number
|
|
150
|
-
private readonly
|
|
151
|
-
private readonly cores: number
|
|
157
|
+
private readonly machine: () => MachineLoad
|
|
152
158
|
private holdReason: string | null = null
|
|
153
159
|
private readonly catchUp: CatchUpStore | null
|
|
154
160
|
private beatAt: number
|
|
@@ -160,16 +166,15 @@ export class Planner {
|
|
|
160
166
|
* the window it had (catch-up.ts) */
|
|
161
167
|
private readonly bootAt: number
|
|
162
168
|
|
|
163
|
-
constructor(private o: { now?: () => number; timers?: PlanTimers; quietMs?: number; maxWaitMs?: number;
|
|
169
|
+
constructor(private o: { now?: () => number; timers?: PlanTimers; quietMs?: number; maxWaitMs?: number; machine?: () => MachineLoad; catchUp?: CatchUpStore; onError?: (repo: string, e: Error) => void } = {}) {
|
|
164
170
|
this.now = o.now ?? Date.now
|
|
165
171
|
this.catchUp = o.catchUp ?? null
|
|
166
172
|
this.bootAt = this.catchUp != null ? resumeCatchUp(this.now(), this.catchUp) : this.now()
|
|
167
173
|
this.beatAt = this.now()
|
|
168
|
-
this.cores = o.cores ?? availableParallelism()
|
|
169
174
|
this.timers = o.timers ?? realTimers
|
|
170
175
|
this.quietMs = o.quietMs ?? QUIET_MS
|
|
171
176
|
this.maxWaitMs = o.maxWaitMs ?? MAX_WAIT_MS
|
|
172
|
-
this.
|
|
177
|
+
this.machine = o.machine ?? (() => machineLoad())
|
|
173
178
|
}
|
|
174
179
|
|
|
175
180
|
private fail(repo: string, e: unknown): void {
|
|
@@ -341,7 +346,13 @@ export class Planner {
|
|
|
341
346
|
const due = raw != null && raw < this.bootAt ? this.bootAt + Math.round(stablePoint(`catch up\0${r.src.repo}\0${c.id}`) * CATCH_UP_MS) : raw
|
|
342
347
|
if (due == null) return { ...base, state: 'idle', reason: null, dueAt: null }
|
|
343
348
|
if (due > now) return { ...base, state: 'next', reason: 'scheduled', dueAt: due }
|
|
344
|
-
if (!active && wi.value === 'wait')
|
|
349
|
+
if (!active && wi.value === 'wait') {
|
|
350
|
+
if (last?.status !== 'fail') return { ...base, state: 'late', reason: 'late', dueAt: due }
|
|
351
|
+
// a red never waits for its repo: nobody is there to refresh it, so the plan asks again
|
|
352
|
+
const again = Math.max(due, lastAt + redReask(last.streak))
|
|
353
|
+
const inactive = `${wi.rule}, but its last run failed: asked again a day later, then less often while it stays red`
|
|
354
|
+
return { ...base, inactive, state: again > now ? 'next' : 'due', reason: 'scheduled', dueAt: again }
|
|
355
|
+
}
|
|
345
356
|
return { ...base, state: 'due', reason: 'scheduled', dueAt: due }
|
|
346
357
|
}
|
|
347
358
|
|
|
@@ -406,11 +417,11 @@ export class Planner {
|
|
|
406
417
|
return null
|
|
407
418
|
}
|
|
408
419
|
// a loaded machine runs only what someone asked for
|
|
409
|
-
const
|
|
410
|
-
if (
|
|
420
|
+
const m = this.machine()
|
|
421
|
+
if (effectiveLoad(m) > LOAD_MAX * Math.max(1, m.cores)) {
|
|
411
422
|
due = due.filter((x) => x.reason === 'asked')
|
|
412
423
|
if (due.length === 0) {
|
|
413
|
-
this.holdReason = `held:
|
|
424
|
+
this.holdReason = `held: ${machineWords(m)}`
|
|
414
425
|
return null
|
|
415
426
|
}
|
|
416
427
|
}
|
|
@@ -15,6 +15,7 @@ export const RECORDING_KIND = 'recording'
|
|
|
15
15
|
export function recordingKindAt(root: string, o: { unassigned?: boolean } = {}): MediaKind {
|
|
16
16
|
return {
|
|
17
17
|
kind: RECORDING_KIND,
|
|
18
|
+
what: 'the screen recorder\'s takes',
|
|
18
19
|
storeOf: (repoRoot) => (o.unassigned ? join(root, UNASSIGNED) : repoDir(root, repoRoot)),
|
|
19
20
|
stamp(store) {
|
|
20
21
|
const parts = recordingsIn(root, store).map((r) => `${r.id}:${statSync(join(r.dir, 'meta.json'), { throwIfNoEntry: false })?.mtimeMs ?? '-'}:${Object.keys(r.files).map((n) => `${n}=${statSync(join(r.dir, n), { throwIfNoEntry: false })?.size ?? '-'}`).join(',')}`)
|
package/src/recordings/model.ts
CHANGED
|
@@ -165,7 +165,7 @@ export function moveRecording(r: Recording, repo: string): Recording {
|
|
|
165
165
|
m.repo = repo
|
|
166
166
|
writeMeta(to, m)
|
|
167
167
|
const db = mediaDb()
|
|
168
|
-
db?.query('update
|
|
168
|
+
db?.query('update media_files set store = ? where store = ? and item = ?').run(folder, join(r.root, r.repo), r.id)
|
|
169
169
|
return { ...m, dir: to, root: r.root }
|
|
170
170
|
}
|
|
171
171
|
|
|
@@ -361,7 +361,8 @@ final class KeyWindow: NSWindow {
|
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
final class ChooseView: NSView {
|
|
364
|
-
|
|
364
|
+
// weak: a mouse or key event still in flight after the pick ended finds no chooser, and does nothing
|
|
365
|
+
weak var chooser: Chooser?
|
|
365
366
|
let screen: NSScreen
|
|
366
367
|
|
|
367
368
|
init(frame: NSRect, chooser: Chooser, screen: NSScreen) {
|
|
@@ -383,19 +384,20 @@ final class ChooseView: NSView {
|
|
|
383
384
|
|
|
384
385
|
private func local(_ r: NSRect) -> NSRect { r.offsetBy(dx: -screen.frame.minX, dy: -screen.frame.minY) }
|
|
385
386
|
|
|
386
|
-
override func mouseMoved(with e: NSEvent) { MainActor.assumeIsolated { chooser
|
|
387
|
-
override func mouseDown(with e: NSEvent) { MainActor.assumeIsolated { chooser
|
|
388
|
-
override func mouseDragged(with e: NSEvent) { MainActor.assumeIsolated { chooser
|
|
389
|
-
override func mouseUp(with e: NSEvent) { MainActor.assumeIsolated { chooser
|
|
387
|
+
override func mouseMoved(with e: NSEvent) { MainActor.assumeIsolated { chooser?.moved(global(e)) } }
|
|
388
|
+
override func mouseDown(with e: NSEvent) { MainActor.assumeIsolated { chooser?.down(global(e)) } }
|
|
389
|
+
override func mouseDragged(with e: NSEvent) { MainActor.assumeIsolated { chooser?.dragged(global(e)) } }
|
|
390
|
+
override func mouseUp(with e: NSEvent) { MainActor.assumeIsolated { chooser?.up(global(e)) } }
|
|
390
391
|
override func keyDown(with e: NSEvent) {
|
|
391
392
|
MainActor.assumeIsolated {
|
|
392
|
-
if e.keyCode == UInt16(kVK_Escape) { chooser
|
|
393
|
-
if e.keyCode == UInt16(kVK_Return) { chooser
|
|
393
|
+
if e.keyCode == UInt16(kVK_Escape) { chooser?.cancel() }
|
|
394
|
+
if e.keyCode == UInt16(kVK_Return) { chooser?.go() }
|
|
394
395
|
}
|
|
395
396
|
}
|
|
396
397
|
|
|
397
398
|
override func draw(_ dirty: NSRect) {
|
|
398
399
|
MainActor.assumeIsolated {
|
|
400
|
+
guard let chooser else { return }
|
|
399
401
|
if let f = chooser.frozen, f.screen === screen { NSGraphicsContext.current?.cgContext.draw(f.image, in: bounds) }
|
|
400
402
|
let lit: NSRect? = chooser.chosen ?? chooser.dragRect ?? chooser.hover?.frame
|
|
401
403
|
let shade = NSBezierPath(rect: bounds)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// the prompts the hq keeps of a repo, beside the local transcripts: Claude Code deletes a transcript after its
|
|
2
|
+
// retention, the hq never does (hq/kinds/prompt.ts). On the machine that carries the hq they are read from its file,
|
|
3
|
+
// read only; on another machine through the node's own read route, inside its grant. A row's text is as the hq keeps
|
|
4
|
+
// it: masked, cut
|
|
5
|
+
import { Database } from 'bun:sqlite'
|
|
6
|
+
import { existsSync } from 'fs'
|
|
7
|
+
import { READ_MAX_ROWS, type Refused } from '../hq/hq-store.ts'
|
|
8
|
+
import type { ReadLink } from '../hq/hq-routes.ts'
|
|
9
|
+
import { promptId, promptKind, type PromptBody } from '../hq/kinds/prompt.ts'
|
|
10
|
+
import type { PromptEntry } from './prompt-corpus.ts'
|
|
11
|
+
|
|
12
|
+
/** a prompt the hq keeps, as its read gives it */
|
|
13
|
+
export type HqPrompt = PromptBody & { node?: string }
|
|
14
|
+
|
|
15
|
+
/** where a prompt of the merged corpus came from, and what the hq did to it */
|
|
16
|
+
export type MergedEntry = PromptEntry & { from: 'here' | 'hq' | 'both'; cut?: number; masked?: number }
|
|
17
|
+
|
|
18
|
+
/** every prompt the hq keeps of one repo, oldest first: from its file (`file`), else through a node's link */
|
|
19
|
+
export async function readHqPrompts(repo: string, o: { file?: string; link?: Pick<ReadLink, 'read'> }): Promise<{ rows: HqPrompt[] } | Refused> {
|
|
20
|
+
const rows: HqPrompt[] = []
|
|
21
|
+
let after = ''
|
|
22
|
+
if (o.file != null && existsSync(o.file)) {
|
|
23
|
+
const db = new Database(o.file, { readonly: true })
|
|
24
|
+
try {
|
|
25
|
+
for (;;) {
|
|
26
|
+
const page = promptKind.read!.page(db, { repos: [repo], node: null, since: 0, after, limit: READ_MAX_ROWS })
|
|
27
|
+
rows.push(...(page.rows as HqPrompt[]))
|
|
28
|
+
if (page.next == null) return { rows }
|
|
29
|
+
after = page.next
|
|
30
|
+
}
|
|
31
|
+
} finally {
|
|
32
|
+
db.close()
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (o.link == null) return { refused: 'this machine neither carries the hq nor joined one' }
|
|
36
|
+
for (;;) {
|
|
37
|
+
const page = await o.link.read('prompt', { repo, after })
|
|
38
|
+
if ('refused' in page) return page
|
|
39
|
+
rows.push(...(page.rows as HqPrompt[]))
|
|
40
|
+
if (page.next == null) return { rows }
|
|
41
|
+
after = page.next
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** the local prompts and the hq's, by prompt id, each once, in time order: a local text wins (unmasked, uncut),
|
|
46
|
+
* a prompt only the hq keeps comes with its marks */
|
|
47
|
+
export function mergeHq(local: PromptEntry[], hq: HqPrompt[]): MergedEntry[] {
|
|
48
|
+
const out = new Map<string, MergedEntry>()
|
|
49
|
+
for (const p of local) out.set(promptId(p.uuid, Date.parse(p.timestamp), p.text), { ...p, from: 'here' })
|
|
50
|
+
for (const r of hq) {
|
|
51
|
+
const held = out.get(r.id)
|
|
52
|
+
if (held != null) held.from = 'both'
|
|
53
|
+
else out.set(r.id, { uuid: r.id, timestamp: new Date(r.at).toISOString(), sessionId: r.session, account: r.account, text: r.text, origin: r.origin, from: 'hq', cut: r.cut, masked: r.masked })
|
|
54
|
+
}
|
|
55
|
+
return [...out.values()].sort((a, b) => a.timestamp.localeCompare(b.timestamp))
|
|
56
|
+
}
|
|
@@ -198,7 +198,9 @@ export function corpusMarkdown(repoPath: string, prompts: PromptEntry[]): string
|
|
|
198
198
|
const lines: string[] = [`# prompt corpus — ${resolve(repoPath)} (${count})`, '']
|
|
199
199
|
prompts.forEach((p, i) => {
|
|
200
200
|
const when = p.timestamp.replace('T', ' ').slice(0, 16)
|
|
201
|
-
const
|
|
201
|
+
const hq = p as PromptEntry & { from?: string; cut?: number; masked?: number }
|
|
202
|
+
const marks = hq.from === 'hq' ? [`from the hq${hq.masked ? `, ${hq.masked} masked` : ''}${hq.cut ? ', cut' : ''}`] : []
|
|
203
|
+
const tag = `${p.origin === 'queued' ? ' · queued' : ''}${marks.map((m) => ` · ${m}`).join('')}`
|
|
202
204
|
lines.push(`## ${i + 1} · ${when} · ${p.account} · ${p.sessionId.slice(0, 8)}${tag}`, '', fenced(p.text), '')
|
|
203
205
|
})
|
|
204
206
|
return `${lines.join('\n')}\n`
|