rvlib-shipkit 2.25.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 +33 -0
- package/package.json +2 -2
- package/src/agent-time/diet.ts +77 -0
- package/src/agent-time/family.ts +72 -0
- package/src/agent-time/hooks.ts +331 -0
- 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 +130 -17
- package/src/agent-time/report-cache.ts +57 -0
- package/src/agent-time/report.ts +349 -23
- package/src/agent-time/shape.ts +50 -3
- package/src/agent-time/store.ts +370 -95
- 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/SK045-slow-hooks.check.ts +47 -0
- package/src/checks/SK046-hook-records.check.ts +76 -0
- 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 +5 -3
- 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_Mv.ts +1 -1
- package/src/cli/cmd_Reflect.ts +23 -2
- package/src/cli/cmd_Releases.ts +30 -0
- package/src/cli/cmd_Review.ts +569 -118
- 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 +82 -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 +26 -4
- 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/commands/runner.ts +5 -1
- 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/history-files.ts +9 -5
- 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/signal-name.ts +6 -0
- package/src/core/slots.ts +5 -4
- package/src/core/trace-audit.ts +6 -1
- package/src/core/transient.ts +6 -0
- package/src/drill/clean.ts +25 -1
- package/src/drill/run.ts +2 -2
- 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 +29 -4
- package/src/ledger/git-key.ts +3 -3
- package/src/ledger/git-scan.ts +49 -7
- package/src/ledger/run-log.ts +11 -3
- package/src/ledger/store.ts +26 -4
- package/src/media-store/backup/daemon.ts +36 -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 +68 -20
- 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 +146 -36
- 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/model.ts +18 -0
- package/src/releases/routes.ts +10 -5
- package/src/releases/store.ts +23 -2
- package/src/repo-config.ts +42 -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 +35 -0
- 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 +214 -45
- 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 +113 -16
- package/src/suite/select.ts +45 -3
- package/src/suite/suite-cli.ts +81 -34
- 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/wiki/run-wiki.ts +2 -1
- package/src/wiki/scan-md.ts +42 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
## 2.27.0
|
|
2
|
+
|
|
3
|
+
- **The hq: one place for every machine.** Every daemon carries an hq and reports to it (`sk machines`); another machine joins with `sk hq`. Review cards, asks, reflections, prompts and agent time days travel through it, each behind its own switch. `sk hq replicate` and `sk hq drill` keep a second copy and prove it.
|
|
4
|
+
- **The vault.** OpenBao runs under pm, its seal key in the login keychain. On its machine every read of a secret comes from it and every write goes to it. A scope names a machine and a repo. `sk vault init`, `import`, `compare`, `snapshot`, `restore`, `narrow` and `destroy`. A sealed snapshot is proved by a restore before it leaves, sent to the Space, and removed after 30 days once a newer one passed its proof.
|
|
5
|
+
- **One machine database.** The media index, the agent time index and the daemon's file fold into one store (`sk db fold`, and back). A damaged table costs only itself (`sk db drop`, `sk db repair`, `sk db rebuild`). A store keeps a copy of itself before its schema changes.
|
|
6
|
+
- **The home.** Pages for the machines, the databases, the vault, the Space and agent time. The pages move into a folding rail, with no top bar. One keyboard pattern for every side list. Two new themes, dim and grey. `sk home move` puts the machine's state under `~/.shipkit`.
|
|
7
|
+
- **Review cards as rows** of the machine database, behind a switch: `sk review move`, `--back`, `--tidy`, and a watch that hears a verdict in 50 ms. A verdict opens the next waiting card. The lightbox fills the window at the size you set. A draft card pins a post draft.
|
|
8
|
+
- **Threads.** One thread per subject for its whole life, at its own address. `sk thread` asks a question with its answers as buttons, proposes a change the owner applies in one click, and links what it is about. A watch follows whoever holds the thread. The hub has a threads page, and every object carries a thread control.
|
|
9
|
+
- **`sk time` sees more, and counts truer.** Foreground and background apart, Bash by family, turns by model and context size, the refused calls with the turns they wasted, the time limits hit, the scripts behind a `<file>` shape, a report kept 5 minutes, and a `/time` page in the home. A line of several commands is its own row, `<first> (+ more)`, so a fast command before a slow one never looks slow.
|
|
10
|
+
- **ONE WAY IN lets `bun test <file or folder>` run.** Only a whole suite run is refused, and SK013 replaces the old `Bash(bun test*)` deny row with the bare `Bash(bun test)`. The Bash guard also refuses a wait loop on `pgrep -f <name>`: loops that wait on the same name match each other and never end. It names `kill -0 <pid>` instead.
|
|
11
|
+
- **Urls.** A repo lists every url it has, dev and prod, on its own page, its logins as copy chips. A `/` in a label makes folders. The overview lists the urls of every repo.
|
|
12
|
+
- **Trailers.** A cut opens on its start image and ends on its end image (`thumbnail`, and `endcard` on a landscape cut, both required). `sk trailer --mock` plays the whole cut before its shots exist. A corner `watermark`. The score warns where a phone hears it fall away.
|
|
13
|
+
- **Social and stores.** `sk social thumbnail` makes every video's thumbnail from the brand. The Chrome Web Store joins the desk. The owner suggests messages and phrasings from the hub.
|
|
14
|
+
- **Asks.** The owner can decline an ask (`sk asks decline`), and a declined ask stays closed. A login's row carries its account beside the password.
|
|
15
|
+
- **Lanes and the gate read the cores really in use**, not the load alone: `sk capacity`, the slow checks, the suite judge and the slot pool.
|
|
16
|
+
- **Temp folders.** Each house repo's `.shipkit/tmp` joins the machine's temp sweep. A dry sweep names every unit it would take.
|
|
17
|
+
- **The Space.** A copy to a second place by stream, each object with its content type. `sk space` and `sk space ls`.
|
|
18
|
+
- **Checks.** SK035 refuses a machine of the owner in what a unit publishes. SK047 warns on a password in a process description. SK028 takes a README alone, with no screenshot.
|
|
19
|
+
- **Faster.** A media sender's first run of 91,125 objects in 5 s. Keychain calls without a 250 ms spawn timeout. A verdict given on another machine reaches a watch in about 7 s, not 60.
|
|
20
|
+
|
|
21
|
+
## 2.26.0
|
|
22
|
+
|
|
23
|
+
- **A slow hook is refused.** SK045 fails a repo whose hook on every tool call (`PreToolUse`, `PostToolUse`) takes over 150 ms on a no-op Bash call, and fails a hook on a save as soon as it is wired, unless `repo.config.ts` names it under `instantHooks` with the reason it is instant. SK046 warns on the runs the harness recorded. `sk time hooks` shows what each hook cost.
|
|
24
|
+
- **A suite that fails only in a loaded pool runs again alone** before the gate goes red: it passes alone, the gate warns and names the file and the load; it fails alone too, the machine was quiet, or more than three suites failed, the red stands.
|
|
25
|
+
- **The cache**: a submodule declared as an input keys by the commit it stands at while it is filled and holds no change of its own; an ignored file named as an input keeps its key after the first scan; a write in flight (`.dist.tmp-<pid>`) is never proposed as an ignored input.
|
|
26
|
+
- **A defect of a toolkit check never fails another repo's gate**: the check runs there with no cache and says whose defect it is; the repo that hosts the toolkit still fails on it.
|
|
27
|
+
- **Review**: once no watch of a card's lane or session lives, whoever reads the answer marks it seen; `sk review inbox --hook` runs the inbox as a Claude Code hook on a prompt and at a turn's end; the worker that blocked a raised item takes it back or closes it.
|
|
28
|
+
- **`sk releases remove <card id | title>`** takes one change out of the next release file.
|
|
29
|
+
- **`sk wiki lint`** checks that an anchor names a heading of its page; a changelog or a journal keeps a link as written.
|
|
30
|
+
- **`sk mv`** leaves archived repros and field notes as written too.
|
|
31
|
+
- **`sk backup --check`** reads the local files the daemon's looks keep, three times faster.
|
|
32
|
+
- **The bun types follow the machine's bun** (`@types/bun` ^1.4.4).
|
|
33
|
+
|
|
1
34
|
## 2.25.0
|
|
2
35
|
|
|
3
36
|
- **A repo adjusts its own lane count.** `sk capacity` answers how many lanes this repo runs now from the cores, the 1 minute load and the agents at work: never zero, `--max <n>` is the count the owner gave, and only a machine at twice its cores of load stops a lane. `sk lanes` shows each live session and lane, since when, and what it does.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rvlib-shipkit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.27.0",
|
|
4
4
|
"funding": "https://github.com/sponsors/rvion",
|
|
5
5
|
"description": "All-in-one repo companion: ci gate (task DAG), auto-discovered health checks, release-contract fulfillness, asks queue, md-wiki tools, asset atelier, live tui",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"./src/*": "./src/*"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/bun": "^1.
|
|
26
|
+
"@types/bun": "^1.4.4",
|
|
27
27
|
"@types/react": "^19.2.17",
|
|
28
28
|
"@types/react-dom": "^19.2.3",
|
|
29
29
|
"@types/sanitize-html": "^2.16.1",
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// the diet of the agent time index: after DIET_KEEP_MS, a call keeps its command's text only when `sk time` shows it
|
|
2
|
+
// (it failed, was refused, ran DIET_SLOW_MS or more, has no end, or ran a script: a `<file>` shape), and every other
|
|
3
|
+
// text goes, its 53 bit sum kept so the blind retry test still compares. The one constraint a reader breaks first: a
|
|
4
|
+
// dropped text never comes back (Claude Code prunes the transcripts), so it runs only while the owner's switch
|
|
5
|
+
// `time-diet` is on, off by default, in steps that rewrite each range of rows so its pages go back to the disk
|
|
6
|
+
import type { Database } from 'bun:sqlite'
|
|
7
|
+
import { machineGet, machineSet } from '../core/machine-db.ts'
|
|
8
|
+
import { FILE_MARK } from './shape.ts'
|
|
9
|
+
import { cmdSum } from './timeline.ts'
|
|
10
|
+
|
|
11
|
+
export const TIME_DIET = 'time-diet'
|
|
12
|
+
/** the owner's word: on, the agent time job drops the texts; off, its default, nothing is dropped */
|
|
13
|
+
export const dietOn = (): boolean => machineGet<boolean>(TIME_DIET) === true
|
|
14
|
+
export const setDietOn = (on: boolean): boolean => machineSet(TIME_DIET, on)
|
|
15
|
+
|
|
16
|
+
/** a call this recent keeps its text, whatever it is */
|
|
17
|
+
export const DIET_KEEP_MS = 7 * 86_400_000
|
|
18
|
+
/** a call that ran this long keeps its text: the slowest calls `sk time` lists */
|
|
19
|
+
export const DIET_SLOW_MS = 10_000
|
|
20
|
+
/** rows a step rewrites: a few ms of the file's write lock */
|
|
21
|
+
const DIET_STEP = 500
|
|
22
|
+
/** the pause between two steps */
|
|
23
|
+
const DIET_PAUSE_MS = 10
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/** the texts that stay, as a condition on a row of time_calls */
|
|
27
|
+
const KEEPS = `(outcome in ('exit', 'error', 'timeout', 'blocked', 'denied') or end is null or end - start >= ${DIET_SLOW_MS} or instr(shape, '${FILE_MARK}') > 0)`
|
|
28
|
+
|
|
29
|
+
export type Diet = { calls: number; bytes: number; heldMs: number }
|
|
30
|
+
|
|
31
|
+
/** the texts the diet drops, older than `now - DIET_KEEP_MS`: `dry` counts them and drops nothing. Each step deletes a
|
|
32
|
+
* range of rows and writes them back without their text under the same rowids, so the range takes fewer pages and
|
|
33
|
+
* the freed ones go to the free list (the file gives them back in steps: machine-db.ts vacuumSteps). A row older
|
|
34
|
+
* than the cut is never written by the indexer again (it only closes a call with no end, which keeps its text) */
|
|
35
|
+
export function dietCalls(db: Database, o: { now: number; dry?: boolean; step?: number; pauseMs?: number }): Diet {
|
|
36
|
+
const cut = o.now - DIET_KEEP_MS
|
|
37
|
+
const goes = `start < ? and cmd != '' and cmd_sum is null and not ${KEEPS}`
|
|
38
|
+
if (o.dry === true) {
|
|
39
|
+
const r = db.query(`select count(*) as n, coalesce(sum(length(cast(cmd as blob))), 0) as b from time_calls where ${goes}`).get(cut) as { n: number; b: number }
|
|
40
|
+
return { calls: r.n, bytes: r.b, heldMs: 0 }
|
|
41
|
+
}
|
|
42
|
+
const cols = (db.query("select name from pragma_table_info('time_calls')").all() as { name: string }[]).map((c) => c.name)
|
|
43
|
+
const keeps = (r: Record<string, unknown>): boolean => ['exit', 'error', 'timeout', 'blocked', 'denied'].includes(r.outcome as string) || r.end == null || (r.end as number) - (r.start as number) >= DIET_SLOW_MS || (r.shape as string).includes(FILE_MARK)
|
|
44
|
+
const drops = (r: Record<string, unknown>): boolean => (r.start as number) < cut && r.cmd !== '' && r.cmd_sum == null && !keeps(r)
|
|
45
|
+
const list = cols.map((c) => `"${c}"`).join(', ')
|
|
46
|
+
// a step is a range of DIET_STEP rows, kept ones too: a range of a fixed size holds the lock a fixed time, and a
|
|
47
|
+
// range rewritten whole takes the fewest pages
|
|
48
|
+
const first = db.query(`select min(rowid) as r from time_calls where ${goes}`)
|
|
49
|
+
const end = db.query('select rowid as r from time_calls where rowid >= ? order by rowid limit 1 offset ?')
|
|
50
|
+
const out: Diet = { calls: 0, bytes: 0, heldMs: 0 }
|
|
51
|
+
const step = o.step ?? DIET_STEP
|
|
52
|
+
for (let lo = (first.get(cut) as { r: number | null }).r; lo != null; ) {
|
|
53
|
+
const hi = (end.get(lo, step - 1) as { r: number } | null)?.r ?? Number.MAX_SAFE_INTEGER
|
|
54
|
+
const t = performance.now()
|
|
55
|
+
db.transaction(() => {
|
|
56
|
+
const rows = db.query(`select rowid as _r, ${list} from time_calls where rowid between ? and ?`).all(lo, hi) as Record<string, unknown>[]
|
|
57
|
+
db.query('delete from time_calls where rowid between ? and ?').run(lo, hi)
|
|
58
|
+
const put = db.query(`insert into time_calls (rowid, ${list}) values (${['?', ...cols.map(() => '?')].join(', ')})`)
|
|
59
|
+
for (const r of rows) {
|
|
60
|
+
if (drops(r)) {
|
|
61
|
+
out.bytes += Buffer.byteLength(r.cmd as string)
|
|
62
|
+
out.calls++
|
|
63
|
+
r.cmd_sum = cmdSum(r.cmd as string)
|
|
64
|
+
r.cmd = ''
|
|
65
|
+
}
|
|
66
|
+
put.run(r._r as never, ...cols.map((c) => r[c] as never))
|
|
67
|
+
}
|
|
68
|
+
}).immediate()
|
|
69
|
+
out.heldMs = Math.max(out.heldMs, Math.round(performance.now() - t))
|
|
70
|
+
// the log checkpointed here at each step: else another process's small write past the threshold pays it
|
|
71
|
+
db.query('pragma wal_checkpoint(passive)').all()
|
|
72
|
+
// a pause a step, so the machine's other writes and the log's checkpoint get the disk between two
|
|
73
|
+
Bun.sleepSync(o.pauseMs ?? DIET_PAUSE_MS)
|
|
74
|
+
lo = (db.query(`select min(rowid) as r from time_calls where rowid > ? and ${goes}`).get(hi, cut) as { r: number | null }).r
|
|
75
|
+
}
|
|
76
|
+
return out
|
|
77
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// A Bash shape's FAMILY: the kind of work the command is (a read, an edit, a
|
|
2
|
+
// check, a wait). A few hundred shapes group into ten rows, so « Bash » is
|
|
3
|
+
// never one figure.
|
|
4
|
+
//
|
|
5
|
+
// The constraint a reader breaks first: the rules run in order and the first
|
|
6
|
+
// match wins, so `sed -i (edit)` is an edit before `sed` is a read, and
|
|
7
|
+
// `bun check` is a check before `bun` is a program.
|
|
8
|
+
|
|
9
|
+
import { kindOf } from './shape.ts'
|
|
10
|
+
|
|
11
|
+
export const FAMILIES = ['scripts', 'checks', 'reads', 'edits', 'git', 'shipkit', 'files', 'machine', 'waits', 'other'] as const
|
|
12
|
+
export type Family = (typeof FAMILIES)[number]
|
|
13
|
+
|
|
14
|
+
/** each family as a person names it, and what falls in it */
|
|
15
|
+
export const FAMILY_WORDS: Record<Family, { label: string; title: string }> = {
|
|
16
|
+
scripts: { label: 'scripts and programs', title: 'bun <file>, python3, bash <file>, a package script, ffmpeg' },
|
|
17
|
+
checks: { label: 'checks and tests', title: 'bun check, a test run, sk ci, a linter' },
|
|
18
|
+
reads: { label: 'reading and searching', title: 'grep, sed, cat, ls, head, tail, wc, find' },
|
|
19
|
+
edits: { label: 'editing through the shell', title: 'a python3 heredoc that writes a file, sed -i, perl -i, cat >' },
|
|
20
|
+
git: { label: 'git', title: 'git and gh' },
|
|
21
|
+
shipkit: { label: 'shipkit commands', title: 'sk, its checks left out (sk ci, sk check, sk status are checks)' },
|
|
22
|
+
files: { label: 'moving files', title: 'cp, mv, rm, mkdir, chmod, tar, rsync' },
|
|
23
|
+
machine: { label: 'the machine and the network', title: 'curl, ssh, lsof, pgrep, kill, du, df' },
|
|
24
|
+
waits: { label: 'waiting and polling', title: 'sleep, an until loop, a while loop' },
|
|
25
|
+
other: { label: 'other', title: 'a shell function, a loop whose command the shape does not name' },
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const BG = ' (bg)'
|
|
29
|
+
/** a row of a background run: timed from its start to its end, never a wait inside the call */
|
|
30
|
+
export const isBgShape = (shape: string): boolean => shape.endsWith(BG)
|
|
31
|
+
export const bareShape = (shape: string): string => (isBgShape(shape) ? shape.slice(0, -BG.length) : shape)
|
|
32
|
+
|
|
33
|
+
const READS = new Set([
|
|
34
|
+
'grep', 'rg', 'sed', 'awk', 'cat', 'head', 'tail', 'ls', 'wc', 'find', 'sort', 'uniq', 'cut', 'jq', 'diff', 'tree', 'stat', 'file', 'echo', 'printf',
|
|
35
|
+
'pwd', 'which', 'test', 'less', 'xxd', 'nl', 'tr', 'basename', 'dirname', 'realpath', 'readlink', 'sqlite3', 'date', 'column', 'comm', 'md5', 'shasum', 'strings', 'type',
|
|
36
|
+
])
|
|
37
|
+
const FILES = new Set(['cp', 'mv', 'rm', 'rmdir', 'mkdir', 'chmod', 'chown', 'touch', 'ln', 'tar', 'zip', 'unzip', 'gzip', 'gunzip', 'rsync', 'tee', 'trash'])
|
|
38
|
+
const MACHINE = new Set([
|
|
39
|
+
'curl', 'wget', 'ssh', 'scp', 'lsof', 'pgrep', 'ps', 'kill', 'killall', 'pkill', 'du', 'df', 'top', 'uptime', 'open', 'osascript', 'launchctl', 'tmutil', 'nc', 'ping',
|
|
40
|
+
'say', 'afplay', 'screencapture', 'brew', 'docker', 'sysctl', 'vm_stat', 'defaults', 'diskutil', 'mdfind', 'pmset', 'sw_vers', 'uname', 'whoami', 'hostname', 'tailscale', 'dig',
|
|
41
|
+
])
|
|
42
|
+
const PROGRAMS = new Set([
|
|
43
|
+
'bun', 'node', 'deno', 'python', 'python3', 'bash', 'sh', 'zsh', 'npx', 'bunx', 'pnpx', 'npm', 'pnpm', 'yarn', 'ffmpeg', 'ffprobe', 'magick', 'convert', 'sips',
|
|
44
|
+
'make', 'cargo', 'go', 'ruby', 'perl', 'time', 'xargs', 'comfy-ts', 'chi', 'cflow', 'wrangler', 'swift', 'swiftc', 'xcodebuild', 'pip', 'pip3', 'uv',
|
|
45
|
+
])
|
|
46
|
+
const CHECKERS = new Set(['tsc', 'vitest', 'jest', 'eslint', 'biome', 'oxlint', 'prettier', 'playwright'])
|
|
47
|
+
/** a package script that checks: `test:raw`, `box:check`, `prove:data` */
|
|
48
|
+
const CHECK_WORD = /(?:^|:)(?:test|tests|check|lint|typecheck|types|tsc|ci|prove|verify)(?::|$)/
|
|
49
|
+
const SCRIPT_FILE = /\.(?:sh|bash|zsh|ts|tsx|js|mjs|cjs|py|rb|pl)$/
|
|
50
|
+
|
|
51
|
+
/** the family of one Bash shape; a background row falls in the family of its command */
|
|
52
|
+
export function familyOf(shape: string): Family {
|
|
53
|
+
const s = kindOf(bareShape(shape))
|
|
54
|
+
if (/^\((?:until|while)\)/.test(s)) return 'waits'
|
|
55
|
+
// a loop, a subshell, a group or a substitution is the command it runs
|
|
56
|
+
const cmd = s.replace(/^(?:\((?:for|if|function)\)\s*|[A-Za-z_][A-Za-z0-9_]*=\$\(|\$?\(|\{ )+/, '')
|
|
57
|
+
const w = cmd.split(' ')
|
|
58
|
+
const head = w[0] ?? ''
|
|
59
|
+
if (head === 'sleep') return 'waits'
|
|
60
|
+
if (cmd.endsWith('(edit)') || cmd === 'cat > (write)') return 'edits'
|
|
61
|
+
if (head === 'git' || head === 'gh') return 'git'
|
|
62
|
+
const runner = head === 'bun' || head === 'npm' || head === 'pnpm' || head === 'yarn'
|
|
63
|
+
if (runner && CHECK_WORD.test(w[1] === 'run' ? (w[2] ?? '') : (w[1] ?? ''))) return 'checks'
|
|
64
|
+
if ((head === 'bunx' || head === 'npx' || head === 'pnpx') && CHECKERS.has(w[1] ?? '')) return 'checks'
|
|
65
|
+
if (CHECKERS.has(head)) return 'checks'
|
|
66
|
+
if (head === 'sk' || head === 'shipkit') return w[1] === 'ci' || w[1] === 'check' || w[1] === 'status' ? 'checks' : 'shipkit'
|
|
67
|
+
if (READS.has(head)) return 'reads'
|
|
68
|
+
if (FILES.has(head)) return 'files'
|
|
69
|
+
if (MACHINE.has(head)) return 'machine'
|
|
70
|
+
if (PROGRAMS.has(head) || SCRIPT_FILE.test(head) || head === '<file>') return 'scripts'
|
|
71
|
+
return 'other'
|
|
72
|
+
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
// HOOKS ON THE AGENT'S PATH: what the settings wire to run on each tool call or
|
|
2
|
+
// each turn, the budget of each cadence, the probe a gate may run, and the
|
|
3
|
+
// verdicts of SK045 (the gate) and SK046 (the recorded runs, a warning).
|
|
4
|
+
// `sk time hooks` reads the same declarations.
|
|
5
|
+
//
|
|
6
|
+
// The constraint a reader breaks first: the harness records the run of a hook
|
|
7
|
+
// on a tool call or a prompt only when the hook printed something, so a silent
|
|
8
|
+
// one has no record (the hooks of a turn's end are all recorded), and a hook
|
|
9
|
+
// the probe may not run (one on a save may write) has no measure at all.
|
|
10
|
+
import { createHash } from 'crypto'
|
|
11
|
+
import { existsSync, readFileSync, realpathSync, statSync } from 'fs'
|
|
12
|
+
import { homedir } from 'os'
|
|
13
|
+
import { dirname, isAbsolute, join, relative, resolve } from 'path'
|
|
14
|
+
import { gitBin } from '../core/git-bin.ts'
|
|
15
|
+
import { houseOfIndex } from '../home/home-paths.ts'
|
|
16
|
+
import { discoverConfigRoots } from '../reflect/prompt-corpus.ts'
|
|
17
|
+
import { homeRepo, houseIndex } from '../serve/project-gutter.ts'
|
|
18
|
+
|
|
19
|
+
/** how often a hook stands in the agent's way */
|
|
20
|
+
export type Cadence = 'call' | 'turn' | 'other'
|
|
21
|
+
|
|
22
|
+
const CADENCE: Record<string, Cadence> = { PreToolUse: 'call', PostToolUse: 'call', PostToolUseFailure: 'call', UserPromptSubmit: 'turn', Stop: 'turn', SubagentStop: 'turn' }
|
|
23
|
+
export const cadenceOf = (event: string): Cadence => CADENCE[event] ?? 'other'
|
|
24
|
+
|
|
25
|
+
/** a hook on every tool call: bun's own start is about 60 ms on a loaded Mac,
|
|
26
|
+
* so this leaves a guard room to read a file or two, and a whole tree
|
|
27
|
+
* typecheck (a median near a second) is far over */
|
|
28
|
+
export const CALL_BUDGET_MS = 150
|
|
29
|
+
/** a hook on each prompt or turn end runs once per many calls: ten times
|
|
30
|
+
* more, and over it warns, never fails */
|
|
31
|
+
export const TURN_BUDGET_MS = 1000
|
|
32
|
+
/** recorded runs a median needs before it judges */
|
|
33
|
+
export const MIN_RUNS = 5
|
|
34
|
+
/** records older than this describe another machine load and another tree */
|
|
35
|
+
export const RECORD_DAYS = 30
|
|
36
|
+
/** probe runs after one warm up: the fastest is a floor no load explains */
|
|
37
|
+
export const PROBE_RUNS = 5
|
|
38
|
+
|
|
39
|
+
export type HookSource = 'repo' | 'local' | 'user'
|
|
40
|
+
|
|
41
|
+
/** one hook as a settings file declares it; `command` is '' for a hook of
|
|
42
|
+
* another type, named by `type` */
|
|
43
|
+
export type DeclaredHook = { event: string; matcher: string; type: string; command: string; timeoutS: number | null; source: HookSource; file: string }
|
|
44
|
+
|
|
45
|
+
type RawSettings = { hooks?: Record<string, { matcher?: unknown; hooks?: { type?: unknown; command?: unknown; timeout?: unknown }[] }[]> }
|
|
46
|
+
|
|
47
|
+
/** the hooks of one settings text; throws on text that is not JSON */
|
|
48
|
+
export function parseHooks(text: string, source: HookSource, file: string): DeclaredHook[] {
|
|
49
|
+
const j = JSON.parse(text) as RawSettings
|
|
50
|
+
const out: DeclaredHook[] = []
|
|
51
|
+
for (const [event, entries] of Object.entries(j?.hooks ?? {})) {
|
|
52
|
+
if (!Array.isArray(entries)) continue
|
|
53
|
+
for (const e of entries) {
|
|
54
|
+
const matcher = typeof e?.matcher === 'string' ? e.matcher : ''
|
|
55
|
+
for (const h of Array.isArray(e?.hooks) ? e.hooks : []) {
|
|
56
|
+
const type = typeof h?.type === 'string' ? h.type : 'command'
|
|
57
|
+
const command = type === 'command' && typeof h?.command === 'string' ? h.command : ''
|
|
58
|
+
out.push({ event, matcher, type, command, timeoutS: typeof h?.timeout === 'number' ? h.timeout : null, source, file })
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return out
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const REPO_SETTINGS = ['.claude/settings.json', '.claude/settings.local.json'] as const
|
|
66
|
+
|
|
67
|
+
/** the hooks a repo's own settings declare, and the files that did not parse */
|
|
68
|
+
export function repoHooks(root: string): { hooks: DeclaredHook[]; broken: string[] } {
|
|
69
|
+
const hooks: DeclaredHook[] = []
|
|
70
|
+
const broken: string[] = []
|
|
71
|
+
for (const rel of REPO_SETTINGS) {
|
|
72
|
+
const text = readOrNull(join(root, rel))
|
|
73
|
+
if (text == null) continue
|
|
74
|
+
try {
|
|
75
|
+
hooks.push(...parseHooks(text, rel.endsWith('.local.json') ? 'local' : 'repo', rel))
|
|
76
|
+
} catch {
|
|
77
|
+
broken.push(rel)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return { hooks, broken }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** the settings file of every Claude Code account on the machine */
|
|
84
|
+
export function userSettingsFiles(home = homedir()): string[] {
|
|
85
|
+
return discoverConfigRoots(home).map((r) => join(dirname(r.projects), 'settings.json')).filter((f) => existsSync(f))
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** the hooks every account declares for every repo; one entry per distinct
|
|
89
|
+
* hook, its file the first account that declares it */
|
|
90
|
+
export function userHooks(home = homedir()): DeclaredHook[] {
|
|
91
|
+
const seen = new Map<string, DeclaredHook>()
|
|
92
|
+
for (const f of userSettingsFiles(home)) {
|
|
93
|
+
const text = readOrNull(f)
|
|
94
|
+
if (text == null) continue
|
|
95
|
+
let hooks: DeclaredHook[]
|
|
96
|
+
try {
|
|
97
|
+
hooks = parseHooks(text, 'user', f.startsWith(`${home}/`) ? `~/${relative(home, f)}` : f)
|
|
98
|
+
} catch {
|
|
99
|
+
continue
|
|
100
|
+
}
|
|
101
|
+
for (const h of hooks) if (!seen.has(hookKey(h))) seen.set(hookKey(h), h)
|
|
102
|
+
}
|
|
103
|
+
return [...seen.values()]
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** this repo is the house, the one gate that judges the machine's own hooks */
|
|
107
|
+
export function isHouse(root: string): boolean {
|
|
108
|
+
const index = houseIndex(homeRepo(root), homedir())
|
|
109
|
+
return index != null && houseOfIndex(index) === root
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** a settings file that does not parse still applies: the check says so */
|
|
113
|
+
export function hasHooks(root: string): boolean {
|
|
114
|
+
const r = repoHooks(root)
|
|
115
|
+
return r.hooks.length > 0 || r.broken.length > 0 || (isHouse(root) && userHooks().length > 0)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export const hookKey = (h: { event: string; matcher?: string; command: string }): string => `${h.event}\u0000${h.matcher ?? ''}\u0000${h.command}`
|
|
119
|
+
|
|
120
|
+
/** Claude Code's matcher: none, `*` or `.*` takes every tool, else a regex on the whole tool name */
|
|
121
|
+
export function matcherMatches(matcher: string, tool: string): boolean {
|
|
122
|
+
const m = matcher.trim()
|
|
123
|
+
if (m === '' || m === '*' || m === '.*') return true
|
|
124
|
+
try {
|
|
125
|
+
return new RegExp(`^(?:${m})$`).test(tool)
|
|
126
|
+
} catch {
|
|
127
|
+
return m === tool
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export const matcherLabel = (matcher: string): string => (['', '*', '.*'].includes(matcher.trim()) ? 'every tool' : matcher)
|
|
132
|
+
|
|
133
|
+
// ── the probe ──────────────────────────────────────────────────────────────
|
|
134
|
+
|
|
135
|
+
const PROBE_ID = 'shipkit-hook-probe'
|
|
136
|
+
|
|
137
|
+
/** the probe runs a hook only on what the harness itself sends for a Bash
|
|
138
|
+
* `true`, a call that changes nothing, so it does no more than a real no-op
|
|
139
|
+
* call does. A hook whose matcher takes no Bash call is never run: on a
|
|
140
|
+
* made up save it may write, and its cost hangs on the file it is given */
|
|
141
|
+
export const probeable = (h: DeclaredHook): boolean => h.command !== '' && (h.event === 'PreToolUse' || h.event === 'PostToolUse') && matcherMatches(h.matcher, 'Bash')
|
|
142
|
+
|
|
143
|
+
export function probeInput(h: DeclaredHook, root: string): string {
|
|
144
|
+
const base = { session_id: PROBE_ID, transcript_path: '', cwd: root, permission_mode: 'default', hook_event_name: h.event, tool_name: 'Bash', tool_input: { command: 'true', description: 'a no-op' }, tool_use_id: PROBE_ID }
|
|
145
|
+
return JSON.stringify(h.event === 'PostToolUse' ? { ...base, tool_response: { stdout: '', stderr: '', interrupted: false, isImage: false } } : base)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export type Probe = { ms: number[]; code: number | null; timedOut: boolean }
|
|
149
|
+
|
|
150
|
+
/** the env a probed hook gets: the caller's, minus the live session's own
|
|
151
|
+
* channel (its id, messaging socket and token, pid), plus the project dir */
|
|
152
|
+
export function probeEnv(from: Record<string, string | undefined>, root: string): Record<string, string | undefined> {
|
|
153
|
+
const env: Record<string, string | undefined> = {}
|
|
154
|
+
for (const [k, v] of Object.entries(from)) if (!k.startsWith('CLAUDE_CODE_') && k !== 'CLAUDE_PID') env[k] = v
|
|
155
|
+
env.CLAUDE_PROJECT_DIR = root
|
|
156
|
+
return env
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** the hook run as the harness runs it (a shell, the repo as its project dir,
|
|
160
|
+
* the input on stdin), once to warm up and PROBE_RUNS times measured */
|
|
161
|
+
export async function probeHook(h: DeclaredHook, root: string, runs = PROBE_RUNS): Promise<Probe> {
|
|
162
|
+
const env = probeEnv(process.env, root)
|
|
163
|
+
const input = Buffer.from(probeInput(h, root))
|
|
164
|
+
const capMs = Math.min(h.timeoutS ?? 60, 5) * 1000
|
|
165
|
+
const ms: number[] = []
|
|
166
|
+
let code: number | null = null
|
|
167
|
+
for (let i = 0; i <= runs; i++) {
|
|
168
|
+
const t0 = performance.now()
|
|
169
|
+
const p = Bun.spawn(['/bin/sh', '-c', h.command], { cwd: root, env, stdin: input, stdout: 'ignore', stderr: 'ignore' })
|
|
170
|
+
const timer = setTimeout(() => p.kill(9), capMs)
|
|
171
|
+
code = await p.exited
|
|
172
|
+
clearTimeout(timer)
|
|
173
|
+
const took = performance.now() - t0
|
|
174
|
+
if (took >= capMs) return { ms: [...ms, took], code, timedOut: true }
|
|
175
|
+
// exit 2 is a block, an answer like any other; anything else but 0 means it did not run as meant
|
|
176
|
+
if (code !== 0 && code !== 2) return { ms, code, timedOut: false }
|
|
177
|
+
if (i > 0) ms.push(took)
|
|
178
|
+
}
|
|
179
|
+
return { ms, code, timedOut: false }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// ── when the hook last changed ─────────────────────────────────────────────
|
|
183
|
+
|
|
184
|
+
/** the files a command names: its quoted or bare paths, the project dir and ~ expanded */
|
|
185
|
+
export function scriptsOf(command: string, root: string, home = homedir()): string[] {
|
|
186
|
+
const out: string[] = []
|
|
187
|
+
for (const raw of command.replace(/["']/g, '').split(/\s+/)) {
|
|
188
|
+
const t = raw.replace(/\$\{?CLAUDE_PROJECT_DIR\}?/g, root).replace(/^~(?=\/)/, home)
|
|
189
|
+
if (!t.includes('/')) continue
|
|
190
|
+
const p = isAbsolute(t) ? t : resolve(root, t)
|
|
191
|
+
try {
|
|
192
|
+
if (statSync(p).isFile()) out.push(p)
|
|
193
|
+
} catch { /* not a file */ }
|
|
194
|
+
}
|
|
195
|
+
return out
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** when the files a hook runs last changed: a tracked file its last commit
|
|
199
|
+
* while it is clean, any other its mtime; null when it names none. A record
|
|
200
|
+
* older than this timed another version of the hook */
|
|
201
|
+
export function changedAt(command: string, root: string, home = homedir()): number | null {
|
|
202
|
+
let at: number | null = null
|
|
203
|
+
for (const f of scriptsOf(command, root, home)) {
|
|
204
|
+
const real = safeReal(f)
|
|
205
|
+
const rel = relative(root, real)
|
|
206
|
+
let t: number | null = null
|
|
207
|
+
if (!rel.startsWith('..') && !rel.split('/').includes('node_modules')) {
|
|
208
|
+
const dirty = Bun.spawnSync([gitBin(), 'status', '--porcelain', '--', rel], { cwd: root, stdout: 'pipe', stderr: 'ignore' })
|
|
209
|
+
if (dirty.exitCode === 0 && dirty.stdout.toString().trim() === '') {
|
|
210
|
+
const log = Bun.spawnSync([gitBin(), 'log', '-1', '--format=%ct', '--', rel], { cwd: root, stdout: 'pipe', stderr: 'ignore' })
|
|
211
|
+
const s = Number(log.stdout.toString().trim())
|
|
212
|
+
if (log.exitCode === 0 && s > 0) t = s * 1000
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (t == null) t = statSync(real).mtimeMs
|
|
216
|
+
if (at == null || t > at) at = t
|
|
217
|
+
}
|
|
218
|
+
return at
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** what a cached answer is keyed on: the settings texts and the stamp of each file their hooks run */
|
|
222
|
+
export function hooksKey(root: string, settings: string[], home = homedir()): string {
|
|
223
|
+
const h = createHash('sha1')
|
|
224
|
+
for (const f of settings) {
|
|
225
|
+
const text = readOrNull(isAbsolute(f) ? f : join(root, f))
|
|
226
|
+
h.update(`${f}\u0000${text ?? '-'}\u0000`)
|
|
227
|
+
if (text == null) continue
|
|
228
|
+
let hooks: DeclaredHook[] = []
|
|
229
|
+
try {
|
|
230
|
+
hooks = parseHooks(text, 'repo', f)
|
|
231
|
+
} catch { /* the body reports it */ }
|
|
232
|
+
for (const x of hooks)
|
|
233
|
+
for (const s of scriptsOf(x.command, root, home)) {
|
|
234
|
+
const st = statSync(safeReal(s))
|
|
235
|
+
h.update(`${s}:${st.size}:${Math.floor(st.mtimeMs)}\u0000`)
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return h.digest('hex').slice(0, 16)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// ── the verdict ────────────────────────────────────────────────────────────
|
|
242
|
+
|
|
243
|
+
export type Measure = { runs: number; p50: number; p90: number; max: number; total: number }
|
|
244
|
+
|
|
245
|
+
export function measureOf(ms: number[]): Measure | null {
|
|
246
|
+
if (ms.length === 0) return null
|
|
247
|
+
const s = [...ms].sort((a, b) => a - b)
|
|
248
|
+
const q = (p: number): number => s[Math.min(s.length - 1, Math.floor(p * s.length))] ?? 0
|
|
249
|
+
return { runs: s.length, p50: q(0.5), p90: q(0.9), max: s[s.length - 1] ?? 0, total: s.reduce((a, b) => a + b, 0) }
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export type Verdict = { level: 'ok' | 'warn' | 'fail'; text: string; fix?: string }
|
|
253
|
+
|
|
254
|
+
/** 40 ms, 1.3 s */
|
|
255
|
+
export const fmtHookMs = (ms: number): string => (ms < 1000 ? `${Math.round(ms)} ms` : `${(ms / 1000).toFixed(1)} s`)
|
|
256
|
+
|
|
257
|
+
const recordedWords = (m: Measure): string => `median ${fmtHookMs(m.p50)} over ${m.runs} recorded run${m.runs === 1 ? '' : 's'} (p90 ${fmtHookMs(m.p90)}, worst ${fmtHookMs(m.max)})`
|
|
258
|
+
|
|
259
|
+
const probeWords = (p: Probe): string => {
|
|
260
|
+
const m = measureOf(p.ms)
|
|
261
|
+
return m == null ? 'no probe run' : `fastest ${fmtHookMs(Math.min(...p.ms))}, median ${fmtHookMs(m.p50)} of ${m.runs} probe runs on a no-op Bash call`
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export const hookLabel = (h: DeclaredHook): string =>
|
|
265
|
+
`${cadenceOf(h.event) === 'call' ? `${h.event} on ${matcherLabel(h.matcher)}` : h.event} (${h.file}): ${h.command === '' ? `a ${h.type} hook` : `\`${h.command}\``}`
|
|
266
|
+
|
|
267
|
+
/** the key of repo.config.ts that declares a hook the gate cannot time */
|
|
268
|
+
export const INSTANT_KEY = 'instantHooks'
|
|
269
|
+
|
|
270
|
+
/** why a hook has no timed run: every hook of a turn's end is recorded, the others only when they print */
|
|
271
|
+
const notRecorded = (event: string): string => (event === 'Stop' || event === 'SubagentStop' ? 'the harness records every hook of a turn end: none ran in the records read' : 'the harness records a hook run only when the hook prints something')
|
|
272
|
+
const AS_A_CHECK = 'work over the tree runs as a check when the step is done: sk ci --only <check>'
|
|
273
|
+
|
|
274
|
+
/** SK045's verdict on one per call hook, from what the gate itself can tell:
|
|
275
|
+
* its probe, or the repo's word that it answers at once. `instant` is the
|
|
276
|
+
* reason the repo declares, `machine` (a user level hook) turns a fail into a warn */
|
|
277
|
+
export function judgeGate(h: DeclaredHook, probe: Probe | null, opts: { instant?: string; machine?: boolean } = {}): Verdict {
|
|
278
|
+
const label = hookLabel(h)
|
|
279
|
+
const red = opts.machine ? 'warn' : 'fail'
|
|
280
|
+
const lift = h.source === 'user' ? `drop it from ${h.file}` : `remove its entry in ${h.file}`
|
|
281
|
+
if (probe == null) {
|
|
282
|
+
if (opts.instant != null) return { level: 'ok', text: `${label}: declared instant in repo.config.ts (${opts.instant}); its recorded runs: SK046` }
|
|
283
|
+
return {
|
|
284
|
+
level: red,
|
|
285
|
+
text: `${label}: a hook on every ${matcherLabel(h.matcher)} call that the gate cannot time (it runs only a hook that takes a Bash call: a made up save may write, and its cost hangs on the file), and repo.config.ts does not declare it instant`,
|
|
286
|
+
fix: `${lift}, or declare it in repo.config.ts ${INSTANT_KEY} with the reason it answers at once; ${AS_A_CHECK}`,
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (probe.timedOut || (probe.ms.length > 0 && Math.min(...probe.ms) > CALL_BUDGET_MS && (probe.code === 0 || probe.code === 2)))
|
|
290
|
+
return {
|
|
291
|
+
level: red,
|
|
292
|
+
text: `${label}: ${probe.timedOut ? `a probe run on a no-op Bash call took over ${fmtHookMs(probe.ms[probe.ms.length - 1] ?? 0)}` : probeWords(probe)}, over the ${CALL_BUDGET_MS} ms budget of a hook on every tool call${h.source === 'user' ? ' (a hook of every session on the machine)' : ''}`,
|
|
293
|
+
fix: `make it read its input and decide under ${CALL_BUDGET_MS} ms, or ${lift}; ${AS_A_CHECK}`,
|
|
294
|
+
}
|
|
295
|
+
if (probe.code !== 0 && probe.code !== 2)
|
|
296
|
+
return { level: 'warn', text: `${label}: its probe exited ${probe.code} on a no-op Bash call, so every call it applies to runs a broken hook`, fix: `run it by hand on a Bash call's input and fix its command, or ${lift}` }
|
|
297
|
+
return { level: 'ok', text: `${label}: ${probeWords(probe)}` }
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** SK046's verdict on one hook from the runs the harness recorded: a warning
|
|
301
|
+
* past the budget of its cadence, never a fail (the index is the world) */
|
|
302
|
+
export function judgeRecords(h: DeclaredHook, recorded: number[], behind?: string): Verdict {
|
|
303
|
+
const label = hookLabel(h)
|
|
304
|
+
const rec = measureOf(recorded)
|
|
305
|
+
const cadence = cadenceOf(h.event)
|
|
306
|
+
const budget = cadence === 'call' ? CALL_BUDGET_MS : TURN_BUDGET_MS
|
|
307
|
+
if (rec == null) return { level: 'ok', text: `${label}: no timed run recorded (${notRecorded(h.event)})${behind == null ? '' : `; ${behind}`}` }
|
|
308
|
+
if (rec.runs >= MIN_RUNS && rec.p50 > budget)
|
|
309
|
+
return {
|
|
310
|
+
level: 'warn',
|
|
311
|
+
text: `${label}: ${recordedWords(rec)}, over the ${fmtHookMs(budget)} budget of a hook on every ${cadence === 'call' ? 'tool call' : 'prompt or turn end'}`,
|
|
312
|
+
fix: `make it read its input and decide under ${fmtHookMs(budget)}, or remove it; ${AS_A_CHECK}`,
|
|
313
|
+
}
|
|
314
|
+
return { level: 'ok', text: `${label}: ${recordedWords(rec)}${rec.runs < MIN_RUNS ? `, ${MIN_RUNS} needed to judge` : ''}` }
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function readOrNull(path: string): string | null {
|
|
318
|
+
try {
|
|
319
|
+
return readFileSync(path, 'utf8')
|
|
320
|
+
} catch {
|
|
321
|
+
return null
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function safeReal(p: string): string {
|
|
326
|
+
try {
|
|
327
|
+
return realpathSync(p)
|
|
328
|
+
} catch {
|
|
329
|
+
return p
|
|
330
|
+
}
|
|
331
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// The commands that reached the time limit of their call, summed for a
|
|
2
|
+
// reader: what became of them, by command (a `<file>` command by its scripts),
|
|
3
|
+
// and the newest. The page and the console read the same sums.
|
|
4
|
+
import type { TimeoutRow } from './report.ts'
|
|
5
|
+
|
|
6
|
+
export const TOP_LIMIT_SHAPES = 15
|
|
7
|
+
/** the scripts a `<file>` row opens on */
|
|
8
|
+
export const TOP_FILE_PARTS = 10
|
|
9
|
+
export const TOP_TIMEOUTS = 40
|
|
10
|
+
|
|
11
|
+
/** the commands that reached the time limit of their call, summed by shape */
|
|
12
|
+
/** `parts`: for a `<file>` shape, the scripts that reached the limit */
|
|
13
|
+
export type TimeoutShape = { shape: string; n: number; finished: number; lost: number; limitMs: number; typicalTotalMs: number | null; parts?: TimeoutShape[] }
|
|
14
|
+
export type Timeouts = { count: number; finished: number; failed: number; stopped: number; lost: number; limitMs: number; byShape: TimeoutShape[]; rows: TimeoutRow[] }
|
|
15
|
+
|
|
16
|
+
const median = (xs: number[]): number | null => (xs.length === 0 ? null : ([...xs].sort((a, b) => a - b)[Math.floor(xs.length / 2)] ?? null))
|
|
17
|
+
|
|
18
|
+
/** the commands that reached their call's time limit: the counts by what became of them, by shape, and the newest */
|
|
19
|
+
export function timeoutsOf(rows: readonly TimeoutRow[]): Timeouts {
|
|
20
|
+
const count = (after: TimeoutRow['after'], of: readonly TimeoutRow[] = rows): number => of.filter((t) => t.after === after).length
|
|
21
|
+
/** the rows summed under a name, the most hits first */
|
|
22
|
+
const cut = (of: readonly TimeoutRow[], key: (t: TimeoutRow) => string): TimeoutShape[] => {
|
|
23
|
+
const by = new Map<string, TimeoutRow[]>()
|
|
24
|
+
for (const t of of) by.set(key(t), [...(by.get(key(t)) ?? []), t])
|
|
25
|
+
return [...by.entries()]
|
|
26
|
+
.map(([shape, ts]) => ({ shape, n: ts.length, finished: count('ok', ts), lost: count('none', ts), limitMs: ts.reduce((n, t) => n + t.limitMs, 0), typicalTotalMs: median(ts.flatMap((t) => (t.totalMs == null ? [] : [t.totalMs]))) }))
|
|
27
|
+
.sort((a, b) => b.n - a.n || a.shape.localeCompare(b.shape))
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
count: rows.length,
|
|
31
|
+
finished: count('ok'),
|
|
32
|
+
failed: count('failed'),
|
|
33
|
+
stopped: count('stopped'),
|
|
34
|
+
lost: count('none'),
|
|
35
|
+
limitMs: rows.reduce((n, t) => n + t.limitMs, 0),
|
|
36
|
+
byShape: cut(rows, (t) => t.shape)
|
|
37
|
+
.slice(0, TOP_LIMIT_SHAPES)
|
|
38
|
+
.map((s) => {
|
|
39
|
+
const scripts = rows.filter((t) => t.shape === s.shape && t.script != null)
|
|
40
|
+
return scripts.length === 0 ? s : { ...s, parts: cut(scripts, (t) => t.script ?? '').slice(0, TOP_FILE_PARTS) }
|
|
41
|
+
}),
|
|
42
|
+
rows: rows.slice(0, TOP_TIMEOUTS),
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/agent-time/live.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// each time someone looks.
|
|
9
9
|
import { closeSync, openSync, readFileSync, readSync, statSync } from 'fs'
|
|
10
10
|
import type { TranscriptFile } from './store.ts'
|
|
11
|
+
import { HAND_BACK } from './timeline.ts'
|
|
11
12
|
|
|
12
13
|
const HEAD_BYTES = 64 * 1024
|
|
13
14
|
const TAIL_BYTES = 256 * 1024
|
|
@@ -54,9 +55,6 @@ export function callWords(p: Part): string {
|
|
|
54
55
|
return `${p.name ?? 'tool'}${one === '' ? '' : `: ${one.length > 70 ? `${one.slice(0, 69)}…` : one}`}`
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
/** the call a sub-agent ends on: its report handed back to the session that started it */
|
|
58
|
-
const HAND_BACK = 'SubagentHandback'
|
|
59
|
-
|
|
60
58
|
/** what the last entries of a transcript say the agent does now. `lines` are its last lines, oldest first */
|
|
61
59
|
export function stateOf(lines: readonly string[]): { state: LiveState; at: number } {
|
|
62
60
|
// a result just came back, or a request is in flight: a model turn, unless the call before it was the hand back
|