rvlib-shipkit 2.29.0 → 2.30.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 -1
- package/package.json +2 -1
- package/src/advisors/app-graph.ts +1 -1
- package/src/advisors/expose.ts +5 -1
- package/src/advisors/r2.ts +7 -9
- package/src/advisors/routes.ts +29 -2
- package/src/advisors/scan.ts +11 -0
- package/src/agent-time/accounts-usage.ts +8 -0
- package/src/agent-time/claude-sessions.ts +32 -0
- package/src/agent-time/hooks.ts +1 -1
- package/src/agent-time/live.ts +5 -2
- package/src/agent-time/registry.ts +186 -89
- package/src/agent-time/store.ts +6 -4
- package/src/asks/ask-doc.ts +2 -2
- package/src/asks/ask-store.ts +22 -7
- package/src/check.ts +9 -1
- package/src/checks/SK001-package-json-shape.check.ts +1 -0
- package/src/checks/SK003-claude-md-shape.check.ts +1 -0
- package/src/checks/SK004-gitignore-policy.check.ts +12 -6
- package/src/checks/SK008-reviewer-agent.check.ts +4 -7
- package/src/checks/SK013-one-way-in-policy.check.ts +1 -0
- package/src/checks/SK017-vscode-hub-task.check.ts +1 -0
- package/src/checks/SK024-identity-colors.check.ts +1 -1
- package/src/checks/SK027-agent-wiki-links.check.ts +2 -1
- package/src/checks/SK033-global-contribution.check.ts +1 -0
- package/src/checks/SK034-commit-gates-armed.check.ts +1 -0
- package/src/checks/SK039-vscode-watch-generated.check.ts +1 -0
- package/src/checks/SK049-thread-answers-hook.check.ts +9 -5
- package/src/checks/SK050-retired-commands.check.ts +1 -0
- package/src/checks/SK051-no-formatter.check.ts +1 -0
- package/src/cli/channel-run.ts +17 -0
- package/src/cli/cmd_Advisors.ts +28 -7
- package/src/cli/cmd_Asks.ts +2 -2
- package/src/cli/cmd_Backup.ts +5 -1
- package/src/cli/cmd_CacheAudit.ts +1 -1
- package/src/cli/cmd_Channel.ts +43 -0
- package/src/cli/cmd_GlobalProcesses.ts +1 -0
- package/src/cli/cmd_Home.ts +12 -5
- package/src/cli/cmd_Hooks.ts +1 -1
- package/src/cli/cmd_Hq.ts +43 -0
- package/src/cli/cmd_Lanes.ts +15 -3
- package/src/cli/cmd_Media.ts +8 -3
- package/src/cli/cmd_Orchestrator.ts +253 -84
- package/src/cli/cmd_OrchestratorRole.ts +163 -0
- package/src/cli/cmd_Review.ts +142 -165
- package/src/cli/cmd_Secret.ts +44 -14
- package/src/cli/cmd_Shot.ts +2 -4
- package/src/cli/cmd_Sound.ts +1 -0
- package/src/cli/cmd_Urls.ts +3 -3
- package/src/cli/inbox-hook-run.ts +109 -0
- package/src/cli/registry.ts +6 -2
- package/src/cli/review-here.ts +136 -0
- package/src/cli.ts +45 -14
- package/src/collections/actions.ts +5 -4
- package/src/collections/checks.ts +5 -0
- package/src/collections/collection-types.ts +4 -3
- package/src/collections/pings.ts +4 -1
- package/src/collections/providers.ts +6 -4
- package/src/collections/tests.ts +7 -4
- package/src/core/app-icon-frame.ts +62 -0
- package/src/core/app-icon.ts +179 -17
- package/src/core/archived.ts +10 -7
- package/src/core/check-ctx.ts +38 -4
- package/src/core/check-pass.ts +7 -0
- package/src/core/foreign.ts +87 -0
- package/src/core/gui-color.ts +75 -0
- package/src/core/hub-theme.ts +1 -3
- package/src/core/layout.ts +3 -0
- package/src/core/machine-commit.ts +9 -1
- package/src/core/one-lib.ts +2 -1
- package/src/core/one-way-in-policy.ts +17 -12
- package/src/core/owner-word-policy.ts +123 -0
- package/src/core/panel-shades.ts +140 -0
- package/src/core/repo-gui-color.ts +16 -0
- package/src/core/role-policy.ts +17 -0
- package/src/core/scope.ts +6 -3
- package/src/core/tmux-policy.ts +264 -0
- package/src/core/unit-icon.ts +43 -0
- package/src/fleet/push-fleet.ts +2 -0
- package/src/fleet/scan-fleet.ts +3 -0
- package/src/gate/cache-audit.ts +7 -1
- package/src/gate/gate-checks.ts +14 -9
- package/src/gate/run-fix.ts +30 -5
- package/src/gate/run-fixers.ts +8 -3
- package/src/home/activity-shape.ts +2 -0
- package/src/home/activity.ts +2 -1
- package/src/home/daemon-guard.ts +20 -2
- package/src/home/daemon-jobs.ts +26 -18
- package/src/home/gui-app/ShipkitGui.swift +2012 -144
- package/src/home/gui-app/icon.svg +8 -0
- package/src/home/gui-app.ts +94 -30
- package/src/home/home-routes.ts +53 -9
- package/src/home/home-start.ts +27 -3
- package/src/home/inbox-shape.ts +7 -3
- package/src/home/log-follow.ts +117 -0
- package/src/home/machine-fold.ts +1 -1
- package/src/home/open-app.ts +9 -3
- package/src/home/page-build.ts +5 -1
- package/src/home/page-held.ts +1 -1
- package/src/home/pm-config.ts +0 -8
- package/src/home/pm.ts +62 -5
- package/src/home/process-apps.ts +70 -23
- package/src/home/process-rows.ts +16 -1
- package/src/home/push-sources.ts +18 -13
- package/src/home/resources.ts +16 -7
- package/src/home/run-daemon.ts +4 -1
- package/src/home/run-pm.ts +1 -1
- package/src/home/serve-daemon.ts +13 -4
- package/src/home/serve-web.ts +141 -17
- package/src/home/space-page.ts +3 -3
- package/src/home/space-route.ts +2 -2
- package/src/home/supervise.ts +2 -1
- package/src/home/vault-page.ts +2 -1
- package/src/home/web-places.ts +239 -0
- package/src/home/widgets.ts +16 -2
- package/src/hooks/commit-message.ts +11 -9
- package/src/hooks/one-way-in-guard.ts +145 -68
- package/src/hooks/run-hooks.ts +15 -5
- package/src/hooks/shared-file.ts +273 -83
- package/src/hooks/shell-writes.ts +620 -0
- package/src/hooks/write-log.ts +149 -0
- package/src/hq/door-route.ts +63 -7
- package/src/hq/door.ts +45 -12
- package/src/hq/history-send.ts +3 -1
- package/src/hq/hq-db.ts +10 -3
- package/src/hq/hq-local.ts +24 -5
- package/src/hq/hq-routes.ts +3 -1
- package/src/hq/hq-store.ts +9 -3
- package/src/hq/kinds/index.ts +2 -1
- package/src/hq/kinds/kind.ts +9 -4
- package/src/hq/kinds/presence-rule.ts +56 -0
- package/src/hq/kinds/presence.ts +210 -0
- package/src/hq/kinds/report.ts +8 -5
- package/src/hq/lead-order.ts +68 -0
- package/src/hq/outbox.ts +7 -0
- package/src/hq/replica.ts +5 -7
- package/src/hq/report-facts.ts +14 -7
- package/src/hq/report.ts +47 -2
- package/src/hq/switch.ts +1 -0
- package/src/hq/terminal-hop.ts +64 -0
- package/src/hq/thread-sync.ts +13 -6
- package/src/http/door-forward.ts +10 -12
- package/src/http/door-names.ts +9 -0
- package/src/http/hop-caller.ts +23 -0
- package/src/http/hop-names.ts +14 -0
- package/src/http/loopback-serve.ts +28 -6
- package/src/http/owner-word.ts +128 -0
- package/src/http/same-origin.ts +12 -0
- package/src/{serve → http}/secret-gate.ts +3 -3
- package/src/ledger/run-log.ts +25 -1
- package/src/media-store/backup/sources.ts +53 -6
- package/src/media-store/backup/thread-copy.ts +9 -5
- package/src/media-store/copy/config.ts +10 -9
- package/src/media-store/daemon.ts +5 -2
- package/src/media-store/put.ts +3 -0
- package/src/media-store/space.ts +14 -16
- package/src/media-store/upload.ts +4 -0
- package/src/messages/collection.ts +2 -2
- package/src/messages/model.ts +6 -1
- package/src/messages/routes.ts +3 -0
- package/src/orchestrator/brief.md +8 -6
- package/src/orchestrator/channel-declare.ts +58 -0
- package/src/orchestrator/channel.ts +226 -0
- package/src/orchestrator/guards.ts +12 -3
- package/src/orchestrator/host.ts +35 -0
- package/src/orchestrator/lead-shape.ts +86 -0
- package/src/orchestrator/now.ts +88 -0
- package/src/orchestrator/phone.ts +4 -1
- package/src/orchestrator/places-file.ts +38 -0
- package/src/orchestrator/places-look.ts +180 -0
- package/src/orchestrator/places-shape.ts +151 -0
- package/src/orchestrator/places.ts +50 -0
- package/src/orchestrator/presence-shape.ts +13 -2
- package/src/orchestrator/presence.ts +26 -15
- package/src/orchestrator/push.ts +5 -10
- package/src/orchestrator/role-shape.ts +270 -0
- package/src/orchestrator/role.ts +242 -0
- package/src/orchestrator/routes.ts +136 -31
- package/src/orchestrator/sessions-shape.ts +78 -0
- package/src/orchestrator/sessions.ts +86 -0
- package/src/orchestrator/share.ts +71 -0
- package/src/orchestrator/start-notice.ts +61 -0
- package/src/orchestrator/start.ts +137 -0
- package/src/orchestrator/started.ts +55 -0
- package/src/orchestrator/stuck.ts +196 -0
- package/src/orchestrator/unheard.ts +18 -7
- package/src/pages/frame-client.ts +44 -6
- package/src/problems/failure-words.ts +80 -0
- package/src/release/run-bump.ts +26 -5
- package/src/release/run-release.ts +34 -14
- package/src/repo-config.ts +37 -9
- package/src/review/aside-at.ts +19 -0
- package/src/review/band.ts +3 -3
- package/src/review/doc-save.ts +1 -1
- package/src/review/inbox-hook.ts +12 -4
- package/src/review/inbox-read.ts +20 -7
- package/src/review/instruction-guards.ts +137 -0
- package/src/review/instructions.ts +14 -2
- package/src/review/item-db.ts +52 -2
- package/src/review/mentions.ts +6 -4
- package/src/review/model.ts +3 -2
- package/src/review/parties.ts +88 -19
- package/src/review/push.ts +32 -15
- package/src/review/routes.ts +12 -4
- package/src/review/secret-route.ts +5 -5
- package/src/review/snooze.ts +1 -16
- package/src/review/store-parties.ts +4 -2
- package/src/review/take-back.ts +2 -1
- package/src/review/threads.ts +13 -2
- package/src/review/unit.ts +3 -2
- package/src/review/view-layout.ts +8 -1
- package/src/review/watchers.ts +25 -4
- package/src/secrets/key-pair.ts +14 -0
- package/src/secrets/lapse.ts +3 -3
- package/src/secrets/manager.ts +5 -1
- package/src/secrets/name-template.ts +83 -0
- package/src/secrets/name.ts +3 -0
- package/src/secrets/read.ts +10 -6
- package/src/secrets/secrets-view.ts +299 -0
- package/src/secrets/who-reads.ts +2 -1
- package/src/serve/frame-part.ts +49 -0
- package/src/serve/hub-app/accounts-line.tsx +33 -45
- package/src/serve/hub-app/activity-st.ts +6 -5
- package/src/serve/hub-app/activity-view.tsx +10 -9
- package/src/serve/hub-app/advice-box.tsx +6 -5
- package/src/serve/hub-app/advisor-app.tsx +2 -0
- package/src/serve/hub-app/advisor-face.tsx +3 -2
- package/src/serve/hub-app/advisor.html +1 -0
- package/src/serve/hub-app/advisors-view.tsx +52 -10
- package/src/serve/hub-app/advisors.css +4 -0
- package/src/serve/hub-app/app-bridge.ts +31 -5
- package/src/serve/hub-app/asked-page.ts +24 -0
- package/src/serve/hub-app/asks-page.tsx +10 -6
- package/src/serve/hub-app/auto-text.tsx +7 -5
- package/src/serve/hub-app/card-head.tsx +3 -2
- package/src/serve/hub-app/check-view.tsx +10 -9
- package/src/serve/hub-app/checks-svc.ts +96 -32
- package/src/serve/hub-app/clock-svc.ts +24 -8
- package/src/serve/hub-app/code-copy.ts +1 -1
- package/src/serve/hub-app/col-card.tsx +2 -1
- package/src/serve/hub-app/col-list-page.tsx +12 -6
- package/src/serve/hub-app/col-list-st.ts +12 -2
- package/src/serve/hub-app/col-tables-view.tsx +8 -44
- package/src/serve/hub-app/col-tables.ts +0 -14
- package/src/serve/hub-app/cols-svc.ts +6 -12
- package/src/serve/hub-app/columns.ts +94 -0
- package/src/serve/hub-app/comfy-view.tsx +8 -7
- package/src/serve/hub-app/commands/commands-page.tsx +4 -3
- package/src/serve/hub-app/commands/commands-st.ts +2 -2
- package/src/serve/hub-app/controls.css +69 -23
- package/src/serve/hub-app/cycle-button.tsx +2 -1
- package/src/serve/hub-app/database-st.ts +1 -1
- package/src/serve/hub-app/database-view.tsx +4 -2
- package/src/serve/hub-app/deaf.tsx +27 -0
- package/src/serve/hub-app/dock-st.ts +21 -16
- package/src/serve/hub-app/dock-view.tsx +19 -12
- package/src/serve/hub-app/empty-section.tsx +30 -0
- package/src/serve/hub-app/entry-bar.css +1 -1
- package/src/serve/hub-app/entry-bar.tsx +11 -6
- package/src/serve/hub-app/entry-list.css +32 -0
- package/src/serve/hub-app/entry-list.tsx +123 -0
- package/src/serve/hub-app/entry-pick.ts +1 -1
- package/src/serve/hub-app/entry-sections.ts +140 -0
- package/src/serve/hub-app/event-stream-reader.ts +56 -0
- package/src/serve/hub-app/floating.tsx +68 -14
- package/src/serve/hub-app/geometry-view.tsx +3 -2
- package/src/serve/hub-app/git-view.tsx +3 -2
- package/src/serve/hub-app/hash-route.ts +14 -2
- package/src/serve/hub-app/header-bar.tsx +53 -36
- package/src/serve/hub-app/home-st.ts +131 -14
- package/src/serve/hub-app/home-strip.css +24 -13
- package/src/serve/hub-app/home-strip.tsx +131 -66
- package/src/serve/hub-app/home.html +5 -0
- package/src/serve/hub-app/hub-app.tsx +94 -102
- package/src/serve/hub-app/hub.css +61 -94
- package/src/serve/hub-app/icons.tsx +16 -0
- package/src/serve/hub-app/identities-st.ts +19 -54
- package/src/serve/hub-app/identities-view.tsx +25 -24
- package/src/serve/hub-app/identity-address.ts +2 -2
- package/src/serve/hub-app/in-sight.ts +10 -0
- package/src/serve/hub-app/inbox-st.ts +20 -2
- package/src/serve/hub-app/inbox-view.tsx +16 -9
- package/src/serve/hub-app/inbox.css +1 -0
- package/src/serve/hub-app/index.html +5 -0
- package/src/serve/hub-app/insights-view.tsx +6 -5
- package/src/serve/hub-app/instructions.css +4 -1
- package/src/serve/hub-app/kept-cols.tsx +83 -20
- package/src/serve/hub-app/kept-width.tsx +76 -0
- package/src/serve/hub-app/keys.ts +116 -38
- package/src/serve/hub-app/layout-st.ts +109 -99
- package/src/serve/hub-app/lightbox-zoom.css +36 -0
- package/src/serve/hub-app/list-filter.tsx +15 -6
- package/src/serve/hub-app/list-head.tsx +29 -0
- package/src/serve/hub-app/list-row.ts +8 -0
- package/src/serve/hub-app/list-walk.ts +26 -105
- package/src/serve/hub-app/live-socket.ts +274 -0
- package/src/serve/hub-app/live-sources.ts +189 -0
- package/src/serve/hub-app/live-svc.ts +2 -2
- package/src/serve/hub-app/machine-st.ts +75 -14
- package/src/serve/hub-app/main-panel.css +211 -0
- package/src/serve/hub-app/main-panel.tsx +259 -0
- package/src/serve/hub-app/md.ts +4 -4
- package/src/serve/hub-app/media-svc.ts +5 -5
- package/src/serve/hub-app/media-view.tsx +13 -12
- package/src/serve/hub-app/messages/messages-page.tsx +8 -7
- package/src/serve/hub-app/messages/messages-st.ts +5 -2
- package/src/serve/hub-app/new-thread-st.ts +170 -0
- package/src/serve/hub-app/new-thread.tsx +133 -107
- package/src/serve/hub-app/orchestrator-line.tsx +115 -45
- package/src/serve/hub-app/orchestrator-places.tsx +86 -0
- package/src/serve/hub-app/orchestrator.css +57 -5
- package/src/serve/hub-app/page-keys.ts +107 -68
- package/src/serve/hub-app/page-reload.ts +46 -6
- package/src/serve/hub-app/pages-frames.tsx +40 -3
- package/src/serve/hub-app/pages-svc.ts +3 -1
- package/src/serve/hub-app/palette-st.ts +198 -43
- package/src/serve/hub-app/palette-view.tsx +32 -8
- package/src/serve/hub-app/panel-head-action.tsx +39 -0
- package/src/serve/hub-app/panel-head.tsx +70 -0
- package/src/serve/hub-app/panel-repo.ts +42 -0
- package/src/serve/hub-app/panel-source.ts +195 -0
- package/src/serve/hub-app/panel-tint.css +6 -0
- package/src/serve/hub-app/panel-tint.ts +23 -0
- package/src/serve/hub-app/panel-walk.ts +107 -0
- package/src/serve/hub-app/pill-row.tsx +2 -1
- package/src/serve/hub-app/place-path.ts +4 -0
- package/src/serve/hub-app/places-svc.ts +75 -0
- package/src/serve/hub-app/plan-view.tsx +3 -2
- package/src/serve/hub-app/polled.ts +11 -1
- package/src/serve/hub-app/presence-st.ts +66 -32
- package/src/serve/hub-app/processes-view.tsx +2 -2
- package/src/serve/hub-app/project-bar.tsx +116 -0
- package/src/serve/hub-app/project-list.css +20 -173
- package/src/serve/hub-app/project-list.tsx +30 -298
- package/src/serve/hub-app/projects-svc.ts +59 -32
- package/src/serve/hub-app/push-sign.tsx +2 -1
- package/src/serve/hub-app/push-svc.ts +86 -69
- package/src/serve/hub-app/quiet-st.ts +5 -3
- package/src/serve/hub-app/rail-groups.ts +144 -0
- package/src/serve/hub-app/reader-chips.tsx +2 -1
- package/src/serve/hub-app/recordings-st.ts +2 -1
- package/src/serve/hub-app/recordings-view.tsx +19 -47
- package/src/serve/hub-app/recordings.css +0 -2
- package/src/serve/hub-app/reflections-page.tsx +10 -6
- package/src/serve/hub-app/releases/releases-page.tsx +6 -5
- package/src/serve/hub-app/repo-sections.ts +127 -38
- package/src/serve/hub-app/repo-st.ts +57 -36
- package/src/serve/hub-app/review/advisor-bar.tsx +3 -2
- package/src/serve/hub-app/review/ask-proof.tsx +79 -0
- package/src/serve/hub-app/review/attach-view.tsx +11 -10
- package/src/serve/hub-app/review/box-view.ts +479 -0
- package/src/serve/hub-app/review/box-zoom.tsx +70 -0
- package/src/serve/hub-app/review/diff-view.tsx +3 -2
- package/src/serve/hub-app/review/doc-body.tsx +2 -1
- package/src/serve/hub-app/review/dock.tsx +3 -2
- package/src/serve/hub-app/review/draft-body.tsx +4 -3
- package/src/serve/hub-app/review/faces.tsx +0 -8
- package/src/serve/hub-app/review/group-block.tsx +8 -7
- package/src/serve/hub-app/review/heard-line.tsx +4 -3
- package/src/serve/hub-app/review/instructions-view.tsx +3 -2
- package/src/serve/hub-app/review/item-verdict.tsx +40 -40
- package/src/serve/hub-app/review/kind-states.tsx +5 -4
- package/src/serve/hub-app/review/kit.tsx +24 -4
- package/src/serve/hub-app/review/lane-bar.tsx +30 -28
- package/src/serve/hub-app/review/lightbox.tsx +6 -4
- package/src/serve/hub-app/review/live-bar.tsx +7 -6
- package/src/serve/hub-app/review/live-view.tsx +6 -5
- package/src/serve/hub-app/review/object-card.tsx +2 -1
- package/src/serve/hub-app/review/object-panel.tsx +11 -10
- package/src/serve/hub-app/review/pano-view.tsx +3 -2
- package/src/serve/hub-app/review/question-views.tsx +6 -5
- package/src/serve/hub-app/review/review-cells.tsx +21 -20
- package/src/serve/hub-app/review/review-host.ts +3 -0
- package/src/serve/hub-app/review/review-kit.ts +7 -5
- package/src/serve/hub-app/review/review-list.tsx +98 -52
- package/src/serve/hub-app/review/review-page.tsx +3 -3
- package/src/serve/hub-app/review/review-st.ts +70 -14
- package/src/serve/hub-app/review/review-thread.tsx +234 -138
- package/src/serve/hub-app/review/review-views.tsx +166 -191
- package/src/serve/hub-app/review/space3d.tsx +17 -9
- package/src/serve/hub-app/review/thread-close.tsx +24 -32
- package/src/serve/hub-app/review/thread-st.ts +39 -25
- package/src/serve/hub-app/review/trailer-body.tsx +5 -4
- package/src/serve/hub-app/review/trailer-page.tsx +18 -16
- package/src/serve/hub-app/review/trailer-st.ts +3 -2
- package/src/serve/hub-app/review/trailer-timeline.tsx +10 -9
- package/src/serve/hub-app/review/trailer-voices.tsx +29 -28
- package/src/serve/hub-app/review.css +159 -42
- package/src/serve/hub-app/row-acts.tsx +126 -0
- package/src/serve/hub-app/row-face.tsx +29 -0
- package/src/serve/hub-app/running-rows.tsx +142 -0
- package/src/serve/hub-app/running-st.ts +110 -0
- package/src/serve/hub-app/search-view.tsx +3 -2
- package/src/serve/hub-app/secrets-page.tsx +290 -0
- package/src/serve/hub-app/secrets-st.ts +181 -0
- package/src/serve/hub-app/secrets.css +65 -0
- package/src/serve/hub-app/section-head.tsx +3 -2
- package/src/serve/hub-app/session-chips.tsx +55 -0
- package/src/serve/hub-app/shell.ts +56 -0
- package/src/serve/hub-app/site/site-part.tsx +6 -5
- package/src/serve/hub-app/site/site-st.ts +0 -6
- package/src/serve/hub-app/site.css +0 -1
- package/src/serve/hub-app/social/calendar.tsx +7 -6
- package/src/serve/hub-app/social/comms-page.tsx +29 -26
- package/src/serve/hub-app/social/group-editor.tsx +2 -1
- package/src/serve/hub-app/social/kit.tsx +12 -11
- package/src/serve/hub-app/social/next-release.tsx +3 -2
- package/src/serve/hub-app/social/post-card.tsx +21 -20
- package/src/serve/hub-app/social/post-page.tsx +2 -1
- package/src/serve/hub-app/social/problems.tsx +3 -2
- package/src/serve/hub-app/social/social-page.tsx +29 -27
- package/src/serve/hub-app/social/social-st.ts +4 -2
- package/src/serve/hub-app/social/stage-popup.tsx +11 -10
- package/src/serve/hub-app/social.css +7 -5
- package/src/serve/hub-app/source-acts.ts +79 -0
- package/src/serve/hub-app/source-page.tsx +17 -0
- package/src/serve/hub-app/space-view.tsx +5 -4
- package/src/serve/hub-app/stores/stores-page.tsx +21 -19
- package/src/serve/hub-app/stores/stores-st.ts +1 -1
- package/src/serve/hub-app/stores.css +1 -1
- package/src/serve/hub-app/terminal-history-st.ts +112 -0
- package/src/serve/hub-app/terminal-keys.ts +79 -0
- package/src/serve/hub-app/terminal-lib.ts +110 -0
- package/src/serve/hub-app/terminal-links.ts +55 -0
- package/src/serve/hub-app/terminal-list-st.ts +304 -0
- package/src/serve/hub-app/terminal-log-st.ts +242 -0
- package/src/serve/hub-app/terminal-out.ts +135 -0
- package/src/serve/hub-app/terminal-pages.tsx +115 -0
- package/src/serve/hub-app/terminal-panel.tsx +60 -9
- package/src/serve/hub-app/terminal-sources.tsx +335 -0
- package/src/serve/hub-app/terminal-st.ts +447 -167
- package/src/serve/hub-app/terminal-stream.ts +233 -0
- package/src/serve/hub-app/terminal-tab.tsx +64 -0
- package/src/serve/hub-app/terminal-widths.ts +30 -0
- package/src/serve/hub-app/terminal.css +50 -4
- package/src/serve/hub-app/test-view.tsx +5 -3
- package/src/serve/hub-app/tests-view.tsx +16 -15
- package/src/serve/hub-app/theme-st.ts +5 -0
- package/src/serve/hub-app/thread-row.tsx +39 -31
- package/src/serve/hub-app/time-ago.tsx +3 -2
- package/src/serve/hub-app/time-view.tsx +2 -1
- package/src/serve/hub-app/time.css +1 -1
- package/src/serve/hub-app/timeline-chart.tsx +5 -4
- package/src/serve/hub-app/timeline-view.tsx +10 -9
- package/src/serve/hub-app/tips.ts +247 -0
- package/src/serve/hub-app/tree-build.ts +40 -8
- package/src/serve/hub-app/tree-svc.ts +167 -134
- package/src/serve/hub-app/unit-icons.ts +26 -0
- package/src/serve/hub-app/url-address.ts +154 -0
- package/src/serve/hub-app/url-faces.ts +88 -0
- package/src/serve/hub-app/url-forms.tsx +183 -0
- package/src/serve/hub-app/urls-svc.ts +167 -5
- package/src/serve/hub-app/urls-view.tsx +56 -20
- package/src/serve/hub-app/urls.css +26 -0
- package/src/serve/hub-app/vault-view.tsx +5 -4
- package/src/serve/hub-app/veille/veille-page.tsx +34 -33
- package/src/serve/hub-app/veille/veille-st.ts +6 -3
- package/src/serve/hub-app/view-layout.css +3 -3
- package/src/serve/hub-app/when-view.tsx +5 -4
- package/src/serve/hub-app/wikis-view.tsx +6 -5
- package/src/serve/hub-app/words.tsx +9 -2
- package/src/serve/hub-runtime.ts +3 -2
- package/src/serve/orchestrator-host.ts +58 -0
- package/src/serve/page-live.ts +147 -0
- package/src/serve/project-gutter-route.ts +63 -2
- package/src/serve/read-worker.ts +7 -2
- package/src/serve/runs-stamp.ts +33 -0
- package/src/serve/secrets-read.ts +156 -0
- package/src/serve/serve-hub.ts +71 -22
- package/src/serve/terminal-claudes.ts +185 -0
- package/src/serve/terminal-guard.ts +10 -5
- package/src/serve/terminal-host.ts +517 -0
- package/src/serve/terminal-record.ts +104 -0
- package/src/serve/terminal-route.ts +466 -103
- package/src/serve/terminal-shells.ts +3 -0
- package/src/serve/terminal-watch.ts +102 -0
- package/src/shipkit-files.ts +9 -4
- package/src/shot/client.ts +4 -9
- package/src/shot/shooter.ts +2 -4
- package/src/shot/shot-ask.ts +2 -7
- package/src/shot/shot-theme.ts +6 -17
- package/src/social/routes.ts +2 -2
- package/src/social/writes.ts +3 -0
- package/src/suite/test-units.ts +6 -2
- package/src/trailer/sound/eleven.ts +1 -0
- package/src/urls/added.ts +111 -0
- package/src/urls/icons.ts +294 -0
- package/src/urls/places.ts +139 -0
- package/src/urls/routes.ts +17 -7
- package/src/urls/rows.ts +48 -15
- package/src/urls/unit.ts +57 -3
- package/src/urls/write-routes.ts +207 -0
- package/src/vault/vault-destroy.ts +2 -1
- package/src/vault/vault-import.ts +4 -11
- package/src/vault/vault-restore.ts +3 -2
- package/src/veille/chrome.ts +18 -3
- package/src/veille/identity.ts +6 -0
- package/src/view3d/cam.ts +30 -46
- package/src/view3d/lib.ts +20 -2
- package/src/view3d/viewer.ts +62 -88
- package/src/wiki/agent-paths.ts +2 -1
- package/src/orchestrator/deliver.ts +0 -81
- package/src/orchestrator/drill.ts +0 -129
- package/src/orchestrator/keeper.ts +0 -332
- package/src/orchestrator/pm.ts +0 -20
- package/src/orchestrator/state.ts +0 -92
- package/src/orchestrator/switch.ts +0 -86
- package/src/orchestrator/tmux.ts +0 -82
- package/src/serve/hub-app/rail-fly.tsx +0 -95
- package/src/serve/hub-app/side-lists.ts +0 -72
- package/src/serve/hub-app/sidebar.tsx +0 -62
- package/src/serve/hub-app/tree-row.tsx +0 -125
package/src/serve/serve-hub.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { existsSync, realpathSync } from 'fs'
|
|
|
8
8
|
import { fileURLToPath } from 'url'
|
|
9
9
|
import { PAGE_PATH, PageBuild, withPageNotices } from '../home/page-build.ts'
|
|
10
10
|
import { HELD_BUILD_SCRIPT, HELD_SOURCE_PATH, heldSource } from '../home/page-held.ts'
|
|
11
|
-
import { partiesStamp } from '../home/push-sources.ts'
|
|
11
|
+
import { dirStamp, partiesStamp } from '../home/push-sources.ts'
|
|
12
12
|
import { join } from 'path'
|
|
13
13
|
import { positionsFile } from 'rvlib-shipkit/src/wiki/graph-positions.ts'
|
|
14
14
|
import { imageOf, pageOf, searchWiki } from 'rvlib-shipkit/src/wiki/graph-pages.ts'
|
|
@@ -36,13 +36,14 @@ import { daemonPort, homePort, homeUp, pmPort } from '../home/home-paths.ts'
|
|
|
36
36
|
import { RUN_EXIT } from '../home/home-words.ts'
|
|
37
37
|
import { projectGutter } from './project-gutter-route.ts'
|
|
38
38
|
import { loopbackServe } from '../http/loopback-serve.ts'
|
|
39
|
+
import type { TestPage } from '../http/owner-word.ts'
|
|
39
40
|
import { sameOrigin } from '../http/same-origin.ts'
|
|
40
41
|
import { LAYOUT } from '../core/layout.ts'
|
|
41
42
|
import { heldNow, heldText } from '../core/last-good.ts'
|
|
42
43
|
import { WarmCell, warmQueue } from './warm-cell.ts'
|
|
43
44
|
import { resourcesAnswer, testRunsAnswer } from './resources-wire.ts'
|
|
44
45
|
import { readmeRoutes } from './readme-route.ts'
|
|
45
|
-
import { reviewRoutes } from '../review/routes.ts'
|
|
46
|
+
import { partiesStampWith, reviewRoutes } from '../review/routes.ts'
|
|
46
47
|
import { ThreadPush, type PushSource } from '../review/push.ts'
|
|
47
48
|
import { storeDir } from '../review/store.ts'
|
|
48
49
|
import type { TailnetWho } from '../http/tailnet-caller.ts'
|
|
@@ -53,12 +54,16 @@ import { releasesRoutes } from '../releases/routes.ts'
|
|
|
53
54
|
import { docRoutes } from '../review/doc-routes.ts'
|
|
54
55
|
import { commandsRoutes } from '../commands/routes.ts'
|
|
55
56
|
import { noCli } from '../commands/registry.ts'
|
|
57
|
+
import { sessionsDir } from '../agent-time/registry.ts'
|
|
56
58
|
import { socialRoutes } from '../social/routes.ts'
|
|
57
59
|
import type { Publishers } from '../social/publish/index.ts'
|
|
58
60
|
import { embedRoute } from './embed.ts'
|
|
59
61
|
import { pagesRoutes } from '../pages/routes.ts'
|
|
60
62
|
import { urlsRoutes } from '../urls/routes.ts'
|
|
61
|
-
import {
|
|
63
|
+
import type { UrlWriteDeps } from '../urls/write-routes.ts'
|
|
64
|
+
import { secretsReadsHere, secretsRoutes, type SecretsReads } from './secrets-read.ts'
|
|
65
|
+
import { type Live, LIVE_PATH, liveSockets } from './page-live.ts'
|
|
66
|
+
import { noPage, pagePart, type TerminalDeps, terminalRoutesOf } from './terminal-route.ts'
|
|
62
67
|
import { liveHopTarget, toLive } from './live-hop.ts'
|
|
63
68
|
|
|
64
69
|
export { sameOrigin }
|
|
@@ -78,9 +83,15 @@ export type ComfyDeps = {
|
|
|
78
83
|
/** a path as the disk resolves it, so `/tmp` and `/private/tmp` are one tree */
|
|
79
84
|
const sameTree = (p: string): string => { try { return realpathSync(p) } catch { return p } }
|
|
80
85
|
|
|
86
|
+
/** the parts of a hub's terminal routes a caller can replace: where tmux is, its server's socket and config, and how
|
|
87
|
+
* each of its commands runs */
|
|
88
|
+
export type HubTerminal = Pick<TerminalDeps, 'tmux' | 'socket' | 'conf' | 'ask' | 'run' | 'spawn'>
|
|
89
|
+
|
|
81
90
|
export type HubDeps = {
|
|
82
91
|
root: string
|
|
83
92
|
name: string
|
|
93
|
+
/** what the hub's terminals run with, in place of this Mac's own tmux: a test's hub (tests/test-hub.ts) */
|
|
94
|
+
terminal?: HubTerminal
|
|
84
95
|
/** the machine resources the repo declares in serve.uses */
|
|
85
96
|
uses?: string[]
|
|
86
97
|
/** a terminal's `shipkit ci` or `check`, run in this process; resolves to its exit code */
|
|
@@ -135,8 +146,13 @@ export type HubDeps = {
|
|
|
135
146
|
/** where a value pasted under a credential ask goes; absent = the repo's
|
|
136
147
|
* house store, as `sk secret set` makes it */
|
|
137
148
|
storeSecret?: SecretStore
|
|
149
|
+
/** what the hub's writes on the urls reach (urls/write-routes.ts): the vault's soft delete, the identity, the
|
|
150
|
+
* Chrome popup; absent = this machine's, a test passes fakes */
|
|
151
|
+
urlWrites?: UrlWriteDeps
|
|
138
152
|
/** the store's read of a credential ask's names (collections/providers.ts heldOfAsks), a test passes its own */
|
|
139
153
|
secretHeld?: HeldOf
|
|
154
|
+
/** the secrets page's reads (secrets-read.ts); absent = this machine's registry and store, a test passes its own */
|
|
155
|
+
secrets?: SecretsReads
|
|
140
156
|
/** who calls over the tailnet (http/tailnet-caller.ts); absent = this Mac's tailscale, a test passes its own */
|
|
141
157
|
tailnet?: TailnetWho
|
|
142
158
|
/** what « publish » posts with (social/publish/index.ts); absent = the live venues, a test passes fakes */
|
|
@@ -176,6 +192,8 @@ export type HubHandler = {
|
|
|
176
192
|
needs: () => Promise<Resource[]>
|
|
177
193
|
/** what the push stream follows of this repo (review/push.ts): its runs, rows, media and parties */
|
|
178
194
|
sources: () => PushSource[]
|
|
195
|
+
/** the store notices of this hub, for a page's socket (page-live.ts) */
|
|
196
|
+
push: Pick<ThreadPush, 'attach'>
|
|
179
197
|
stop: () => void
|
|
180
198
|
}
|
|
181
199
|
|
|
@@ -205,6 +223,10 @@ const homeLink = (base: string): string => `<style>.skhome{position:fixed;left:1
|
|
|
205
223
|
background:#141619;border:1px solid #282c31;border-radius:3px;padding:5px 9px}</style><a class=skhome href="${base}/" title="hub — THE page">⌂</a>`
|
|
206
224
|
const withHome = (html: string, base: string): string => html.replace(/<body([^>]*)>/, `<body$1>${homeLink(base)}`)
|
|
207
225
|
|
|
226
|
+
// a held parties answer (review/routes.ts) stands while the stamp its stream follows holds, the sessions' records read
|
|
227
|
+
// unmemoized: a record written a moment ago counts
|
|
228
|
+
partiesStampWith((store) => `${dirStamp(sessionsDir())}|${partiesStamp(store)}`)
|
|
229
|
+
|
|
208
230
|
/** the hub's routes under `base` ('' on a server of its own, '/r/<repo>' in
|
|
209
231
|
* the home). `projects` is the rail, shared when one process serves many */
|
|
210
232
|
export function hubHandler(d: HubDeps, o: { base?: string; projects?: Gutter } = {}): HubHandler {
|
|
@@ -228,7 +250,10 @@ export function hubHandler(d: HubDeps, o: { base?: string; projects?: Gutter } =
|
|
|
228
250
|
const timeline = d.timeline == null ? null : new WarmCell(d.timeline, { stamp: d.stamp, queue: warmQueue, what: `warm timeline: ${d.name}` })
|
|
229
251
|
const graphs = new Map(d.graphs.map((g) => [g.id, new WarmCell(async () => g.load(), { maxAgeMs: WARM_MAX_AGE_MS, queue: warmQueue, what: `warm graph ${g.id}: ${d.name}` })]))
|
|
230
252
|
const fresh = (req: Request): boolean => new URL(req.url).searchParams.get('fresh') === '1'
|
|
231
|
-
const terminal =
|
|
253
|
+
const terminal = terminalRoutesOf({ root: d.root, name: d.name, ...d.terminal })
|
|
254
|
+
// the secrets page's reads on this machine: the checks' last runs come from the rows already warm
|
|
255
|
+
let secretsHere: SecretsReads | null = null
|
|
256
|
+
const ownSecrets = (): SecretsReads => (secretsHere ??= secretsReadsHere(d.root, async () => (await rows.get({ held: true })).resources.flatMap((r) => (r.check == null ? [] : [r.check]))))
|
|
232
257
|
// this repo's stream of the thread store's changes: a hub alone and the embed page read it here, the home page reads
|
|
233
258
|
// the daemon's own of every repo (review/push.ts)
|
|
234
259
|
/** a save the watch saw, and each write of the media API: what no file stamp says */
|
|
@@ -263,6 +288,7 @@ export function hubHandler(d: HubDeps, o: { base?: string; projects?: Gutter } =
|
|
|
263
288
|
for (const g of graphs.values()) await g.warm()
|
|
264
289
|
},
|
|
265
290
|
needs: async () => (await rows.get({ held: true })).resources.filter((r) => r.severity != null),
|
|
291
|
+
push,
|
|
266
292
|
stop: () => {
|
|
267
293
|
d.comfy?.stop()
|
|
268
294
|
terminal.stop()
|
|
@@ -280,6 +306,8 @@ export function hubHandler(d: HubDeps, o: { base?: string; projects?: Gutter } =
|
|
|
280
306
|
if (path === '/hub.json') return Response.json({ hub: 'shipkit', name: d.name, root: d.root, base, tools, uses: d.uses ?? [], cli: noCli(d.root) == null })
|
|
281
307
|
if (path === '/api/threads/live') return push.handle(req)
|
|
282
308
|
if (path === '/api/threads/live/why') return Response.json(push.recent)
|
|
309
|
+
// the live channel of one of the repo's own pages, read here for the hub page that frames it
|
|
310
|
+
if (path === '/api/terminal/frame' && req.method === 'POST') return (await import('./frame-part.ts')).framePart(d.root, req, srv.requestIP(req)?.address ?? null)
|
|
283
311
|
const term = await terminal.handle(req, path, srv)
|
|
284
312
|
if (term != null) return term
|
|
285
313
|
if (path.startsWith('/api/projects')) return (await projects.handle(req, path)) ?? new Response('not found', { status: 404 })
|
|
@@ -424,8 +452,13 @@ export function hubHandler(d: HubDeps, o: { base?: string; projects?: Gutter } =
|
|
|
424
452
|
const pages = await pagesRoutes(d.root, req, path, srv)
|
|
425
453
|
if (pages != null) return pages
|
|
426
454
|
// every url of the repo, and the one field of a login a click copies (urls/routes.ts)
|
|
427
|
-
const urls = await urlsRoutes(d.root, req, path)
|
|
455
|
+
const urls = await urlsRoutes(d.root, req, path, {}, { ...(d.storeSecret ? { store: d.storeSecret } : {}), ...(d.tailnet ? { who: d.tailnet } : {}), ...d.urlWrites })
|
|
428
456
|
if (urls != null) return urls
|
|
457
|
+
// the secrets page: every name with who reads it, and one name's tail at a click (secrets-read.ts)
|
|
458
|
+
if (path.startsWith('/api/secrets')) {
|
|
459
|
+
const secrets = await secretsRoutes(req, path, d.secrets ?? ownSecrets(), d.tailnet ? { who: d.tailnet } : {})
|
|
460
|
+
if (secrets != null) return secrets
|
|
461
|
+
}
|
|
429
462
|
// the review or trailer page alone, for another tool's frame (embed.ts)
|
|
430
463
|
const embed = await embedRoute(path)
|
|
431
464
|
if (embed != null) return embed
|
|
@@ -487,23 +520,33 @@ export function hubHandler(d: HubDeps, o: { base?: string; projects?: Gutter } =
|
|
|
487
520
|
}
|
|
488
521
|
}
|
|
489
522
|
if (path === '/api/check/run' && req.method === 'POST') {
|
|
490
|
-
const body = (await req.json().catch(() => ({}))) as { only?: string[]; gate?: boolean }
|
|
491
|
-
//
|
|
492
|
-
//
|
|
493
|
-
|
|
523
|
+
const body = (await req.json().catch(() => ({}))) as { only?: string[]; gate?: boolean; page?: unknown; key?: unknown }
|
|
524
|
+
// one event at a time, so the page colours a row the moment its check finishes instead of waiting for
|
|
525
|
+
// the wall of text a shelled run could only deliver whole
|
|
526
|
+
const run = async (send: (e: Record<string, unknown>) => void): Promise<void> => {
|
|
527
|
+
let code = 1
|
|
528
|
+
try {
|
|
529
|
+
code = await d.runChecks({ line: (text) => send({ t: 'line', text }), check: (u) => send({ t: 'check', ...u }) }, { only: body.only, gate: body.gate })
|
|
530
|
+
} catch (e) {
|
|
531
|
+
send({ t: 'line', text: `FAIL: the run broke: ${(e as Error).message}` })
|
|
532
|
+
}
|
|
533
|
+
send({ t: 'done', code })
|
|
534
|
+
}
|
|
535
|
+
// asked by a page that names its socket: each event is a line of that part, and the page holds no
|
|
536
|
+
// request open for the run. A socket this process does not hold starts no run
|
|
537
|
+
if (body.page != null) {
|
|
538
|
+
const part = pagePart(body)
|
|
539
|
+
if (part == null) return noPage()
|
|
540
|
+
void run((e) => part.put({ t: 'r', e })).then(part.end)
|
|
541
|
+
return new Response(null, { status: 204, headers: { 'cache-control': 'no-store' } })
|
|
542
|
+
}
|
|
543
|
+
// else NDJSON, one line per event, for as long as the run: a program, a page with no such socket
|
|
494
544
|
const enc = new TextEncoder()
|
|
495
545
|
const stream = new ReadableStream({
|
|
496
546
|
async start(ctrl) {
|
|
497
|
-
|
|
547
|
+
await run((e) => {
|
|
498
548
|
try { ctrl.enqueue(enc.encode(`${JSON.stringify(e)}\n`)) } catch { /* the tab went away mid-run */ }
|
|
499
|
-
}
|
|
500
|
-
let code = 1
|
|
501
|
-
try {
|
|
502
|
-
code = await d.runChecks({ line: (text) => send({ t: 'line', text }), check: (u) => send({ t: 'check', ...u }) }, { only: body.only, gate: body.gate })
|
|
503
|
-
} catch (e) {
|
|
504
|
-
send({ t: 'line', text: `FAIL: the run broke: ${(e as Error).message}` })
|
|
505
|
-
}
|
|
506
|
-
send({ t: 'done', code })
|
|
549
|
+
})
|
|
507
550
|
ctrl.close()
|
|
508
551
|
},
|
|
509
552
|
})
|
|
@@ -546,7 +589,9 @@ const heldProblem = (): { id: string; text: string; severity: 'yellow' }[] => {
|
|
|
546
589
|
return h == null ? [] : [{ id: 'last-good', text: heldText(h), severity: 'yellow' }]
|
|
547
590
|
}
|
|
548
591
|
|
|
549
|
-
|
|
592
|
+
/** `test`: a test started this hub (tests/test-hub.ts), and its clients stand in for a page of the hub with that
|
|
593
|
+
* test's token (http/owner-word.ts TestPage). A hub of the product is started with none (run-serve.ts) */
|
|
594
|
+
export function serveHub(d: HubDeps, h: HubHandler = hubHandler(d), test?: TestPage): Hub {
|
|
550
595
|
// built on the first load, then rebuilt on a save of its files: a hub whose page nobody opens builds nothing
|
|
551
596
|
let page: PageBuild | null = null
|
|
552
597
|
let ready: Promise<PageBuild> | null = null
|
|
@@ -555,23 +600,27 @@ export function serveHub(d: HubDeps, h: HubHandler = hubHandler(d)): Hub {
|
|
|
555
600
|
const b = (page = new PageBuild({ entry: HUB_PAGE, head: HELD_BUILD_SCRIPT, watch: d.pageWatch !== false }))
|
|
556
601
|
return (ready = b.start().then(() => b))
|
|
557
602
|
}
|
|
558
|
-
|
|
603
|
+
// a page's one socket: the lines of its terminals, the store's notices and this page's builds (page-live.ts)
|
|
604
|
+
const live = liveSockets({ push: () => h.push, page: () => page })
|
|
605
|
+
const server: Server = loopbackServe<Live>({
|
|
559
606
|
port: d.port,
|
|
607
|
+
websocket: live.websocket,
|
|
560
608
|
fetch: async (req, srv) => {
|
|
561
609
|
// a live view's page under its own name (live-hop.ts), never a route of the hub
|
|
562
610
|
if (liveHopTarget(req.headers.get('host')) != null) return (await toLive(req, { ports: [Number(srv.port), homePort(), daemonPort(), pmPort()], srv })) ?? new Response('the live hop answered nothing', { status: 500 })
|
|
563
611
|
const url = new URL(req.url)
|
|
564
612
|
const path = url.pathname
|
|
613
|
+
if (path === LIVE_PATH) return live.upgrade(req, srv)
|
|
565
614
|
// `/` IS the page, the react app, and `/live` its live page alone in a tab; there is no other surface
|
|
566
615
|
if (path === '/' || path === '/live') return (await built()).servePage()
|
|
567
616
|
if (path.startsWith(PAGE_PATH)) return (await built()).serveFile(path, req) ?? new Response('not found', { status: 404 })
|
|
568
617
|
if (path === HELD_SOURCE_PATH) return heldSource(url, { cwd: realpathSync(process.cwd()), files: () => page?.inputs() ?? [] })
|
|
569
618
|
const r = await h.handle(req, path, srv)
|
|
570
|
-
//
|
|
619
|
+
// a page loaded before the socket reads its build on the event stream: said there too, so it reloads itself
|
|
571
620
|
if (path === '/api/threads/live' && page != null && r.ok && r.body != null) return new Response(withPageNotices(r.body, page), { status: r.status, headers: r.headers })
|
|
572
621
|
return r
|
|
573
622
|
},
|
|
574
|
-
}, d.tailnet ? { who: d.tailnet } : {})
|
|
623
|
+
}, { otherApp: (req) => liveHopTarget(req.headers.get('host')) != null, ...(d.tailnet ? { who: d.tailnet } : {}), ...(test == null ? {} : { testPage: test }) })
|
|
575
624
|
// the panel process belongs to this hub: leaving it behind means the next
|
|
576
625
|
// launch adopts a server holding the previous run's modules
|
|
577
626
|
return { server, tools: h.tools, stop: () => { page?.stop(); h.stop(); server.stop(true) } }
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// the Claude Code sessions at work in a repo's folder, for the terminal page's list (wiki tools/shipkit/hub.md, The
|
|
2
|
+
// terminal panel): found with no setup, wherever each runs. Claude Code itself writes one small file a process,
|
|
3
|
+
// `<config folder>/sessions/<pid>.json` (its pid, its session, its folder, busy or idle, its name): that file is the
|
|
4
|
+
// source, so no environment of a process is ever read. Where it runs comes from the process table (its tty) and
|
|
5
|
+
// tmux's panes: in a window of the repo's session (then it IS that terminal), in another tmux session, or outside
|
|
6
|
+
// tmux. What it does now is read by `sk lanes`' own reader (agent-time/live.ts), never a second one.
|
|
7
|
+
// The one constraint a reader breaks first: an account leaves the hub as its name (cc3), never as its folder's path
|
|
8
|
+
import { statSync } from 'fs'
|
|
9
|
+
import { homedir } from 'os'
|
|
10
|
+
import { basename, dirname, isAbsolute, join } from 'path'
|
|
11
|
+
import { type ClaudeRecord, sessionRecords } from '../agent-time/claude-sessions.ts'
|
|
12
|
+
import { liveRow } from '../agent-time/live.ts'
|
|
13
|
+
import { discoverConfigRoots, projectSlug } from '../reflect/prompt-corpus.ts'
|
|
14
|
+
import { pidAlive } from '../review/watchers.ts'
|
|
15
|
+
import type { Tmux } from './terminal-host.ts'
|
|
16
|
+
|
|
17
|
+
/** where a session runs: a terminal of this page, a window of another tmux session, or no tmux at all */
|
|
18
|
+
export type ClaudeWhere =
|
|
19
|
+
| { in: 'here'; /** the window's tmux id */ window: string }
|
|
20
|
+
| { in: 'tmux'; session: string; /** the window's name */ window: string }
|
|
21
|
+
| { in: 'outside'; /** the app its terminal belongs to (Visual Studio Code), '' when none is found */ app: string; /** its tty, '' when it has none */ tty: string }
|
|
22
|
+
|
|
23
|
+
/** one Claude Code session at work in the repo's folder */
|
|
24
|
+
export type TermClaude = {
|
|
25
|
+
pid: number
|
|
26
|
+
/** the first 8 signs of its session id, as `sk lanes` says it */
|
|
27
|
+
session: string
|
|
28
|
+
/** its account by the name the main panel shows (cc3), else its config folder's name with no dot and no path */
|
|
29
|
+
account: string
|
|
30
|
+
/** the name the session carries, '' for none */
|
|
31
|
+
name: string
|
|
32
|
+
startedAt: number
|
|
33
|
+
/** Claude Code's own word: busy, idle, shell */
|
|
34
|
+
state: string
|
|
35
|
+
/** what it does now in the words of `sk lanes` (`Bash: bun test`, `model turn`), '' when its transcript says nothing */
|
|
36
|
+
doing: string
|
|
37
|
+
/** its folder under the repo's, '' for the repo's own */
|
|
38
|
+
dir: string
|
|
39
|
+
where: ClaudeWhere
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type { ClaudeRecord }
|
|
43
|
+
export type Proc = { ppid: number; tty: string; comm: string }
|
|
44
|
+
export type Pane = { tty: string; session: string; window: string; name: string }
|
|
45
|
+
|
|
46
|
+
export type ClaudeSources = {
|
|
47
|
+
/** each Claude Code config folder of this Mac */
|
|
48
|
+
roots(): { account: string; dir: string }[]
|
|
49
|
+
/** the accounts by the names the main panel shows, each with the config folder its status line reported */
|
|
50
|
+
accounts(): { name: string; dir: string | null }[]
|
|
51
|
+
records(dir: string): ClaudeRecord[]
|
|
52
|
+
alive(pid: number): boolean
|
|
53
|
+
/** the process table: one `ps` */
|
|
54
|
+
procs(): Map<number, Proc>
|
|
55
|
+
/** every pane of the tmux server: one `list-panes` */
|
|
56
|
+
panes(): Pane[]
|
|
57
|
+
/** what a session does now, null when its transcript is not found */
|
|
58
|
+
live(dir: string, cwd: string, session: string): { doing: string } | null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const isClaude = (comm: string): boolean => /(^|\/)claude$/.test(comm)
|
|
62
|
+
const under = (folder: string, cwd: string): string | null => (cwd === folder ? '' : cwd.startsWith(`${folder}/`) ? cwd.slice(folder.length + 1) : null)
|
|
63
|
+
|
|
64
|
+
/** the account of a config folder: the main panel's name where a status line reported that folder (by its name or its
|
|
65
|
+
* path), else the folder's own name */
|
|
66
|
+
function accountOf(root: { account: string; dir: string }, accounts: { name: string; dir: string | null }[]): string {
|
|
67
|
+
const named = accounts.find((a) => a.dir != null && (a.dir === root.dir || basename(a.dir) === basename(root.dir)))
|
|
68
|
+
return named?.name ?? (root.account === '.claude' ? 'default' : root.account.replace(/^\.claude-/, '').replace(/^\./, ''))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** the app a process's terminal belongs to: the first ancestor that runs from an `.app` */
|
|
72
|
+
function appOf(pid: number, procs: Map<number, Proc>): string {
|
|
73
|
+
for (let p = procs.get(pid), n = 0; p != null && n < 16; p = procs.get(p.ppid), n++) {
|
|
74
|
+
const m = /\/([^/]+)\.app\//.exec(p.comm)
|
|
75
|
+
if (m != null) return m[1]!
|
|
76
|
+
}
|
|
77
|
+
return ''
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** the live sessions whose folder is one of `folders` or inside one, as their files say: no process table yet */
|
|
81
|
+
function found(folders: readonly string[], src: ClaudeSources): { root: { account: string; dir: string }; r: ClaudeRecord; dir: string }[] {
|
|
82
|
+
return src.roots().flatMap((root) => src.records(root.dir).flatMap((r) => {
|
|
83
|
+
const dir = folders.map((f) => under(f, r.cwd)).find((d) => d != null)
|
|
84
|
+
return dir == null || !src.alive(r.pid) ? [] : [{ root, r, dir }]
|
|
85
|
+
}))
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** the Claude Code sessions at work in `folders` (the repo's folder, and its real path where it differs), oldest
|
|
89
|
+
* first; `session` is the repo's tmux session. `tables`: a process table and panes read before, in place of new ones */
|
|
90
|
+
export function claudesOf(folders: string | readonly string[], session: string, src: ClaudeSources, tables?: { procs: Map<number, Proc>; panes: Pane[] }): TermClaude[] {
|
|
91
|
+
const live = found(typeof folders === 'string' ? [folders] : folders, src)
|
|
92
|
+
if (live.length === 0) return []
|
|
93
|
+
const procs = tables?.procs ?? src.procs()
|
|
94
|
+
const panes = tables?.panes ?? src.panes()
|
|
95
|
+
const accounts = src.accounts()
|
|
96
|
+
return live.flatMap(({ root, r, dir }): TermClaude[] => {
|
|
97
|
+
const p = procs.get(r.pid)
|
|
98
|
+
// the pid of a session that ended can be another program's by now
|
|
99
|
+
if (p == null || !isClaude(p.comm)) return []
|
|
100
|
+
const tty = p.tty === '??' || p.tty === '' ? '' : p.tty
|
|
101
|
+
const pane = tty === '' ? undefined : panes.find((x) => x.tty === `/dev/${tty}`)
|
|
102
|
+
const where: ClaudeWhere = pane == null ? { in: 'outside', app: appOf(r.pid, procs), tty } : pane.session === session ? { in: 'here', window: pane.window } : { in: 'tmux', session: pane.session, window: pane.name }
|
|
103
|
+
return [{ pid: r.pid, session: r.sessionId.slice(0, 8), account: accountOf(root, accounts), name: r.name, startedAt: r.startedAt, state: r.status, doing: src.live(root.dir, r.cwd, r.sessionId)?.doing ?? '', dir, where }]
|
|
104
|
+
}).sort((a, b) => a.startedAt - b.startedAt || a.pid - b.pid)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** the same list for a page that asks every few seconds: the session files are read each time (a few small files),
|
|
108
|
+
* the process table and tmux's panes only when the set of sessions or the terminals changed. `windows`: any value
|
|
109
|
+
* that changes with the repo's terminals */
|
|
110
|
+
export function claudeWatch(src: ClaudeSources): { read(folders: string | readonly string[], session: string, windows: string): TermClaude[] } {
|
|
111
|
+
let key = ''
|
|
112
|
+
let tables: { procs: Map<number, Proc>; panes: Pane[] } | null = null
|
|
113
|
+
return {
|
|
114
|
+
read(folders, session, windows) {
|
|
115
|
+
const pids = found(typeof folders === 'string' ? [folders] : folders, src).map((f) => f.r.pid).sort((a, b) => a - b)
|
|
116
|
+
if (pids.length === 0) return []
|
|
117
|
+
const now = `${pids.join(',')}|${windows}`
|
|
118
|
+
if (tables == null || now !== key) tables = { procs: src.procs(), panes: src.panes() }
|
|
119
|
+
key = now
|
|
120
|
+
return claudesOf(folders, session, src, tables)
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** the rows of `ps -axo pid=,ppid=,tty=,comm=` */
|
|
126
|
+
export function parseProcs(out: string): Map<number, Proc> {
|
|
127
|
+
const by = new Map<number, Proc>()
|
|
128
|
+
for (const l of out.split('\n')) {
|
|
129
|
+
const m = /^\s*(\d+)\s+(\d+)\s+(\S+)\s+(.*)$/.exec(l)
|
|
130
|
+
if (m != null) by.set(Number(m[1]), { ppid: Number(m[2]), tty: m[3]!, comm: m[4]!.trim() })
|
|
131
|
+
}
|
|
132
|
+
return by
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const SEP = '\x1f'
|
|
136
|
+
/** the rows of `list-panes -a` with the four fields below, a pane once a session it is linked in */
|
|
137
|
+
/** a pane's session is its group where it has one: a page's view of a repo's session reads as that session */
|
|
138
|
+
export const PANE_FIELDS = ['#{pane_tty}', '#{?session_grouped,#{session_group},#{session_name}}', '#{window_id}', '#{window_name}'].join(`#{l:${SEP}}`)
|
|
139
|
+
export function parsePanes(out: string): Pane[] {
|
|
140
|
+
return out.split('\n').flatMap((l) => {
|
|
141
|
+
const [tty, session, window, name] = l.split(SEP)
|
|
142
|
+
return tty == null || session == null || window == null ? [] : [{ tty, session, window, name: name ?? '' }]
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** this Mac's own: the config folders `sk lanes` reads, the session files in each, `ps`, tmux's panes, and what a
|
|
147
|
+
* session does now by the reader of `sk lanes`, read again only when its transcript moved */
|
|
148
|
+
export function diskClaudes(o: { accounts: () => { name: string; dir: string | null }[]; tmux: Tmux | null; home?: string }): ClaudeSources {
|
|
149
|
+
const home = o.home ?? homedir()
|
|
150
|
+
const doing = new Map<string, { stamp: string; doing: string }>()
|
|
151
|
+
return {
|
|
152
|
+
roots: () => discoverConfigRoots(home).map((r) => ({ account: r.account, dir: dirname(r.projects) })),
|
|
153
|
+
// a folder a status line named by its name alone is under his home
|
|
154
|
+
accounts: () => o.accounts().map((a) => ({ name: a.name, dir: a.dir == null ? null : isAbsolute(a.dir) ? a.dir : join(home, a.dir) })),
|
|
155
|
+
records: sessionRecords,
|
|
156
|
+
alive: pidAlive,
|
|
157
|
+
procs() {
|
|
158
|
+
try {
|
|
159
|
+
return parseProcs(Bun.spawnSync(['/bin/ps', '-axo', 'pid=,ppid=,tty=,comm='], { stdout: 'pipe', stderr: 'ignore' }).stdout.toString())
|
|
160
|
+
} catch {
|
|
161
|
+
return new Map()
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
panes() {
|
|
165
|
+
const r = o.tmux?.(['list-panes', '-a', '-F', PANE_FIELDS])
|
|
166
|
+
return r?.ok === true ? parsePanes(r.out) : []
|
|
167
|
+
},
|
|
168
|
+
live(dir, cwd, session) {
|
|
169
|
+
const project = projectSlug(cwd)
|
|
170
|
+
const path = join(dir, 'projects', project, `${session}.jsonl`)
|
|
171
|
+
try {
|
|
172
|
+
const st = statSync(path)
|
|
173
|
+
const stamp = `${st.size}:${st.mtimeMs}`
|
|
174
|
+
const held = doing.get(path)
|
|
175
|
+
if (held?.stamp === stamp) return { doing: held.doing }
|
|
176
|
+
const s = liveRow({ path, account: basename(dir), project, session, agent: '', size: st.size, mtime: Math.floor(st.mtimeMs) }, { calls: false }).state
|
|
177
|
+
const words = s.kind === 'tool' ? s.what : s.kind === 'model' ? 'model turn' : s.kind === 'ended' ? 'waits for its user' : ''
|
|
178
|
+
doing.set(path, { stamp, doing: words })
|
|
179
|
+
return { doing: words }
|
|
180
|
+
} catch {
|
|
181
|
+
return null
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// the one gate before the hub's terminal (wiki tools/shipkit/hub.md, The terminal panel): a shell in a web page answers
|
|
2
2
|
// this Mac's own browser on the hub's own page, and nothing else. The web runs it with the peer it sees and the
|
|
3
|
-
// browser's own headers; the daemon or a hub of its own runs it again behind the web.
|
|
3
|
+
// browser's own headers; the daemon or a hub of its own runs it again behind the web. It says WHERE a terminal
|
|
4
|
+
// answers (this Mac, by its own name, never through a proxy). WHO asks, a page of the hub and never a program, is
|
|
5
|
+
// the gate on the owner's acts, which every server runs before this one (http/owner-word.ts, the `/api/terminal`
|
|
6
|
+
// family and the page's socket).
|
|
4
7
|
// The one constraint a reader breaks first: the tailnet reaches the web through `tailscale serve`, whose peer is
|
|
5
8
|
// loopback too, so a loopback peer alone proves nothing: its forwarded headers refuse it
|
|
6
9
|
import { broughtByProxy } from '../http/door-forward.ts'
|
|
@@ -16,12 +19,13 @@ const OWN_NAMES = new Set(['localhost', '127.0.0.1', '::1'])
|
|
|
16
19
|
export const loopbackPeer = (ip: string): boolean => ip === '::1' || /^(?:::ffff:)?127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/i.test(ip)
|
|
17
20
|
|
|
18
21
|
/** why a request may not reach the terminal, null when it may. `peer`: the address the connection came from; `what`:
|
|
19
|
-
* the words its refusals name the door by
|
|
20
|
-
|
|
22
|
+
* the words its refusals name the door by; `socket`: the request is the upgrade of a page's socket (a GET), on
|
|
23
|
+
* which that page then types */
|
|
24
|
+
export function terminalRefusal(req: Request, peer: string | null, what = 'the terminal', o: { socket?: boolean } = {}): string | null {
|
|
21
25
|
const localOnly = `${what} answers on the Mac that runs the hub only`
|
|
22
26
|
if (peer == null || !loopbackPeer(peer)) return `${localOnly}: this request came from ${peer ?? 'an unknown address'}`
|
|
23
27
|
if (broughtByProxy(req) || req.headers.get(REACH_HEADER) === 'tailnet') return `${localOnly}: this request came through a proxy (the tailnet)`
|
|
24
|
-
if (req.method !== 'POST') return `${what} takes a POST only`
|
|
28
|
+
if (req.method !== (o.socket === true ? 'GET' : 'POST')) return `${what} takes a ${o.socket === true ? 'socket' : 'POST'} only`
|
|
25
29
|
const host = req.headers.get('host') ?? ''
|
|
26
30
|
// behind the web, the Host the browser sent rides in the web's tag
|
|
27
31
|
const shown = req.headers.get(HOST_HEADER) ?? host
|
|
@@ -29,7 +33,8 @@ export function terminalRefusal(req: Request, peer: string | null, what = 'the t
|
|
|
29
33
|
const site = req.headers.get('sec-fetch-site')
|
|
30
34
|
if (site != null && site !== 'same-origin') return `refused: a request of another site (${site})`
|
|
31
35
|
const origin = req.headers.get('origin')
|
|
32
|
-
// no origin and no fetch metadata:
|
|
36
|
+
// no origin and no fetch metadata: the web brought it (it strips both as it forwards, and the gate on the owner's
|
|
37
|
+
// acts read its tags before this), or a caller in this process (a test of the routes alone)
|
|
33
38
|
if (origin == null) return site == null ? null : 'refused: a browser request with no origin'
|
|
34
39
|
try {
|
|
35
40
|
if (new URL(origin).host === shown.toLowerCase()) return null
|