rvlib-shipkit 2.31.0 → 2.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/package.json +1 -1
- package/src/advisors/acts.ts +16 -15
- package/src/advisors/advice.ts +56 -102
- package/src/advisors/advisor-view.ts +98 -73
- package/src/advisors/app-graph.ts +1 -1
- package/src/advisors/app.ts +3 -11
- package/src/advisors/cf-api.ts +1 -1
- package/src/advisors/dir-bucket.ts +4 -3
- package/src/advisors/edge/api.ts +26 -198
- package/src/advisors/edge/bucket.ts +2 -2
- package/src/advisors/edge/handler.ts +13 -155
- package/src/advisors/edge/here.ts +5 -5
- package/src/advisors/edge/pages.ts +12 -9
- package/src/advisors/edge/shell.ts +6 -5
- package/src/advisors/edge/sign-in.ts +101 -36
- package/src/advisors/edge/status.ts +19 -6
- package/src/advisors/edge/types.ts +36 -60
- package/src/advisors/expose.ts +29 -29
- package/src/advisors/here.ts +12 -12
- package/src/advisors/invite-send.ts +79 -35
- package/src/advisors/invite.ts +31 -8
- package/src/advisors/job.ts +24 -16
- package/src/advisors/login.ts +40 -15
- package/src/advisors/owner-store.ts +46 -22
- package/src/advisors/photos.ts +3 -3
- package/src/advisors/project.ts +25 -23
- package/src/advisors/reach.ts +89 -0
- package/src/advisors/rights.ts +1 -1
- package/src/advisors/routes.ts +55 -74
- package/src/advisors/scan.ts +0 -4
- package/src/advisors/setup-run.ts +14 -14
- package/src/advisors/share-trace.ts +3 -3
- package/src/advisors/{door-probe.ts → sign-in-probe.ts} +7 -6
- package/src/advisors/speaks.ts +29 -0
- package/src/advisors/sync.ts +92 -182
- package/src/advisors/tunnel.ts +6 -5
- package/src/advisors/users-listen.ts +92 -0
- package/src/advisors/users-router.ts +257 -85
- package/src/advisors/users-store.ts +81 -0
- package/src/agent-time/blocked-scan.ts +181 -0
- package/src/agent-time/registry.ts +12 -5
- package/src/agent-time/store.ts +9 -109
- package/src/asks/ask-bar-fold.ts +2 -1
- package/src/asks/ask-close.ts +2 -1
- package/src/asks/ask-doc.ts +2 -1
- package/src/asks/ask-migrate.ts +3 -2
- package/src/asks/ask-steps-fold.ts +2 -1
- package/src/asks/ask-store.ts +4 -3
- package/src/check.ts +3 -43
- package/src/checks/SK001-package-json-shape.check.ts +4 -55
- package/src/checks/SK004-gitignore-policy.check.ts +24 -69
- package/src/checks/SK013-one-way-in-policy.check.ts +3 -7
- package/src/checks/SK017-vscode-hub-task.check.ts +4 -4
- package/src/checks/SK019-tests-run-in-units.check.ts +3 -14
- package/src/checks/SK020-self-spawning-check.check.ts +5 -7
- package/src/checks/SK035-public-clean.check.ts +1 -1
- package/src/checks/SK039-vscode-watch-generated.check.ts +1 -1
- package/src/checks/SK042-post-kinds.check.ts +5 -14
- package/src/checks/SK054-agent-allow-list.check.ts +5 -74
- package/src/checks/SK055-retired-config-keys.check.ts +45 -0
- package/src/cli/cmd_Advisors.ts +11 -45
- package/src/cli/cmd_Asks.ts +3 -10
- package/src/cli/cmd_Backup.ts +25 -127
- package/src/cli/cmd_BackupTargets.ts +1 -1
- package/src/cli/cmd_Checks.ts +0 -14
- package/src/cli/cmd_Db.ts +3 -82
- package/src/cli/cmd_Home.ts +4 -32
- package/src/cli/cmd_Hq.ts +0 -17
- package/src/cli/cmd_Releases.ts +57 -4
- package/src/cli/cmd_Review.ts +333 -354
- package/src/cli/cmd_SocialDrafts.ts +6 -13
- package/src/cli/cmd_ThreadSyncNeeds.ts +6 -2
- package/src/cli/cmd_Time.ts +1 -1
- package/src/cli/cmd_Trailer.ts +1 -1
- package/src/cli/inbox-hook-run.ts +5 -23
- package/src/cli/registry-heads.ts +5 -55
- package/src/cli/registry.ts +1 -5
- package/src/cli/review-here.ts +1 -1
- package/src/cli.ts +2 -2
- package/src/collections/collection-types.ts +1 -1
- package/src/collections/review.ts +5 -4
- package/src/core/agent-allow-policy.ts +32 -2
- package/src/core/agent-env.ts +8 -0
- package/src/core/allow-rows.ts +74 -0
- package/src/core/check-file-names.ts +19 -106
- package/src/core/footprint.ts +17 -13
- package/src/core/identities-root.ts +1 -4
- package/src/core/layout.ts +1 -2
- package/src/core/machine-db.ts +33 -208
- package/src/core/machine-layout.ts +14 -127
- package/src/core/mask-source.ts +60 -0
- package/src/core/memory-watch.ts +17 -14
- package/src/core/motherhome.ts +8 -35
- package/src/core/one-way-in-policy.ts +0 -3
- package/src/core/repo-walk.ts +0 -9
- package/src/core/retention.ts +1 -9
- package/src/core/retired-checks.ts +2 -0
- package/src/core/tmux-policy.ts +1 -1
- package/src/core/tree-watch.ts +2 -2
- package/src/core/when.ts +7 -45
- package/src/gate/discover-checks.ts +42 -32
- package/src/gate/gate-checks.ts +21 -131
- package/src/gate/pre-commit-discovery.ts +16 -25
- package/src/gate/run-check.ts +0 -4
- package/src/gate/run-fix.ts +5 -17
- package/src/gate/run-fixers.ts +6 -42
- package/src/home/app-sign.ts +2 -2
- package/src/home/backup-status.ts +52 -92
- package/src/home/backup-verdict.ts +2 -2
- package/src/home/daemon-jobs.ts +51 -95
- package/src/home/database-words.ts +1 -2
- package/src/home/databases.ts +9 -25
- package/src/home/home-launchd.ts +0 -6
- package/src/home/home-paths.ts +8 -4
- package/src/home/home-routes.ts +3 -10
- package/src/home/home-state.ts +2 -14
- package/src/home/inbox-shape.ts +14 -15
- package/src/home/inbox.ts +1 -1
- package/src/home/machine-repair.ts +102 -103
- package/src/home/resume.ts +1 -15
- package/src/home/run-daemon.ts +4 -11
- package/src/home/space-page.ts +3 -2
- package/src/home/supervise.ts +3 -7
- package/src/hooks/hook-config.ts +6 -7
- package/src/hooks/leak-guard.ts +1 -1
- package/src/hooks/run-hooks.ts +0 -5
- package/src/hq/daemon-db.ts +8 -8
- package/src/hq/door.ts +3 -16
- package/src/hq/hq-db.ts +4 -3
- package/src/hq/hq-local.ts +1 -2
- package/src/hq/hq-store.ts +0 -15
- package/src/hq/item-direct.ts +8 -10
- package/src/hq/item-fill.ts +37 -0
- package/src/hq/kinds/item-gone.ts +7 -10
- package/src/hq/kinds/item-msg.ts +12 -18
- package/src/hq/kinds/item.ts +13 -19
- package/src/hq/kinds/report.ts +3 -4
- package/src/hq/owner-switch.ts +3 -3
- package/src/hq/report.ts +5 -9
- package/src/hq/switch.ts +2 -11
- package/src/hq/thread-sync.ts +5 -17
- package/src/hq/{shapes-words.ts → threads-words.ts} +2 -12
- package/src/http/owner-word.ts +1 -1
- package/src/identities/machine.ts +16 -0
- package/src/init-repo.ts +0 -1
- package/src/ledger/check-stats.ts +6 -5
- package/src/ledger/db.ts +2 -4
- package/src/ledger/record-kept.ts +117 -48
- package/src/ledger/run-log.ts +21 -2
- package/src/ledger/slow-tests.ts +96 -0
- package/src/ledger/store.ts +3 -86
- package/src/ledger/suite-log.ts +8 -2
- package/src/media-store/backup/facts.ts +3 -37
- package/src/media-store/backup/keys.ts +1 -8
- package/src/media-store/backup/manifest.ts +6 -67
- package/src/media-store/backup/restore.ts +4 -13
- package/src/media-store/backup/retention.ts +13 -1
- package/src/media-store/backup/run.ts +6 -267
- package/src/media-store/backup/snapshot.ts +2 -38
- package/src/media-store/backup/sources.ts +3 -113
- package/src/media-store/backup/target-send.ts +5 -29
- package/src/media-store/db.ts +8 -7
- package/src/media-store/forget-one.ts +1 -1
- package/src/media-store/forget.ts +1 -80
- package/src/orchestrator/guards.ts +0 -1
- package/src/orchestrator/presence.ts +2 -2
- package/src/orchestrator/routes.ts +1 -1
- package/src/orchestrator/started.ts +0 -9
- package/src/orchestrator/talk-key.ts +3 -4
- package/src/orchestrator/unheard.ts +1 -1
- package/src/recordings/edit.ts +3 -3
- package/src/recordings/marks-draw.ts +17 -6
- package/src/recordings/marks.ts +120 -9
- package/src/reflections/reflections-queue.ts +3 -10
- package/src/release/notes.ts +1 -1
- package/src/release/public-clean.ts +66 -6
- package/src/release/run-bump.ts +11 -0
- package/src/release/run-release.ts +4 -0
- package/src/releases/from-thread.ts +3 -3
- package/src/releases/model.ts +186 -36
- package/src/releases/store.ts +13 -3
- package/src/releases/validate.ts +83 -0
- package/src/repo-config.ts +29 -64
- package/src/review/answer-kinds.ts +61 -4
- package/src/review/blocked-guard.ts +11 -0
- package/src/review/blocked-object.ts +298 -0
- package/src/review/cells.ts +116 -229
- package/src/review/close.ts +39 -1
- package/src/review/doc-save.ts +3 -2
- package/src/review/draft-item.ts +1 -1
- package/src/review/events.ts +3 -7
- package/src/review/expect.ts +23 -39
- package/src/review/format.ts +79 -46
- package/src/review/glyphs.ts +1 -0
- package/src/review/hand-over.ts +3 -3
- package/src/review/heard.ts +1 -1
- package/src/review/holds-sync.ts +2 -1
- package/src/review/inbox-hook.ts +2 -2
- package/src/review/inbox-read.ts +39 -33
- package/src/review/instruction-guards.ts +12 -0
- package/src/review/instructions.ts +0 -1
- package/src/review/item-db.ts +13 -43
- package/src/review/item-hq.ts +2 -2
- package/src/review/item-rows.ts +3 -14
- package/src/review/kind-catalog.ts +3 -1
- package/src/review/kinds.ts +18 -8
- package/src/review/live-view.ts +3 -0
- package/src/review/media-kind.ts +1 -1
- package/src/review/mentions.ts +1 -2
- package/src/review/model.ts +158 -114
- package/src/review/move.ts +149 -0
- package/src/review/need-threads.ts +3 -2
- package/src/review/object-card.ts +11 -0
- package/src/review/object-read.ts +6 -1
- package/src/review/one-block.ts +1 -1
- package/src/review/owner-read.ts +1 -1
- package/src/review/phone-push.ts +10 -9
- package/src/review/previews.ts +32 -4
- package/src/review/push.ts +2 -2
- package/src/review/recap.ts +129 -0
- package/src/review/referring.ts +6 -3
- package/src/review/reflection-object.ts +4 -3
- package/src/review/routes.ts +49 -19
- package/src/review/secret-route.ts +3 -2
- package/src/review/settle.ts +0 -6
- package/src/review/snooze.ts +5 -3
- package/src/review/speaker.ts +68 -0
- package/src/review/start-title.ts +19 -0
- package/src/review/store.ts +86 -59
- package/src/review/{wakes.ts → thread-events.ts} +92 -7
- package/src/review/thread-md.ts +35 -14
- package/src/review/thread-state.ts +798 -0
- package/src/review/threads.ts +29 -347
- package/src/review/traces.ts +104 -7
- package/src/review/trailer-item.ts +1 -1
- package/src/review/unit.ts +7 -9
- package/src/review/verdict-items.ts +12 -10
- package/src/review/view-layout.ts +25 -1
- package/src/review/watch-feed.ts +1 -2
- package/src/review/working-guards.ts +2 -3
- package/src/rules/untrack-generated.ts +1 -15
- package/src/secrets/lapse.ts +2 -1
- package/src/serve/hub-app/advisor-app.tsx +4 -4
- package/src/serve/hub-app/advisor-face.tsx +9 -3
- package/src/serve/hub-app/advisor-host.ts +27 -27
- package/src/serve/hub-app/advisors-model.ts +17 -8
- package/src/serve/hub-app/advisors-rights.tsx +1 -1
- package/src/serve/hub-app/advisors-st.ts +15 -14
- package/src/serve/hub-app/advisors-view.tsx +13 -11
- package/src/serve/hub-app/app-bridge.ts +23 -3
- package/src/serve/hub-app/asks-page.tsx +1 -1
- package/src/serve/hub-app/auto-text.tsx +71 -16
- package/src/serve/hub-app/check-view.tsx +0 -8
- package/src/serve/hub-app/controls.css +14 -3
- package/src/serve/hub-app/database-view.tsx +1 -2
- package/src/serve/hub-app/git-view.tsx +3 -1
- package/src/serve/hub-app/hub.css +12 -5
- package/src/serve/hub-app/icons.tsx +1 -1
- package/src/serve/hub-app/inbox-view.tsx +1 -2
- package/src/serve/hub-app/live-sources.ts +2 -2
- package/src/serve/hub-app/main-panel.tsx +2 -1
- package/src/serve/hub-app/panel-repo.ts +0 -9
- package/src/serve/hub-app/pic.tsx +29 -12
- package/src/serve/hub-app/polled.ts +16 -2
- package/src/serve/hub-app/recordings-st.ts +23 -2
- package/src/serve/hub-app/recordings-view.tsx +68 -10
- package/src/serve/hub-app/ref-pill.ts +1 -1
- package/src/serve/hub-app/repo-st.ts +1 -2
- package/src/serve/hub-app/review/advisor-add.tsx +1 -1
- package/src/serve/hub-app/review/advisor-invite.tsx +1 -1
- package/src/serve/hub-app/review/draft-body.tsx +2 -2
- package/src/serve/hub-app/review/heard-line.tsx +1 -1
- package/src/serve/hub-app/review/instructions-view.tsx +1 -8
- package/src/serve/hub-app/review/kind-states.tsx +14 -9
- package/src/serve/hub-app/review/kit.tsx +4 -11
- package/src/serve/hub-app/review/lane-bar.tsx +3 -3
- package/src/serve/hub-app/review/lightbox.tsx +15 -11
- package/src/serve/hub-app/review/line-window.ts +4 -1
- package/src/serve/hub-app/review/live-bar-st.ts +2 -2
- package/src/serve/hub-app/review/live-view.tsx +57 -1
- package/src/serve/hub-app/review/object-panel.tsx +20 -8
- package/src/serve/hub-app/review/question-views.tsx +181 -54
- package/src/serve/hub-app/review/recap-bar.tsx +40 -0
- package/src/serve/hub-app/review/request-cell.tsx +48 -0
- package/src/serve/hub-app/review/review-cells.tsx +154 -96
- package/src/serve/hub-app/review/review-host.ts +2 -2
- package/src/serve/hub-app/review/review-kit.ts +17 -11
- package/src/serve/hub-app/review/review-list.tsx +23 -31
- package/src/serve/hub-app/review/review-st.ts +30 -40
- package/src/serve/hub-app/review/review-thread.tsx +139 -85
- package/src/serve/hub-app/review/review-views.tsx +124 -68
- package/src/serve/hub-app/review/share-lines.tsx +4 -4
- package/src/serve/hub-app/review/start-st.ts +2 -5
- package/src/serve/hub-app/review/superseded-runs.ts +4 -3
- package/src/serve/hub-app/review/thread-close.tsx +10 -7
- package/src/serve/hub-app/review/thread-st.ts +372 -201
- package/src/serve/hub-app/review/tone-bar.tsx +126 -0
- package/src/serve/hub-app/review/tones.ts +35 -0
- package/src/serve/hub-app/review/trailer-body.tsx +2 -2
- package/src/serve/hub-app/review/trailer-st.ts +3 -2
- package/src/serve/hub-app/review/trailer-voices-st.ts +3 -2
- package/src/serve/hub-app/review.css +180 -106
- package/src/serve/hub-app/search-view.tsx +1 -1
- package/src/serve/hub-app/social/social-model.ts +0 -4
- package/src/serve/hub-app/source-acts.ts +2 -1
- package/src/serve/hub-app/stores/stores-page.tsx +2 -2
- package/src/serve/hub-app/terminal-sources.tsx +2 -1
- package/src/serve/hub-app/thread-row.tsx +3 -4
- package/src/serve/hub-app/tree-build.ts +0 -4
- package/src/serve/hub-app/urls-view.tsx +2 -1
- package/src/serve/hub-app/view-layout.css +13 -3
- package/src/serve/hub-app/wikis-view.tsx +5 -2
- package/src/serve/hub-runtime.ts +7 -37
- package/src/serve/project-gutter-route.ts +6 -2
- package/src/serve/read-thread.ts +20 -2
- package/src/serve/read-worker.ts +9 -1
- package/src/serve/record-pages.ts +46 -0
- package/src/serve/serve-hub.ts +2 -2
- package/src/serve/terminal-host.ts +1 -1
- package/src/serve/terminal-route.ts +1 -3
- package/src/serve/tracked-watch.ts +1 -3
- package/src/setup-house.ts +2 -2
- package/src/shipkit-files.ts +1 -1
- package/src/shipkit.ts +1 -6
- package/src/shot/film-box.ts +0 -20
- package/src/social/drafts.ts +1 -1
- package/src/social/kinds.ts +6 -29
- package/src/social/load.ts +2 -2
- package/src/social/post-object.ts +3 -2
- package/src/social/release-stage.ts +1 -1
- package/src/social/stage.ts +2 -2
- package/src/stores/model.ts +4 -0
- package/src/stores/routes.ts +11 -3
- package/src/suite/judge-suites.ts +58 -0
- package/src/suite/red-alone.ts +54 -18
- package/src/suite/runner-shapes.ts +2 -2
- package/src/suite/suite-cli.ts +67 -14
- package/src/suite/test-units.ts +2 -1
- package/src/urls/fill.ts +1 -1
- package/src/urls/places.ts +1 -2
- package/src/vault/vault-config.ts +2 -2
- package/src/vault/vault-init.ts +1 -5
- package/src/wiki/graph-page.ts +14 -2
- package/src/advisors/copy-truth.ts +0 -49
- package/src/advisors/door-child.ts +0 -112
- package/src/advisors/door-serve.ts +0 -52
- package/src/advisors/door.ts +0 -118
- package/src/checks/SK016-legacy-check-shapes.check.ts +0 -189
- package/src/checks/SK029-explicit-check-files.check.ts +0 -112
- package/src/checks/SK048-one-local-file.check.ts +0 -36
- package/src/core/config-rewrite.ts +0 -111
- package/src/core/daemon-port.ts +0 -10
- package/src/core/legacy-shapes.ts +0 -263
- package/src/core/migrate-layout.ts +0 -638
- package/src/core/port-check-cli.ts +0 -52
- package/src/core/port-check-file.ts +0 -295
- package/src/core/port-check-files.ts +0 -31
- package/src/gate/discover-legacy-checks.ts +0 -26
- package/src/home/home-move.ts +0 -527
- package/src/home/machine-fold.ts +0 -810
- package/src/hq/item-shapes.ts +0 -54
- package/src/hq/kinds/items-read.ts +0 -4
- package/src/media-store/backup/daemon.ts +0 -220
- package/src/media-store/backup/kept.ts +0 -241
- package/src/media-store/backup/prune.ts +0 -359
- package/src/media-store/backup/secret.ts +0 -88
- package/src/media-store/backup/ssh-space.ts +0 -202
- package/src/media-store/backup/watch.ts +0 -117
- package/src/review/band.ts +0 -182
- package/src/review/folders.ts +0 -216
- package/src/review/hook-ask.ts +0 -58
- package/src/review/role.ts +0 -48
- package/src/review/thread-fold.ts +0 -64
- package/src/review/wait.ts +0 -91
- package/src/rules/rule.ts +0 -43
- package/src/serve/hook-thread.ts +0 -37
- package/src/serve/hook-work.ts +0 -92
- package/src/serve/hook-worker.ts +0 -57
- package/src/serve/hub-app/review/dock.tsx +0 -147
- package/src/serve/hub-app/review/faces.tsx +0 -18
- package/src/serve/hub-app/review/item-verdict.tsx +0 -112
- package/src/serve/hub-app/review/review-board.tsx +0 -48
- /package/src/{scaffold → core}/jsonc-spans.ts +0 -0
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
// the advisors' door server as a child of the daemon (wiki tools/shipkit/advisors.md, The advisors page and its server): it runs while this
|
|
2
|
-
// machine carries the hq and the door is set up, looked at every 30 s, started again when it ends; it ends with the
|
|
3
|
-
// daemon, whose next image starts its own on the new code. The one constraint a reader breaks first: the child gets
|
|
4
|
-
// no environment of the daemon's but its path, its home and the door's facts, so no token reaches it
|
|
5
|
-
import { fileURLToPath } from 'node:url'
|
|
6
|
-
import { DOOR_ENV } from './door-serve.ts'
|
|
7
|
-
import { factsOf, type PageFacts } from './edge/pages.ts'
|
|
8
|
-
import { ADVISORS_LIVE } from './users-router.ts'
|
|
9
|
-
import { housePageFacts } from './door.ts'
|
|
10
|
-
import { ownerNameOf } from './owner-name.ts'
|
|
11
|
-
import { advisorsDir, doorDir, readState } from './owner-store.ts'
|
|
12
|
-
|
|
13
|
-
const SERVER = fileURLToPath(new URL('./door-serve.ts', import.meta.url))
|
|
14
|
-
const EVERY_MS = 30_000
|
|
15
|
-
|
|
16
|
-
export interface DoorChildDeps {
|
|
17
|
-
carries?: () => boolean
|
|
18
|
-
host?: () => string | null
|
|
19
|
-
/** the name the public pages print: his default (owner-name.ts) */
|
|
20
|
-
owner?: () => string
|
|
21
|
-
spawn?: (cmd: string[], env: Record<string, string>) => { exited: Promise<unknown>; kill: () => void }
|
|
22
|
-
/** the machine switch `advisors-live` (users-router.ts): this daemon serves the users' port itself */
|
|
23
|
-
live?: () => boolean
|
|
24
|
-
/** the users' port in this process, its reads and replies live */
|
|
25
|
-
listen?: (host: string, pages: PageFacts) => Promise<{ stop: () => void }>
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** the users' port served by this daemon: the live router over his advisors folder, his private words read again
|
|
29
|
-
* each minute */
|
|
30
|
-
async function listenHere(house: string, host: string, pages: PageFacts): Promise<{ stop: () => void }> {
|
|
31
|
-
const { usersRouter } = await import('./users-router.ts')
|
|
32
|
-
const { advisorsDoorPort, ARGON, usersServe } = await import('./door-serve.ts')
|
|
33
|
-
const { DirBucket } = await import('./dir-bucket.ts')
|
|
34
|
-
const { limits } = await import('./edge/sign-in.ts')
|
|
35
|
-
const { privateWords } = await import('./sync.ts')
|
|
36
|
-
let words: { at: number; list: string[] } = { at: 0, list: [] }
|
|
37
|
-
const wordsNow = (): string[] => (Date.now() - words.at < 60_000 ? words.list : (words = { at: Date.now(), list: privateWords(house) }).list)
|
|
38
|
-
const s = usersServe({ port: advisorsDoorPort(), fetch: usersRouter({ bucket: new DirBucket(doorDir()), host, pages, limits: limits(), password: ARGON, dir: advisorsDir(), words: wordsNow }) })
|
|
39
|
-
return { stop: () => void s.stop(true) }
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function keepDoorServer(o: { house: string; print: (l: string) => void; printErr: (l: string) => void; everyMs?: number } & DoorChildDeps): { stop: () => void; tick: () => Promise<void> } {
|
|
43
|
-
const host = o.host ?? (() => readState(advisorsDir()).host)
|
|
44
|
-
const owner = o.owner ?? (() => ownerNameOf(readState(advisorsDir())))
|
|
45
|
-
const spawn = o.spawn ?? ((cmd, env) => Bun.spawn(cmd, { env, stdout: 'inherit', stderr: 'inherit', stdin: 'ignore' }))
|
|
46
|
-
const liveOn = o.live ?? (() => (require('../core/machine-db.ts') as typeof import('../core/machine-db.ts')).machineGet<boolean>(ADVISORS_LIVE) === true)
|
|
47
|
-
const listen = o.listen ?? ((h: string, pages: PageFacts) => listenHere(o.house, h, pages))
|
|
48
|
-
let child: { host: string; owner: string; kill: () => void; exited: Promise<unknown> } | null = null
|
|
49
|
-
let here: { host: string; owner: string; stop: () => void } | null = null
|
|
50
|
-
let stopped = false
|
|
51
|
-
const look = async (): Promise<void> => {
|
|
52
|
-
let want: string | null = null
|
|
53
|
-
let name = 'the owner'
|
|
54
|
-
let live = false
|
|
55
|
-
try {
|
|
56
|
-
const carries = o.carries ?? (await import('../hq/hq-role.ts')).carriesHq
|
|
57
|
-
want = carries() ? host() : null
|
|
58
|
-
name = owner()
|
|
59
|
-
live = liveOn()
|
|
60
|
-
} catch (e) {
|
|
61
|
-
o.printErr(`WARN advisors page: ${(e as Error).message}`)
|
|
62
|
-
}
|
|
63
|
-
// a new name for the public pages, or the switch moved: what serves the port starts again
|
|
64
|
-
if (child !== null && (child.host !== want || child.owner !== name || live)) {
|
|
65
|
-
const was = child
|
|
66
|
-
child = null
|
|
67
|
-
was.kill()
|
|
68
|
-
// the port is free once the child ended: the daemon binds it next
|
|
69
|
-
await Promise.race([was.exited, Bun.sleep(3_000)])
|
|
70
|
-
}
|
|
71
|
-
if (here !== null && (here.host !== want || here.owner !== name || !live)) {
|
|
72
|
-
here.stop()
|
|
73
|
-
here = null
|
|
74
|
-
}
|
|
75
|
-
if (want === null || child !== null || here !== null) return
|
|
76
|
-
const pages = (await housePageFacts(o.house).catch(() => null))?.facts ?? factsOf(undefined, undefined)
|
|
77
|
-
if (stopped) return
|
|
78
|
-
if (live) {
|
|
79
|
-
try {
|
|
80
|
-
here = { host: want, owner: name, ...(await listen(want, pages)) }
|
|
81
|
-
o.print(`advisors page: serving ${want} from this daemon, live`)
|
|
82
|
-
} catch (e) {
|
|
83
|
-
o.printErr(`WARN advisors page: the users' port did not open here: ${(e as Error).message}`)
|
|
84
|
-
}
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
const env: Record<string, string> = { PATH: process.env.PATH ?? '', HOME: process.env.HOME ?? '', [DOOR_ENV.dir]: doorDir(), [DOOR_ENV.host]: want, [DOOR_ENV.owner]: name, ...(pages.contact !== null ? { [DOOR_ENV.contact]: pages.contact } : {}) }
|
|
88
|
-
const p = spawn([process.execPath, SERVER], env)
|
|
89
|
-
const mine = { host: want, owner: name, kill: () => p.kill(), exited: p.exited }
|
|
90
|
-
child = mine
|
|
91
|
-
void p.exited.then(() => {
|
|
92
|
-
if (child === mine) child = null
|
|
93
|
-
})
|
|
94
|
-
o.print(`advisors page: serving ${want}`)
|
|
95
|
-
}
|
|
96
|
-
// one look at a time: a tick while one runs waits for that one
|
|
97
|
-
let running: Promise<void> | null = null
|
|
98
|
-
const tick = (): Promise<void> => (running ??= look().finally(() => (running = null)))
|
|
99
|
-
void tick()
|
|
100
|
-
const timer = setInterval(() => void tick(), o.everyMs ?? EVERY_MS)
|
|
101
|
-
return {
|
|
102
|
-
tick,
|
|
103
|
-
stop: () => {
|
|
104
|
-
stopped = true
|
|
105
|
-
clearInterval(timer)
|
|
106
|
-
child?.kill()
|
|
107
|
-
child = null
|
|
108
|
-
here?.stop()
|
|
109
|
-
here = null
|
|
110
|
-
},
|
|
111
|
-
}
|
|
112
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// the advisors' door server (wiki tools/shipkit/advisors.md, The advisors page and its server): the one server besides the house's loopback one (RV040
|
|
2
|
-
// allows this file), on 127.0.0.1, reached by the tunnel alone. A child of the daemon of the machine that carries the
|
|
3
|
-
// hq (advisors/door-child.ts), over the door's folder. The one constraint a reader breaks first: it imports the
|
|
4
|
-
// door's own code only (the edge folder and the folder bucket, tests/advisors-door-serve.test.ts), so no hub route,
|
|
5
|
-
// no owner word and no vault can exist on this port
|
|
6
|
-
import { DirBucket } from './dir-bucket.ts'
|
|
7
|
-
import { handle } from './edge/handler.ts'
|
|
8
|
-
import { factsOf, type PageFacts } from './edge/pages.ts'
|
|
9
|
-
import { limits, type PasswordHasher } from './edge/sign-in.ts'
|
|
10
|
-
|
|
11
|
-
/** a password as the door keeps it: argon2id */
|
|
12
|
-
export const ARGON: PasswordHasher = { hash: (p) => Bun.password.hash(p, { algorithm: 'argon2id' }), verify: (p, h) => Bun.password.verify(p, h) }
|
|
13
|
-
|
|
14
|
-
/** below the vault's ports (4792, 4793, 4794 kept for its door) */
|
|
15
|
-
export const DEFAULT_ADVISORS_DOOR_PORT = 4791
|
|
16
|
-
|
|
17
|
-
export const advisorsDoorPort = (): number => {
|
|
18
|
-
const env = Number(process.env.SHIPKIT_ADVISORS_DOOR_PORT)
|
|
19
|
-
return Number.isInteger(env) && env > 0 ? env : DEFAULT_ADVISORS_DOOR_PORT
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** what the daemon gives the child, by its environment: never a secret */
|
|
23
|
-
export const DOOR_ENV = { dir: 'SHIPKIT_ADVISORS_DOOR_DIR', host: 'SHIPKIT_ADVISORS_HOST', owner: 'SHIPKIT_ADVISORS_OWNER', contact: 'SHIPKIT_ADVISORS_CONTACT' } as const
|
|
24
|
-
|
|
25
|
-
/** `tls`: the https the tunnel speaks, for a browser check of this same server (tests/browser/advisors-door-check.ts);
|
|
26
|
-
* the daemon's child never passes one, cloudflared ends the tls */
|
|
27
|
-
export function doorServer(o: { port: number; dir: string; host: string; pages: PageFacts; now?: () => number; password?: PasswordHasher; tls?: { cert: string; key: string } }): Bun.Server<undefined> {
|
|
28
|
-
const env = { bucket: new DirBucket(o.dir), host: o.host.toLowerCase(), pages: o.pages, limits: limits(), password: o.password ?? ARGON, ...(o.now ? { now: o.now } : {}) }
|
|
29
|
-
return usersServe({ port: o.port, ...(o.tls ? { tls: o.tls } : {}), fetch: (req) => handle(req, env) })
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** the users' port on 127.0.0.1, whatever answers it: this process's handler, or the hq daemon's live router
|
|
33
|
-
* (users-router.ts). No shared port: another program of this Mac may not bind beside it and take its requests */
|
|
34
|
-
export function usersServe(o: { port: number; fetch: (req: Request) => Promise<Response>; tls?: { cert: string; key: string } }): Bun.Server<undefined> {
|
|
35
|
-
return Bun.serve({ hostname: '127.0.0.1', port: o.port, ...(o.tls ? { tls: o.tls } : {}), fetch: o.fetch, error: () => new Response('error', { status: 500 }) })
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (import.meta.main) {
|
|
39
|
-
const dir = process.env[DOOR_ENV.dir] ?? ''
|
|
40
|
-
const host = process.env[DOOR_ENV.host] ?? ''
|
|
41
|
-
if (dir === '' || host === '') {
|
|
42
|
-
console.error(`FAIL the advisors page's server needs ${DOOR_ENV.dir} and ${DOOR_ENV.host}`)
|
|
43
|
-
process.exit(1)
|
|
44
|
-
}
|
|
45
|
-
const s = doorServer({ port: advisorsDoorPort(), dir, host, pages: factsOf(process.env[DOOR_ENV.owner], process.env[DOOR_ENV.contact]) })
|
|
46
|
-
console.log(`advisors page: ${host} on 127.0.0.1:${s.port}`)
|
|
47
|
-
// the daemon that started it ends: so does it, its next image starts its own
|
|
48
|
-
const parent = process.ppid
|
|
49
|
-
setInterval(() => {
|
|
50
|
-
if (process.ppid !== parent) process.exit(0)
|
|
51
|
-
}, 2_000)
|
|
52
|
-
}
|
package/src/advisors/door.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
// the door as the advisors page reads it (wiki tools/shipkit/advisors.md, The advisors page and its server): where it stands, the name the
|
|
2
|
-
// house config gives it, and in one line whether advisors reach this Mac now (set up, this Mac carries the hq, the
|
|
3
|
-
// tunnel's token stored, the door's server answers). Never a value of a secret: its presence only
|
|
4
|
-
import { hostname } from 'node:os'
|
|
5
|
-
import { loadRepoConfig } from '../repo-config.ts'
|
|
6
|
-
import { heldHere } from '../secrets/read.ts'
|
|
7
|
-
import { ownAddressOf } from '../review/model.ts'
|
|
8
|
-
import { readAll, storeDir } from '../review/store.ts'
|
|
9
|
-
import { threadsOf } from '../review/threads.ts'
|
|
10
|
-
import { loadIdentities, speakerOf } from '../identities/identities.ts'
|
|
11
|
-
import { advisorsDoorPort } from './door-serve.ts'
|
|
12
|
-
import { factsOf, type PageFacts } from './edge/pages.ts'
|
|
13
|
-
import type { SetupRun } from './owner-store.ts'
|
|
14
|
-
|
|
15
|
-
// sk-disable-next-line RV045 -- the tunnel's runner reads the house's own tunnel token by this name
|
|
16
|
-
export const TUNNEL_TOKEN = 'rv/cloudflare/advisors-tunnel'
|
|
17
|
-
|
|
18
|
-
export interface DoorFacts {
|
|
19
|
-
/** where the door stands once his setup ran, null before */
|
|
20
|
-
host: string | null
|
|
21
|
-
/** the name it opens at: the house config's `serve.advisorsHost`, else the door's */
|
|
22
|
-
want: string | null
|
|
23
|
-
/** advisors reach this Mac now */
|
|
24
|
-
ok: boolean
|
|
25
|
-
/** the door in one line: « advisors reach <mac> at <host> », or what is wrong */
|
|
26
|
-
words: string
|
|
27
|
-
/** the ask « open the advisors door », its thread in the house */
|
|
28
|
-
ask: { repo: string; head: string; address: string } | null
|
|
29
|
-
/** what his terminal runs to set it up */
|
|
30
|
-
command: string | null
|
|
31
|
-
/** the setup the daemon runs by itself once his token landed (setup-run.ts): while it runs, after it failed, or for
|
|
32
|
-
* an hour after it ended */
|
|
33
|
-
run?: SetupRun | null
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const RUN_SHOWN_MS = 3_600_000
|
|
37
|
-
/** the setup run the foot shows, null once it ended well over an hour ago */
|
|
38
|
-
export const shownRun = (r: SetupRun | undefined, now: Date): SetupRun | null =>
|
|
39
|
-
r === undefined || (r.state === 'done' && now.getTime() - Date.parse(r.ended ?? r.at) > RUN_SHOWN_MS) || (r.state === 'done' && r.lines.length === 0) ? null : r
|
|
40
|
-
|
|
41
|
-
/** the identity the house's repo config speaks as: its id (the name advisors read when he set none) and its contact */
|
|
42
|
-
export async function housePageFacts(house: string | null): Promise<{ facts: PageFacts; id: string | null; warn?: string }> {
|
|
43
|
-
const speaker = house === null ? null : speakerOf((await loadRepoConfig(house)).speaksAs, await loadIdentities({ cwd: house }))
|
|
44
|
-
const facts = factsOf(speaker?.id, speaker?.rows.find((r) => r.field === 'email')?.value)
|
|
45
|
-
const id = speaker?.id ?? null
|
|
46
|
-
if (facts.contact !== null) return { facts, id }
|
|
47
|
-
return { facts, id, warn: `the privacy page names no contact: ${speaker === null ? 'no identity speaks for the house' : `the identity ${speaker.id} has no email row in its identity.md profile`}` }
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const speaks = new Map<string, Promise<string | null>>()
|
|
51
|
-
/** the identity a repo speaks as (its config's `speaksAs`), read once per process: his name for advisors there
|
|
52
|
-
* (owner-name.ts) */
|
|
53
|
-
export function identityOfRoot(root: string): Promise<string | null> {
|
|
54
|
-
if (!speaks.has(root)) speaks.set(root, loadRepoConfig(root).then((c) => c.speaksAs ?? null, () => null))
|
|
55
|
-
return speaks.get(root)!
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** the name the door opens at: the house config's `serve.advisorsHost`, null when it names none */
|
|
59
|
-
export async function houseHost(house: string): Promise<string | null> {
|
|
60
|
-
const h = await loadRepoConfig(house).then((c) => c.serve?.advisorsHost?.trim().toLowerCase() ?? '', () => '')
|
|
61
|
-
return h === '' ? null : h
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** the ask's address: `ask:<n>-open-the-advisors-door` */
|
|
65
|
-
export const DOOR_ASK = /^ask:\d+-open-the-advisors-door$/
|
|
66
|
-
|
|
67
|
-
const HOST_RE = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/
|
|
68
|
-
|
|
69
|
-
export const exposeCommand = (host: string): string | null => (HOST_RE.test(host) ? `sk advisors expose --host ${host}` : null)
|
|
70
|
-
|
|
71
|
-
/** what the line reads; each the real one by default, a test passes its own */
|
|
72
|
-
export interface DoorLooks {
|
|
73
|
-
carries?: () => boolean
|
|
74
|
-
tunnel?: () => Promise<'stored' | 'missing' | 'unknown'>
|
|
75
|
-
serves?: (host: string) => Promise<boolean>
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** the door's server answers its own name on this Mac */
|
|
79
|
-
async function serves(host: string): Promise<boolean> {
|
|
80
|
-
try {
|
|
81
|
-
const r = await fetch(`http://127.0.0.1:${advisorsDoorPort()}/health`, { headers: { host }, signal: AbortSignal.timeout(500) })
|
|
82
|
-
return r.ok
|
|
83
|
-
} catch {
|
|
84
|
-
return false
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/** the door in one line, worst first */
|
|
89
|
-
export async function doorLine(host: string | null, house: string, l: DoorLooks = {}): Promise<{ ok: boolean; words: string }> {
|
|
90
|
-
// the page names the ask, never a command: the ask's steps hold the one run in his terminal
|
|
91
|
-
if (host === null) return { ok: false, words: 'not set up yet: the ask that opens the advisors page' }
|
|
92
|
-
const carries = l.carries ?? (await import('../hq/hq-role.ts')).carriesHq
|
|
93
|
-
if (!carries()) return { ok: false, words: `the advisors page runs on the Mac that carries the hq, not this one` }
|
|
94
|
-
const tunnel = await (l.tunnel ?? (async () => (await heldHere({ names: [TUNNEL_TOKEN], cwd: house }))[TUNNEL_TOKEN]?.held ?? 'unknown'))().catch(() => 'unknown' as const)
|
|
95
|
-
if (tunnel === 'missing') return { ok: false, words: "the tunnel's token is not stored: the ask that opens the advisors page" }
|
|
96
|
-
if (!(await (l.serves ?? serves)(host))) return { ok: false, words: "the advisors page's server does not answer on this Mac: the daemon starts it" }
|
|
97
|
-
return { ok: true, words: `advisors reach ${hostname().replace(/\.local$/, '')} at ${host}` }
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export async function doorFacts(o: { house: string; houseRepo: string | null; host: string | null; looks?: DoorLooks }): Promise<DoorFacts> {
|
|
101
|
-
let want = o.host
|
|
102
|
-
try {
|
|
103
|
-
want = (await loadRepoConfig(o.house)).serve?.advisorsHost?.trim().toLowerCase() || o.host
|
|
104
|
-
} catch {
|
|
105
|
-
// no house config here: the door's name, or none
|
|
106
|
-
}
|
|
107
|
-
let ask: DoorFacts['ask'] = null
|
|
108
|
-
try {
|
|
109
|
-
for (const t of threadsOf(readAll(storeDir(o.house)).items)) {
|
|
110
|
-
const address = ownAddressOf(t.head.item)
|
|
111
|
-
if (address !== null && DOOR_ASK.test(address)) ask = { repo: o.houseRepo ?? '', head: t.head.item.id, address }
|
|
112
|
-
}
|
|
113
|
-
} catch {
|
|
114
|
-
// the house store does not read now: no link, the words still say what is missing
|
|
115
|
-
}
|
|
116
|
-
const command = want === null ? null : exposeCommand(want)
|
|
117
|
-
return { host: o.host, want, ...(await doorLine(o.host, o.house, o.looks)), ask, command }
|
|
118
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
// SK016 — the shapes the check file replaced, and the machine that
|
|
2
|
-
// rewrites them (tools/shipkit/writing-a-check.md owns the shape itself).
|
|
3
|
-
//
|
|
4
|
-
// The window: every shape below is still READ, named once per run, and
|
|
5
|
-
// refused at the first release after `shipkit fleet` shows no repo below 0.40
|
|
6
|
-
// and none still carrying a check script.
|
|
7
|
-
// So a repo on an old declaration keeps working, learns what to write instead
|
|
8
|
-
// on every gate, and is carried across by one command, save what only a
|
|
9
|
-
// reader can port: a check script's body, a rule, a task whose body is code.
|
|
10
|
-
//
|
|
11
|
-
// It WARNs rather than FAILs for the whole window, because the repo is not
|
|
12
|
-
// broken: it is behind. The day the shapes are refused, `defineRepo` and
|
|
13
|
-
// discovery say so at load, which is a louder place than a lint row.
|
|
14
|
-
//
|
|
15
|
-
// It reads and writes through `c` alone. The config half of the rewrite loads
|
|
16
|
-
// repo.config.ts as a module, which no read can stand for, so it runs in its
|
|
17
|
-
// own process (core/config-rewrite.ts) through `c.exec`.
|
|
18
|
-
import { join } from 'path'
|
|
19
|
-
import { checkFileRunBy, dropConfigKey, legacyShapes, scriptPort, taskCheckSource, checkFileName } from '../core/legacy-shapes.ts'
|
|
20
|
-
import type { ConfigPlan, ConfigRewrite } from '../core/config-rewrite.ts'
|
|
21
|
-
import { check, type CheckCtx, type FixResult, type TaskDef } from '../check.ts'
|
|
22
|
-
|
|
23
|
-
/** the config half of the rewrite, run as its own process */
|
|
24
|
-
const CONFIG_REWRITE = join(import.meta.dir, '../core/config-rewrite.ts')
|
|
25
|
-
|
|
26
|
-
/** what applies the config half of a plan and says what it did */
|
|
27
|
-
export type ConfigRewriter = (plan: ConfigPlan) => Promise<ConfigRewrite>
|
|
28
|
-
|
|
29
|
-
/** the fixer's rewriter: core/config-rewrite.ts in its own process, since
|
|
30
|
-
* loading repo.config.ts as a module is not a read the context records */
|
|
31
|
-
const inOwnProcess = (c: CheckCtx): ConfigRewriter => async (plan) => {
|
|
32
|
-
const r = await c.exec([process.execPath, CONFIG_REWRITE, c.root, JSON.stringify(plan)], { cwd: c.root, timeoutMs: 60_000 })
|
|
33
|
-
try {
|
|
34
|
-
return JSON.parse(r.out.trim().split('\n').at(-1) ?? '') as ConfigRewrite
|
|
35
|
-
} catch {
|
|
36
|
-
return { did: [], hand: [`the repo.config.ts rewrite did not answer (exit ${r.code}${r.timedOut ? ', timed out' : ''}: ${r.out.trim().slice(0, 160)}) — apply ${JSON.stringify(plan)} by hand`] }
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const OWNER = 'tools/shipkit/writing-a-check.md'
|
|
41
|
-
|
|
42
|
-
export const legacyCheckShapes = check({
|
|
43
|
-
id: 'SK016',
|
|
44
|
-
title: 'legacy check shapes',
|
|
45
|
-
description: 'every check declaration uses the current check file shape',
|
|
46
|
-
owner: OWNER,
|
|
47
|
-
// about THIS repo's own declarations, so it is a repo fact. It only ever
|
|
48
|
-
// warns while the window is open, which is the severity, not the axis
|
|
49
|
-
blocking: true,
|
|
50
|
-
// keyed on what it reads: the listing of check files, their sources, and
|
|
51
|
-
// the config. A gitignored check file is no declaration of this repo
|
|
52
|
-
runs: { onPreCommit: false, onCi: false, onFull: true, onRelease: true, onHealth: true, onSave: 'moved', onClock: false },
|
|
53
|
-
cache: { by: 'reads' },
|
|
54
|
-
fix: 'manual',
|
|
55
|
-
applies: 'always',
|
|
56
|
-
run: (c) => {
|
|
57
|
-
const s = legacyShapes(c, c.config)
|
|
58
|
-
if (s.count === 0 && s.placeholders.length === 0) {
|
|
59
|
-
c.ok('no legacy declaration: every check in this repo is a check file')
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
// the one thing the migration cannot write: a sentence only the
|
|
63
|
-
// author knows. The check loads and runs meanwhile, so it is a warning
|
|
64
|
-
// that names each file, never a refusal
|
|
65
|
-
if (s.placeholders.length > 0)
|
|
66
|
-
c.warn(
|
|
67
|
-
`${s.placeholders.length} check file(s) still open with the TODO description the migration wrote: ${s.placeholders.join(', ')}`,
|
|
68
|
-
'by hand: replace each TODO with one line stating what must be true',
|
|
69
|
-
)
|
|
70
|
-
if (s.count === 0) return
|
|
71
|
-
// one WARN per shape, never a bare line: the gate promises every line
|
|
72
|
-
// it prints carries a wire prefix, and this check runs in every gate
|
|
73
|
-
if (s.checkFiles.length > 0) {
|
|
74
|
-
const head = s.checkFiles.slice(0, 3).map((f) => f.rel).join(', ')
|
|
75
|
-
c.warn(`${s.checkFiles.length} legacy check script(s) read by the static reader: ${head}${s.checkFiles.length > 3 ? `, and ${s.checkFiles.length - 3} more` : ''}`)
|
|
76
|
-
const off = s.checkFiles.filter((f) => !f.read.gate).length
|
|
77
|
-
if (off > 0) c.warn(`${off} of them carry \`export const gate = false\`, which is every gate axis false and onHealth true`)
|
|
78
|
-
}
|
|
79
|
-
if (s.checkDefaults) c.warn(`repo.config.ts checkDefaults lets a file forget \`blocking\` — the value belongs in each file`)
|
|
80
|
-
if (s.tasks.length > 0) {
|
|
81
|
-
const data = s.tasks.filter((x) => x.data).length
|
|
82
|
-
c.warn(`${s.tasks.length} \`tasks: []\` entr(ies), ${data} of them pure data — each one is a *.check.ts file with \`build: true\``)
|
|
83
|
-
}
|
|
84
|
-
if (s.rules.length > 0) c.warn(`${s.rules.length} \`rules: []\` entr(ies): ${s.rules.join(', ')} — each one is a *.check.ts file whose \`run\` is its \`lint\``)
|
|
85
|
-
if (s.ruleExempt.length > 0) c.warn(`ruleExempt names ${s.ruleExempt.join(', ')} — the spelling is \`off: { id: '<why>' }\`, and \`shipkit ci\` ports it (SK029)`)
|
|
86
|
-
// what the fixer rewrites without guessing: the exemptions, the tasks
|
|
87
|
-
// once all of them are data, checkDefaults once no script leans on it
|
|
88
|
-
const mechanical = (s.tasks.every((x) => x.data) ? s.tasks.length : 0) + (s.checkDefaults && s.checkFiles.length === 0 ? 1 : 0)
|
|
89
|
-
c.warn(
|
|
90
|
-
`${s.count} declaration(s) in a shape the check file replaced: still read, and refused by the first shipkit release after \`shipkit fleet\` shows no repo below 0.40 and none still carrying a check script`,
|
|
91
|
-
mechanical > 0
|
|
92
|
-
? `shipkit check --fix SK016 rewrites ${mechanical} of them and names the rest`
|
|
93
|
-
: `nothing left is mechanical, so the port is by hand: each line above becomes a *.check.ts file (${OWNER})`,
|
|
94
|
-
)
|
|
95
|
-
},
|
|
96
|
-
repair: async (c) => await fixLegacyShapes(c),
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
export default legacyCheckShapes
|
|
100
|
-
|
|
101
|
-
/** the rewrite. Everything it cannot do without guessing is NAMED in the
|
|
102
|
-
* summary instead of attempted, so a repo is never left half migrated.
|
|
103
|
-
* `rewrite` applies the config half, in its own process unless a caller
|
|
104
|
-
* that may load the config in process hands `rewriteConfig` itself */
|
|
105
|
-
export async function fixLegacyShapes(c: CheckCtx, rewrite: ConfigRewriter = inOwnProcess(c)): Promise<FixResult> {
|
|
106
|
-
const { root } = c
|
|
107
|
-
const config = c.config
|
|
108
|
-
const s = legacyShapes(c, config)
|
|
109
|
-
const todo = (rel: string): string => `${rel}: replace the TODO with one line stating what must be true`
|
|
110
|
-
if (s.count === 0)
|
|
111
|
-
return { changed: false, summary: s.placeholders.length === 0 ? 'nothing legacy left to rewrite' : `nothing mechanical left. ${s.placeholders.length} by hand: ${s.placeholders.map(todo).join(' | ')}` }
|
|
112
|
-
|
|
113
|
-
const did: string[] = []
|
|
114
|
-
const hand: string[] = s.placeholders.map(todo)
|
|
115
|
-
const source = (rel: string): string => c.read(rel) ?? ''
|
|
116
|
-
|
|
117
|
-
// THE PLAN, before any write. A check script is never rewritten: its body
|
|
118
|
-
// prints and exits in a process of its own, and the one body a check file
|
|
119
|
-
// has is `run: (c) => …` (SK020 refuses a check file that spawns itself).
|
|
120
|
-
// Moving prints onto `c` is a hand pass, so each script is listed with
|
|
121
|
-
// where it goes, and the static reader keeps running it meanwhile. The
|
|
122
|
-
// tasks move all together or not at all: the `tasks` key is dropped
|
|
123
|
-
// whole, and a task that runs a script waits for that script's port
|
|
124
|
-
const tasks = config.tasks ?? []
|
|
125
|
-
const checkRels = new Set(s.checkFiles.map((f) => f.rel))
|
|
126
|
-
const runsOf = new Map<TaskDef, { rel: string; rest: string[] }>()
|
|
127
|
-
for (const t of tasks) {
|
|
128
|
-
const r = t.logic == null ? checkFileRunBy(t, root) : null
|
|
129
|
-
if (r != null && checkRels.has(r.rel)) runsOf.set(t, r)
|
|
130
|
-
}
|
|
131
|
-
const fileIds = new Set(s.checkFiles.map((f) => f.read.name))
|
|
132
|
-
const configText = source('repo.config.ts')
|
|
133
|
-
const taskBlock: string[] = []
|
|
134
|
-
if (tasks.length > 0 && dropConfigKey(configText, 'tasks') == null) taskBlock.push('the `tasks` key could not be read mechanically')
|
|
135
|
-
for (const t of tasks) {
|
|
136
|
-
const runs = runsOf.get(t)
|
|
137
|
-
if (t.logic != null || t.cmd == null) taskBlock.push(`task ${t.id}: its body is \`logic\`, a function — move it into ${checkFileName(t.id)} beside repo.config.ts as \`run\``)
|
|
138
|
-
else if (runs != null) taskBlock.push(`task ${t.id}: it runs ${runs.rel}, a check script — port that file first, then drop the task: the check file is the check`)
|
|
139
|
-
else if (fileIds.has(t.id)) taskBlock.push(`task ${t.id}: a check file answers to the same id, and the task does not simply run that file, so the two are different checks — rename one of them`)
|
|
140
|
-
else if (c.exists(checkFileName(t.id))) taskBlock.push(`task ${t.id}: ${checkFileName(t.id)} already exists beside repo.config.ts, so its check file needs another name`)
|
|
141
|
-
}
|
|
142
|
-
const tasksMove = tasks.length > 0 && taskBlock.length === 0
|
|
143
|
-
if (!tasksMove) {
|
|
144
|
-
for (const l of taskBlock) hand.push(l)
|
|
145
|
-
if (tasks.length > 0) hand.push(`the ${tasks.length} task(s) stay in repo.config.ts until the line(s) above are done, then they move together`)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// 1. the check scripts, each listed with where it goes. Its declarations
|
|
149
|
-
// are what the static reader read, so the port loses none of them
|
|
150
|
-
for (const f of s.checkFiles) hand.push(`${f.rel}: ${scriptPort(f.read, config.checkDefaults?.blocking)}`)
|
|
151
|
-
const filesLeft = s.checkFiles.length
|
|
152
|
-
|
|
153
|
-
// 2. the tasks that are DATA, each as its own check file beside the
|
|
154
|
-
// config (the plan refused a name another file already holds)
|
|
155
|
-
for (const t of tasksMove ? tasks : []) {
|
|
156
|
-
const name = checkFileName(t.id)
|
|
157
|
-
c.write(name, taskCheckSource(t, root))
|
|
158
|
-
did.push(`task ${t.id} → ${name}`)
|
|
159
|
-
// a config entry carries no prose, so nothing can be lifted: the file
|
|
160
|
-
// passes the shape and a human owes it the line
|
|
161
|
-
hand.push(`${name}: a task declaration carried no prose — replace the TODO with one line stating what must be true`)
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// 3. a rule is a function too, and the file it was written in owns the
|
|
165
|
-
// names it closes over. The fixer says where it goes, never guesses
|
|
166
|
-
for (const r of config.rules ?? [])
|
|
167
|
-
hand.push(`rule ${r.id}: move it into ${checkFileName(r.id)} beside repo.config.ts, \`lint\` becomes \`run\` and \`code\` goes (the file's own path is its closure)`)
|
|
168
|
-
|
|
169
|
-
// 4. the config keys, last: a key is only dropped once every declaration
|
|
170
|
-
// that leaned on it has a home. It loads the config, so it runs in its
|
|
171
|
-
// own process. `ruleExempt` is SK029's: it ports it into `off`
|
|
172
|
-
const cfgPlan: ConfigPlan = { off: {}, drop: [], name: config.name }
|
|
173
|
-
if (s.checkDefaults && filesLeft === 0) cfgPlan.drop.push({ key: 'checkDefaults', why: 'every file now declares its own blocking' })
|
|
174
|
-
else if (s.checkDefaults) hand.push(`repo.config.ts \`checkDefaults\` stays until the ${filesLeft} file(s) above declare their own \`blocking\``)
|
|
175
|
-
if (tasksMove) cfgPlan.drop.push({ key: 'tasks', why: 'every task is a check file now' })
|
|
176
|
-
if (cfgPlan.drop.length > 0) {
|
|
177
|
-
const out = await rewrite(cfgPlan)
|
|
178
|
-
did.push(...out.did)
|
|
179
|
-
hand.push(...out.hand)
|
|
180
|
-
if (out.restored != null)
|
|
181
|
-
return { changed: did.length > 0, summary: `repo.config.ts was left as it was, its rewrite did not load back (${out.restored}). Done: ${did.join('; ') || 'nothing'}` }
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const summary = [
|
|
185
|
-
did.length > 0 ? did.join('; ') : 'nothing mechanical left',
|
|
186
|
-
...(hand.length > 0 ? [`${hand.length} by hand: ${hand.join(' | ')}`] : []),
|
|
187
|
-
].join('. ')
|
|
188
|
-
return { changed: did.length > 0, summary }
|
|
189
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
// SK029 explicit check files (tools/shipkit/runs.md owns the declaration):
|
|
2
|
-
// every check file of the repo declares runs, cache, fix and applies, with
|
|
3
|
-
// no retired key. A file that does not does not load, and discovery shows
|
|
4
|
-
// it as one failing row. The repair ports it with the values the retired
|
|
5
|
-
// keys resolved to (core/port-check-file.ts), so the check keeps running
|
|
6
|
-
// where it ran, and the ci fix pass applies it before the gate reads the
|
|
7
|
-
// files: a repo carried across by its first `shipkit ci`. The same holds for
|
|
8
|
-
// the config: a retired `when` (only its `off:<why>` entries still load),
|
|
9
|
-
// `ruleExempt`, `hooks.disable` and a `defaults` slot set to false become
|
|
10
|
-
// `off` entries in the managed block.
|
|
11
|
-
import { join } from 'path'
|
|
12
|
-
import { check, type FixResult } from '../check.ts'
|
|
13
|
-
import { unportedCheckFiles } from '../core/port-check-files.ts'
|
|
14
|
-
import type { PortRun } from '../core/port-check-cli.ts'
|
|
15
|
-
import type { ConfigPlan, ConfigRewrite } from '../core/config-rewrite.ts'
|
|
16
|
-
import type { RepoConfig } from '../repo-config.ts'
|
|
17
|
-
import { legacyOffReason } from '../core/when.ts'
|
|
18
|
-
|
|
19
|
-
/** the write half, run as its own process: it walks import closures on disk */
|
|
20
|
-
const PORT_CLI = join(import.meta.dir, '../core/port-check-cli.ts')
|
|
21
|
-
/** the config half, run as its own process: it loads repo.config.ts */
|
|
22
|
-
const CONFIG_REWRITE = join(import.meta.dir, '../core/config-rewrite.ts')
|
|
23
|
-
|
|
24
|
-
/** the retired config spellings this repo still carries, and the `off`
|
|
25
|
-
* entries they become. defineRepo already refused every `when` word but
|
|
26
|
-
* `off:<why>`. `hooks.disable` and a `defaults` slot set to false never said
|
|
27
|
-
* why, so they are lifted with the comment above them, else with a reason
|
|
28
|
-
* that says none was recorded (core/when.ts legacyOffReason) */
|
|
29
|
-
export function retiredOff(c: RepoConfig): { keys: string[]; off: Record<string, string>; lift: NonNullable<ConfigPlan['lift']> } {
|
|
30
|
-
const off: Record<string, string> = {}
|
|
31
|
-
for (const [id, raw] of Object.entries(c.when ?? {})) off[id] = raw.trim().replace(/^off:?/, '').trim()
|
|
32
|
-
for (const [id, why] of Object.entries(c.ruleExempt ?? {})) off[id] ??= why
|
|
33
|
-
const lift: NonNullable<ConfigPlan['lift']> = []
|
|
34
|
-
const disable = c.hooks?.disable ?? []
|
|
35
|
-
if (c.hooks?.disable != null)
|
|
36
|
-
lift.push({ parent: 'hooks', entry: 'disable', value: '\\[[^\\]\\[]*\\]', ids: disable, reason: Object.fromEntries(disable.map((id) => [id, legacyOffReason('hooks.disable', id)])) })
|
|
37
|
-
const slots = Object.entries(c.defaults ?? {}).filter(([, d]) => d === false).map(([id]) => id)
|
|
38
|
-
for (const id of slots) lift.push({ parent: 'defaults', entry: id, value: 'false', ids: [id], reason: { [id]: legacyOffReason('defaults', id) } })
|
|
39
|
-
const keys = [
|
|
40
|
-
...(c.when != null ? ['when'] : []),
|
|
41
|
-
...(c.ruleExempt != null ? ['ruleExempt'] : []),
|
|
42
|
-
...(c.hooks?.disable != null ? ['hooks.disable'] : []),
|
|
43
|
-
...slots.map((id) => `defaults.${id}: false`),
|
|
44
|
-
]
|
|
45
|
-
return { keys, off, lift }
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const explicitCheckFiles = check({
|
|
49
|
-
id: 'SK029',
|
|
50
|
-
title: 'explicit check files',
|
|
51
|
-
description: 'every check file declares runs, cache, fix and applies, and the config says only off',
|
|
52
|
-
owner: 'tools/shipkit/runs.md',
|
|
53
|
-
blocking: true,
|
|
54
|
-
runs: { onPreCommit: false, onCi: true, onFull: true, onRelease: true, onHealth: true, onSave: 'moved', onClock: false },
|
|
55
|
-
// the listing of check files and their sources, read through `c`
|
|
56
|
-
cache: { by: 'reads' },
|
|
57
|
-
// the port is mechanical: every value it writes is what the retired keys
|
|
58
|
-
// resolved to, so the fix pass applies it without asking
|
|
59
|
-
fix: 'ci',
|
|
60
|
-
applies: 'always',
|
|
61
|
-
run: (c) => {
|
|
62
|
-
const files = unportedCheckFiles(c)
|
|
63
|
-
const cfg = retiredOff(c.config)
|
|
64
|
-
if (files.length === 0 && cfg.keys.length === 0) return c.ok('every check file declares runs, cache, fix and applies, and the config says only off')
|
|
65
|
-
for (const f of files) c.fail(`${f.rel} still declares the retired shape (${f.keys.join(', ')}), so it does not load`)
|
|
66
|
-
if (cfg.keys.length > 0) c.fail(`repo.config.ts still carries ${cfg.keys.join(' and ')}: a repo only turns a check off, as off: { <id>: '<why>' }`)
|
|
67
|
-
c.fail(`${files.length + (cfg.keys.length > 0 ? 1 : 0)} file(s) to port`, 'shipkit check --fix SK029 ports each one with the values it ran on, and `shipkit ci` does it in its fix pass')
|
|
68
|
-
},
|
|
69
|
-
repair: async (c): Promise<FixResult> => {
|
|
70
|
-
const files = unportedCheckFiles(c)
|
|
71
|
-
const cfg = retiredOff(c.config)
|
|
72
|
-
if (files.length === 0 && cfg.keys.length === 0) return { changed: false, summary: 'every check file is explicit already, and the config says only off' }
|
|
73
|
-
const did: string[] = []
|
|
74
|
-
const hand: string[] = []
|
|
75
|
-
if (files.length > 0) {
|
|
76
|
-
const r = await c.exec([process.execPath, PORT_CLI, c.root, ...files.map((f) => f.rel)], { cwd: c.root, timeoutMs: 60_000 })
|
|
77
|
-
try {
|
|
78
|
-
const run = JSON.parse(r.out.trim().split('\n').at(-1) ?? '') as PortRun
|
|
79
|
-
if (run.did.length > 0) did.push(`ported ${run.did.join('; ')}`)
|
|
80
|
-
hand.push(...run.hand)
|
|
81
|
-
} catch {
|
|
82
|
-
hand.push(`the port did not answer (exit ${r.code}: ${r.out.trim().slice(0, 160)}): port ${files.map((f) => f.rel).join(', ')} by hand (tools/shipkit/runs.md)`)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (cfg.keys.length > 0) {
|
|
86
|
-
// `when` sits inside the managed block, so it goes first and the
|
|
87
|
-
// block describes the config again before the entries land
|
|
88
|
-
const plan: ConfigPlan = {
|
|
89
|
-
off: cfg.off,
|
|
90
|
-
drop: [
|
|
91
|
-
...(c.config.when != null ? [{ key: 'when', why: 'its off entries are `off` now', phase: 'first' as const }] : []),
|
|
92
|
-
...(c.config.ruleExempt != null ? [{ key: 'ruleExempt', why: 'its exemptions are `off` now', phase: 'afterOff' as const }] : []),
|
|
93
|
-
],
|
|
94
|
-
name: c.config.name,
|
|
95
|
-
lift: cfg.lift,
|
|
96
|
-
}
|
|
97
|
-
const r = await c.exec([process.execPath, CONFIG_REWRITE, c.root, JSON.stringify(plan)], { cwd: c.root, timeoutMs: 60_000 })
|
|
98
|
-
try {
|
|
99
|
-
const out = JSON.parse(r.out.trim().split('\n').at(-1) ?? '') as ConfigRewrite
|
|
100
|
-
did.push(...out.did)
|
|
101
|
-
hand.push(...out.hand)
|
|
102
|
-
if (out.restored != null) hand.push(`repo.config.ts was left as it was: ${out.restored}`)
|
|
103
|
-
} catch {
|
|
104
|
-
hand.push(`the repo.config.ts rewrite did not answer (exit ${r.code}): write off: ${JSON.stringify({ ...Object.assign({}, ...cfg.lift.map((l) => l.reason)), ...cfg.off })} by hand and drop ${cfg.keys.join(', ')}`)
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
const summary = [did.length > 0 ? did.join('; ') : 'nothing ported', ...(hand.length > 0 ? [`${hand.length} by hand: ${hand.join(' | ')}`] : [])].join('. ')
|
|
108
|
-
return { changed: did.length > 0, summary }
|
|
109
|
-
},
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
export default explicitCheckFiles
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// SK048 the one local file (tools/shipkit/home.md): where this machine's fold of the media index, the agent time index
|
|
2
|
-
// and the daemon's file into the machine db stands (home/machine-fold.ts), said in the house repo only, since it is the machine's and
|
|
3
|
-
// not a repo's. It warns, never fails: a walk stopped half way, a store refused as damaged, a file this code does not
|
|
4
|
-
// read. The fold off is a state the owner may keep, said in its ok line, as the day, the rows and the copies once folded
|
|
5
|
-
import { check } from '../check.ts'
|
|
6
|
-
|
|
7
|
-
export const oneLocalFile = check({
|
|
8
|
-
id: 'SK048',
|
|
9
|
-
blocking: false,
|
|
10
|
-
title: 'the one local file',
|
|
11
|
-
description: "the media index, the agent time index and the daemon's file are tables of the machine db",
|
|
12
|
-
owner: 'tools/shipkit/home.md',
|
|
13
|
-
runs: { onPreCommit: false, onCi: false, onFull: true, onRelease: false, onHealth: true, onSave: false, onClock: false },
|
|
14
|
-
cache: { by: 'never', why: 'it reads the machine db and two lstats, a few ms, and the machine moves outside git' },
|
|
15
|
-
fix: 'none',
|
|
16
|
-
applies: (env) => {
|
|
17
|
-
// a require at the call: the module reads the house index, never at the load of the checks
|
|
18
|
-
const { houseRootOf } = require('../home/home-start.ts') as typeof import('../home/home-start.ts')
|
|
19
|
-
return houseRootOf(env.root) === env.root ? null : "the machine's fold is said in the house repo"
|
|
20
|
-
},
|
|
21
|
-
run: async (c) => {
|
|
22
|
-
const { foldWords } = await import('../home/machine-fold.ts')
|
|
23
|
-
let words: string[]
|
|
24
|
-
try {
|
|
25
|
-
words = foldWords()
|
|
26
|
-
} catch (e) {
|
|
27
|
-
return c.warn(`the machine db does not read, the fold's state is unknown: ${(e as Error).message}`)
|
|
28
|
-
}
|
|
29
|
-
// off is a state the owner may keep; a walk half way, a damaged file or a file this code does not read is not
|
|
30
|
-
const stuck = words.some((w) => /half way|is damaged|shape of before the fold/.test(w))
|
|
31
|
-
if (stuck) for (const w of words) c.warn(w)
|
|
32
|
-
else c.ok(words.join('; '))
|
|
33
|
-
},
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
export default oneLocalFile
|