rvlib-shipkit 2.11.0 → 2.13.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 +56 -12
- package/README.md +1 -1
- package/package.json +4 -2
- package/src/agent-time/store.ts +2 -2
- package/src/check.ts +1 -1
- package/src/checks/SK001-package-json-shape.check.ts +4 -0
- package/src/checks/SK003-claude-md-shape.check.ts +1 -1
- package/src/checks/SK004-gitignore-policy.check.ts +27 -2
- package/src/checks/SK005-rvlib-versions.check.ts +1 -1
- package/src/checks/SK008-reviewer-agent.check.ts +2 -2
- package/src/checks/SK012-config-barrel-import.check.ts +1 -1
- package/src/checks/SK015-nested-repo.check.ts +1 -1
- package/src/checks/SK035-public-clean.check.ts +46 -0
- package/src/checks/SK036-draft-media-size.check.ts +28 -0
- package/src/cli/cmd_Backup.ts +152 -0
- package/src/cli/cmd_Ci.ts +8 -11
- package/src/cli/cmd_Drill.ts +145 -0
- package/src/cli/cmd_Home.ts +50 -3
- package/src/cli/cmd_Media.ts +96 -5
- package/src/cli/cmd_Review.ts +8 -2
- package/src/cli/cmd_Shot.ts +5 -2
- package/src/cli/cmd_Smoke.ts +4 -1
- package/src/cli/cmd_Social.ts +226 -0
- package/src/cli/cmd_Start.ts +1 -1
- package/src/cli/cmd_Time.ts +1 -1
- package/src/cli/cmd_Trailer.ts +9 -2
- package/src/cli/cmd_Veille.ts +173 -0
- package/src/cli/family-pages.ts +3 -0
- package/src/cli/registry.ts +13 -2
- package/src/cli.ts +5 -2
- package/src/collections/actions.ts +1 -49
- package/src/collections/checks.ts +2 -1
- package/src/collections/collection-types.ts +11 -2
- package/src/collections/providers.ts +4 -4
- package/src/collections/review.ts +2 -1
- package/src/collections/tests.ts +19 -8
- package/src/contracts/apply-contracts.ts +1 -3
- package/src/contracts/contract-manifests.ts +2 -3
- package/src/contracts/contract-types.ts +0 -1
- package/src/contracts/contracts-engine.ts +0 -3
- package/src/core/app-icon.ts +9 -3
- package/src/core/bun-builtins.ts +2 -2
- package/src/core/discover-checks.ts +37 -5
- package/src/core/fix-scope.ts +4 -2
- package/src/core/floor-resolve.ts +68 -48
- package/src/core/floor.ts +9 -0
- package/src/core/git-root.ts +24 -0
- package/src/core/last-good.ts +3 -1
- package/src/core/layout.ts +8 -0
- package/src/core/log-stamp.ts +36 -0
- package/src/core/loop-watch.ts +93 -0
- package/src/core/machine-link.ts +134 -0
- package/src/core/memory-watch.ts +41 -0
- package/src/core/one-way-in-policy.ts +27 -19
- package/src/core/run-ci.ts +6 -8
- package/src/core/run-fixers.ts +9 -9
- package/src/core/slots.ts +21 -0
- package/src/core/tree-rev.ts +60 -0
- package/src/core/unit-files.ts +42 -0
- package/src/drill/render.ts +140 -0
- package/src/drill/run.ts +269 -0
- package/src/fleet/scan-fleet.ts +6 -5
- package/src/home/daemon-jobs.ts +201 -0
- package/src/home/global-context.ts +34 -1
- package/src/home/home-routes.ts +22 -15
- package/src/home/hubs.ts +10 -3
- package/src/home/inbox-shape.ts +61 -6
- package/src/home/inbox.ts +75 -4
- package/src/home/lib-watch.ts +10 -3
- package/src/home/machine-stores.ts +15 -29
- package/src/home/run-daemon.ts +15 -18
- package/src/home/run-pm.ts +2 -0
- package/src/home/serve-daemon.ts +4 -3
- package/src/home/serve-web.ts +110 -1
- package/src/hooks/commit-message.ts +28 -19
- package/src/hooks/leak-guard.ts +10 -3
- package/src/hooks/run-hooks.ts +2 -6
- package/src/identities/identities.ts +334 -0
- package/src/identities/machine-route.ts +126 -0
- package/src/identities/machine.ts +62 -0
- package/src/init-repo.ts +1 -1
- package/src/ledger/check-stats.ts +10 -9
- package/src/ledger/gate-checks.ts +32 -1
- package/src/ledger/record-kept.ts +112 -0
- package/src/ledger/repo-view.ts +10 -0
- package/src/ledger/run-log.ts +17 -12
- package/src/ledger/run-timeline.ts +8 -4
- package/src/ledger/store.ts +7 -0
- package/src/ledger/suite-log.ts +17 -13
- package/src/media-kinds.ts +9 -1
- package/src/media-store/backup/daemon.ts +73 -0
- package/src/media-store/backup/keys.ts +25 -0
- package/src/media-store/backup/manifest.ts +193 -0
- package/src/media-store/backup/restore.ts +192 -0
- package/src/media-store/backup/run.ts +278 -0
- package/src/media-store/backup/secret.ts +86 -0
- package/src/media-store/backup/snapshot.ts +64 -0
- package/src/media-store/backup/sources.ts +199 -0
- package/src/media-store/content.ts +11 -1
- package/src/media-store/daemon.ts +56 -70
- package/src/media-store/hand.ts +58 -0
- package/src/media-store/put.ts +122 -0
- package/src/media-store/space.ts +73 -11
- package/src/pages/forward.ts +35 -0
- package/src/pages/frame-client.ts +118 -0
- package/src/pages/routes.ts +29 -0
- package/src/pages/unit.ts +92 -0
- package/src/plan/planner.ts +12 -0
- package/src/plan/repo-source.ts +19 -5
- package/src/reflect/transcript.ts +35 -10
- package/src/release/public-clean.ts +301 -0
- package/src/release/published-here.ts +22 -0
- package/src/release/run-bump.ts +2 -1
- package/src/release/run-release.ts +4 -1
- package/src/repo-config.ts +53 -2
- package/src/review/http.ts +16 -2
- package/src/review/media-kind.ts +3 -3
- package/src/review/media-read.ts +3 -3
- package/src/review/model.ts +24 -5
- package/src/review/notes.ts +77 -0
- package/src/review/project.ts +6 -38
- package/src/review/routes.ts +8 -13
- package/src/review/store.ts +46 -4
- package/src/review/trailer-media.ts +24 -3
- package/src/review/trailer-shots.ts +106 -0
- package/src/review/unit.ts +1 -1
- package/src/scaffold/files/agent-handoff.md +3 -0
- package/src/scaffold/files/agent-index.md +4 -12
- package/src/scaffold/project-scaffold.ts +5 -4
- package/src/serve/embed.ts +1 -1
- package/src/serve/hub-app/col-card.tsx +3 -17
- package/src/serve/hub-app/col-tables-view.tsx +2 -1
- package/src/serve/hub-app/cols-svc.ts +12 -14
- package/src/serve/hub-app/dock-st.ts +4 -2
- package/src/serve/hub-app/dock-view.tsx +2 -0
- package/src/serve/hub-app/frames-st.ts +35 -0
- package/src/serve/hub-app/hash-route.ts +64 -1
- package/src/serve/hub-app/home-st.ts +31 -7
- package/src/serve/hub-app/home-strip.css +9 -1
- package/src/serve/hub-app/home-strip.tsx +7 -6
- package/src/serve/hub-app/home.html +5 -0
- package/src/serve/hub-app/hub-app.tsx +49 -5
- package/src/serve/hub-app/hub.css +29 -11
- package/src/serve/hub-app/icons.tsx +16 -1
- package/src/serve/hub-app/identities-st.ts +210 -0
- package/src/serve/hub-app/identities-view.tsx +352 -0
- package/src/serve/hub-app/identities.css +48 -0
- package/src/serve/hub-app/identity-address.ts +52 -0
- package/src/serve/hub-app/inbox-st.ts +59 -6
- package/src/serve/hub-app/inbox-view.tsx +48 -6
- package/src/serve/hub-app/inbox.css +12 -1
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/keys.ts +10 -2
- package/src/serve/hub-app/list-walk.ts +89 -0
- package/src/serve/hub-app/machine-st.ts +12 -0
- package/src/serve/hub-app/media-view.tsx +2 -1
- package/src/serve/hub-app/pages-frames.tsx +134 -0
- package/src/serve/hub-app/pages-svc.ts +111 -0
- package/src/serve/hub-app/palette-st.ts +18 -3
- package/src/serve/hub-app/palette-view.tsx +9 -2
- package/src/serve/hub-app/planned-view.tsx +2 -1
- package/src/serve/hub-app/project-list.css +18 -14
- package/src/serve/hub-app/project-list.tsx +88 -49
- package/src/serve/hub-app/projects-svc.ts +33 -3
- package/src/serve/hub-app/repo-sections.ts +19 -2
- package/src/serve/hub-app/repo-st.ts +75 -19
- package/src/serve/hub-app/review/review-cells.tsx +3 -3
- package/src/serve/hub-app/review/review-kit.ts +30 -7
- package/src/serve/hub-app/review/review-page.tsx +1 -1
- package/src/serve/hub-app/review/review-st.ts +33 -11
- package/src/serve/hub-app/review/review-thread.tsx +11 -9
- package/src/serve/hub-app/review/review-views.tsx +84 -19
- package/src/serve/hub-app/review/thread-st.ts +1 -10
- package/src/serve/hub-app/review/trailer-page.tsx +2 -1
- package/src/serve/hub-app/review.css +17 -8
- package/src/serve/hub-app/site/site-part.tsx +173 -0
- package/src/serve/hub-app/site/site-st.ts +157 -0
- package/src/serve/hub-app/site.css +35 -0
- package/src/serve/hub-app/social/calendar.tsx +182 -0
- package/src/serve/hub-app/social/comms-page.tsx +306 -0
- package/src/serve/hub-app/social/kit.tsx +244 -0
- package/src/serve/hub-app/social/post-card.tsx +456 -0
- package/src/serve/hub-app/social/problems.tsx +60 -0
- package/src/serve/hub-app/social/social-model.ts +154 -0
- package/src/serve/hub-app/social/social-page.tsx +674 -0
- package/src/serve/hub-app/social/social-st.ts +986 -0
- package/src/serve/hub-app/social.css +289 -0
- package/src/serve/hub-app/stores/stores-page.tsx +311 -0
- package/src/serve/hub-app/stores/stores-st.ts +286 -0
- package/src/serve/hub-app/stores.css +54 -0
- package/src/serve/hub-app/test-view.tsx +9 -2
- package/src/serve/hub-app/tests-svc.ts +16 -1
- package/src/serve/hub-app/timeline-geometry.ts +1 -1
- package/src/serve/hub-app/timeline-view.tsx +3 -2
- package/src/serve/hub-app/tree-build.ts +6 -0
- package/src/serve/hub-app/tree-row.tsx +27 -4
- package/src/serve/hub-app/tree-svc.ts +18 -49
- package/src/serve/hub-app/veille/veille-page.tsx +514 -0
- package/src/serve/hub-app/veille/veille-st.ts +443 -0
- package/src/serve/hub-app/veille.css +84 -0
- package/src/serve/hub-runtime.ts +14 -9
- package/src/serve/project-gutter-route.ts +44 -12
- package/src/serve/resources-wire.ts +48 -0
- package/src/serve/run-lanes.ts +7 -4
- package/src/serve/same-origin.ts +1 -1
- package/src/serve/serve-hub.ts +27 -18
- package/src/serve/tracked-watch.ts +24 -3
- package/src/serve/warm-cell.ts +5 -1
- package/src/shipkit-files.ts +15 -4
- package/src/shipkit.ts +0 -1
- package/src/shot/box.ts +162 -0
- package/src/shot/browser-slot.ts +62 -0
- package/src/shot/client.ts +43 -7
- package/src/shot/clip-encoder.ts +93 -12
- package/src/shot/film-box.ts +188 -0
- package/src/shot/shooter.ts +50 -15
- package/src/shot/shot-ask.ts +10 -2
- package/src/shot/stepped-clip.ts +5 -4
- package/src/site/desk.ts +242 -0
- package/src/site/routes.ts +66 -0
- package/src/site/unit.ts +62 -0
- package/src/social/brands.ts +22 -0
- package/src/social/compose.ts +97 -0
- package/src/social/desk-index.ts +123 -0
- package/src/social/desk-wire.ts +64 -0
- package/src/social/drafts.ts +183 -0
- package/src/social/house.ts +24 -0
- package/src/social/load.ts +319 -0
- package/src/social/md.ts +70 -0
- package/src/social/media-facts.ts +53 -0
- package/src/social/media-kind.ts +189 -0
- package/src/social/media-limit.ts +42 -0
- package/src/social/media-of.ts +30 -0
- package/src/social/migrate.ts +123 -0
- package/src/social/open.ts +17 -0
- package/src/social/post-url.ts +158 -0
- package/src/social/presence.ts +332 -0
- package/src/social/public-read.ts +53 -0
- package/src/social/publish/bluesky.ts +168 -0
- package/src/social/publish/discord.ts +76 -0
- package/src/social/publish/index.ts +24 -0
- package/src/social/publish/secret.ts +13 -0
- package/src/social/push.ts +31 -0
- package/src/social/richtext.ts +37 -0
- package/src/social/routes.ts +180 -0
- package/src/social/stats.ts +134 -0
- package/src/social/text.ts +267 -0
- package/src/social/tracker-route.ts +39 -0
- package/src/social/tracker.ts +255 -0
- package/src/social/unit.ts +53 -0
- package/src/social/writes.ts +130 -0
- package/src/start-repo.ts +14 -9
- package/src/stores/collection.ts +27 -0
- package/src/stores/desk.ts +336 -0
- package/src/stores/model.ts +187 -0
- package/src/stores/routes.ts +126 -0
- package/src/stores/unit.ts +57 -0
- package/src/suite/calibrate.ts +127 -0
- package/src/suite/core-counters.ts +91 -0
- package/src/suite/judge-suites.ts +94 -34
- package/src/suite/suite-cli.ts +44 -10
- package/src/suite/suite-cpu-preload.ts +34 -9
- package/src/trailer/adapter.ts +4 -0
- package/src/trailer/build.ts +42 -11
- package/src/trailer/ffmpeg.ts +11 -0
- package/src/trailer/footage.ts +30 -13
- package/src/trailer/grammar.ts +18 -2
- package/src/trailer/graph.ts +28 -6
- package/src/trailer/passage.ts +21 -6
- package/src/trailer/plan.ts +74 -3
- package/src/trailer/shelf.ts +16 -0
- package/src/trailer/stitch.ts +67 -26
- package/src/trailer/url.ts +1 -1
- package/src/trailer/versions.ts +24 -0
- package/src/ts/gate-typecheck.ts +32 -0
- package/src/ts/typecheck-cli.ts +9 -11
- package/src/tui/tui-app.tsx +0 -1
- package/src/veille/asks.ts +155 -0
- package/src/veille/auto.ts +31 -0
- package/src/veille/batch.ts +27 -0
- package/src/veille/chrome.ts +127 -0
- package/src/veille/collection.ts +28 -0
- package/src/veille/desk.ts +242 -0
- package/src/veille/identity.ts +80 -0
- package/src/veille/import.ts +68 -0
- package/src/veille/log.ts +183 -0
- package/src/veille/platforms.ts +118 -0
- package/src/veille/reads.ts +66 -0
- package/src/veille/replied.ts +110 -0
- package/src/veille/routes.ts +185 -0
- package/src/veille/service.ts +81 -0
- package/src/veille/watch.ts +116 -0
- package/src/veille/worth.ts +46 -0
- package/src/wiki/scan-md.ts +18 -0
- package/src/collections/posts.ts +0 -142
- package/src/contracts/manifests/social.contract.ts +0 -20
- package/src/scaffold/files/agent-coding.md +0 -35
- package/src/ts/typecheck-cache.ts +0 -11
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
// what an npm unit publishes names nothing of the house (wiki build/shipkit/units.md): the file list is npm's own
|
|
2
|
+
// pack list, the words come from the data (house repos, identities, the keyword file), so a new repo or identity is
|
|
3
|
+
// covered the day it exists. A hit reports file:line and the masked word, never the word
|
|
4
|
+
import { createHash } from 'crypto'
|
|
5
|
+
import { existsSync, readdirSync, readFileSync, statSync } from 'fs'
|
|
6
|
+
import { homedir } from 'os'
|
|
7
|
+
import { dirname, join, relative } from 'path'
|
|
8
|
+
import { scanFleet } from '../fleet/scan-fleet.ts'
|
|
9
|
+
import { evaluateLeak, globalAllowFile, globalKeywordFile, leakAllowProblem, loadAllowFile, maskPattern, occurrences, parsePatterns, patternFingerprint, type LoadedAllow } from '../hooks/leak-guard.ts'
|
|
10
|
+
import { readIdentities, type Identities } from '../identities/identities.ts'
|
|
11
|
+
import { KEYWORD_FILE, LAYOUT } from '../core/layout.ts'
|
|
12
|
+
import { parseDirectives, reaches } from '../core/waivers.ts'
|
|
13
|
+
import { fileStamp } from '../core/file-stamp.ts'
|
|
14
|
+
import { gitRoot } from '../core/git-root.ts'
|
|
15
|
+
import { houseIndex, houseRepos } from '../serve/project-gutter.ts'
|
|
16
|
+
import type { RepoConfig } from '../repo-config.ts'
|
|
17
|
+
|
|
18
|
+
/** a word the tarball may not carry, and what it is (never the word itself) */
|
|
19
|
+
export type HouseWord = { word: string; what: string }
|
|
20
|
+
|
|
21
|
+
/** a word the tarball may carry, with why: printed every time it applies */
|
|
22
|
+
export type AllowedWord = { word: string; reason: string }
|
|
23
|
+
|
|
24
|
+
/** reads a file by absolute path, null when absent: the check records each read for its cache, the release reads plainly */
|
|
25
|
+
export type Read = (abs: string) => string | null
|
|
26
|
+
|
|
27
|
+
export const readPlain: Read = (abs) => {
|
|
28
|
+
try {
|
|
29
|
+
return readFileSync(abs, 'utf8')
|
|
30
|
+
} catch {
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** what npm would put in the tarball, unit-relative and sorted: its own pack list, never a guess of it */
|
|
36
|
+
export async function packList(unitDir: string): Promise<{ files: string[] } | { error: string }> {
|
|
37
|
+
const npm = Bun.which('npm')
|
|
38
|
+
if (npm == null) return { error: 'npm is not installed: the pack list is npm\'s own, nothing else can say what ships' }
|
|
39
|
+
const p = Bun.spawn([npm, 'pack', '--dry-run', '--json', '--ignore-scripts'], { cwd: unitDir, stdout: 'pipe', stderr: 'pipe' })
|
|
40
|
+
const [out, err, code] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text(), p.exited])
|
|
41
|
+
if (code !== 0) return { error: `npm pack --dry-run exited ${code}: ${err.trim().split('\n').slice(-2).join(' ')}` }
|
|
42
|
+
try {
|
|
43
|
+
const [packed] = JSON.parse(out) as { files: { path: string }[] }[]
|
|
44
|
+
return { files: (packed?.files ?? []).map((f) => f.path).sort() }
|
|
45
|
+
} catch (e) {
|
|
46
|
+
return { error: `npm pack --dry-run --json printed no pack list (${String(e).slice(0, 120)})` }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** every house repo on this disk by name: the house discovery (archived ones too) and the fleet */
|
|
51
|
+
export function houseRepoWords(root: string, home = homedir()): HouseWord[] {
|
|
52
|
+
const house = houseRepos(root, home)
|
|
53
|
+
const names = new Set([...house.repos, ...house.archived].map((r) => r.name))
|
|
54
|
+
for (const r of scanFleet(dirname(house.home))) names.add(r.name)
|
|
55
|
+
return [...names].sort().map((word) => ({ word, what: 'a house repo' }))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** the identities folder of the house this repo belongs to, null with no house */
|
|
59
|
+
export function houseIdentitiesDir(root: string, home = homedir()): string | null {
|
|
60
|
+
const env = process.env['SHIPKIT_IDENTITIES_DIR']
|
|
61
|
+
if (env) return env
|
|
62
|
+
const index = houseIndex(houseRepos(root, home).home, home)
|
|
63
|
+
const top = index == null ? null : gitRoot(dirname(index))?.top
|
|
64
|
+
return top == null ? null : join(top, LAYOUT.identities)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const host = (url: string): string => {
|
|
68
|
+
try {
|
|
69
|
+
return new URL(url).hostname.replace(/^www\./, '')
|
|
70
|
+
} catch {
|
|
71
|
+
return ''
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** a handle's own part: `@x`, `u/x`, `@x@instance` and `x.bsky.social` are all `x`; a platform host is never a word */
|
|
76
|
+
export function handleWord(handle: string): string {
|
|
77
|
+
const h = handle.trim().replace(/^u\//, '').replace(/^@/, '')
|
|
78
|
+
const user = h.split('@')[0] ?? ''
|
|
79
|
+
return (user.includes('.') ? (user.replace(/^www\./, '').split('.')[0] ?? '') : user).trim()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** every word that names an identity: id, name, site domain, site repo, email, each account's handle */
|
|
83
|
+
export function identityWords(ids: Identities): HouseWord[] {
|
|
84
|
+
const out: HouseWord[] = []
|
|
85
|
+
const add = (word: string, what: string): void => {
|
|
86
|
+
const w = word.trim()
|
|
87
|
+
if (w.length >= 3 && !out.some((x) => x.word.toLowerCase() === w.toLowerCase())) out.push({ word: w, what })
|
|
88
|
+
}
|
|
89
|
+
for (const i of ids.identities) {
|
|
90
|
+
add(i.id, 'an identity id')
|
|
91
|
+
add(i.name, 'an identity name')
|
|
92
|
+
add(host(i.site), 'an identity site domain')
|
|
93
|
+
add(i.siteRepo, 'an identity site repo')
|
|
94
|
+
for (const r of i.rows) if (r.field === 'email') add(r.value, 'an identity email')
|
|
95
|
+
for (const a of i.accounts) {
|
|
96
|
+
add(handleWord(a.handle), 'an identity handle')
|
|
97
|
+
for (const r of a.rows) if (r.field === 'email') add(r.value, 'an identity email')
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return out
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
type Pkg = { name?: string; author?: string | { name?: string }; funding?: string | { url?: string }; repository?: string | { url?: string } } & Partial<Record<'dependencies' | 'devDependencies' | 'peerDependencies' | 'optionalDependencies', Record<string, string>>>
|
|
104
|
+
|
|
105
|
+
const githubOwner = (v: string | { url?: string } | undefined): string | null => /github\.com\/(?:sponsors\/)?([A-Za-z0-9-]+)/.exec(typeof v === 'string' ? v : (v?.url ?? ''))?.[1] ?? null
|
|
106
|
+
|
|
107
|
+
/** what the package itself makes public: its name, its declared author, the packages it names as dependencies */
|
|
108
|
+
export function allowedWords(pkg: Pkg): AllowedWord[] {
|
|
109
|
+
const out: AllowedWord[] = []
|
|
110
|
+
if (pkg.name) out.push({ word: pkg.name, reason: "the package's own name" })
|
|
111
|
+
const author = typeof pkg.author === 'string' ? pkg.author.replace(/\s*[<(].*$/, '') : pkg.author?.name
|
|
112
|
+
for (const a of [author, githubOwner(pkg.funding), githubOwner(pkg.repository)]) if (a) out.push({ word: a, reason: 'the declared author (package.json author, funding, repository)' })
|
|
113
|
+
for (const block of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'] as const)
|
|
114
|
+
for (const d of Object.keys(pkg[block] ?? {})) out.push({ word: d, reason: `a declared dependency (${block}), a public package` })
|
|
115
|
+
const seen = new Set<string>()
|
|
116
|
+
return out.filter((a) => !seen.has(a.word.toLowerCase()) && (seen.add(a.word.toLowerCase()), true))
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const BINARY = /\.(png|jpe?g|gif|webp|ico|woff2?|ttf|eot|otf|zip|gz|wasm|mp3|mp4|ogg|wav|flac|node)$/i
|
|
120
|
+
|
|
121
|
+
/** `directive`: the reason of the in-file `sk-disable-… SK035` that waives the site, null when none does */
|
|
122
|
+
export type PublicSite = { file: string; line: number; masked: string; fingerprint: string; what: string; directive: string | null }
|
|
123
|
+
|
|
124
|
+
export const PUBLIC_CLEAN_ID = 'SK035'
|
|
125
|
+
|
|
126
|
+
export type PublicCleanResult = {
|
|
127
|
+
files: string[]
|
|
128
|
+
hits: PublicSite[]
|
|
129
|
+
/** a file npm would pack that must never ship whatever it says (a browser extension) */
|
|
130
|
+
refused: { file: string; why: string }[]
|
|
131
|
+
allowed: { word: string; reason: string }[]
|
|
132
|
+
waived: { file: string; masked: string; reason: string; source: string }[]
|
|
133
|
+
notes: string[]
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export type PublicCleanInput = {
|
|
137
|
+
/** repo-relative unit dir, '' for the root */
|
|
138
|
+
rel: string
|
|
139
|
+
files: { file: string; content: string }[]
|
|
140
|
+
words: HouseWord[]
|
|
141
|
+
keywordText: string
|
|
142
|
+
allowedWords: AllowedWord[]
|
|
143
|
+
allow: LoadedAllow[]
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const lineAt = (text: string, at: number): number => {
|
|
147
|
+
let n = 1
|
|
148
|
+
for (let i = text.indexOf('\n'); i !== -1 && i < at; i = text.indexOf('\n', i + 1)) n++
|
|
149
|
+
return n
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** the whole decision, with no disk in it */
|
|
153
|
+
export function scanPublic(o: PublicCleanInput): Omit<PublicCleanResult, 'files' | 'notes'> {
|
|
154
|
+
const allowedSet = new Map(o.allowedWords.map((a) => [a.word.toLowerCase(), a.reason]))
|
|
155
|
+
const what = new Map<string, string>()
|
|
156
|
+
const allowed: AllowedWord[] = []
|
|
157
|
+
for (const w of o.words) {
|
|
158
|
+
const k = w.word.toLowerCase()
|
|
159
|
+
if (allowedSet.has(k)) {
|
|
160
|
+
if (!allowed.some((a) => a.word.toLowerCase() === k)) allowed.push({ word: w.word, reason: allowedSet.get(k)! })
|
|
161
|
+
} else if (!what.has(k)) what.set(k, w.what)
|
|
162
|
+
}
|
|
163
|
+
const kw = parsePatterns(o.keywordText)
|
|
164
|
+
// a keyword row the package itself makes public is allowed too, printed masked: the list stays unquotable
|
|
165
|
+
const allowRow = (id: string): boolean => {
|
|
166
|
+
const reason = allowedSet.get(id)
|
|
167
|
+
if (reason != null && !allowed.some((a) => a.word === maskPattern(id))) allowed.push({ word: maskPattern(id), reason: `a keyword row, ${reason}` })
|
|
168
|
+
return reason == null
|
|
169
|
+
}
|
|
170
|
+
const patterns = parsePatterns([...what.keys()].map((w) => `w:${w}`).join('\n'))
|
|
171
|
+
patterns.substrings.push(...kw.substrings.filter(allowRow))
|
|
172
|
+
patterns.words.push(...kw.words.filter((w) => !what.has(w.word) && allowRow(w.word)))
|
|
173
|
+
patterns.regexes.push(...kw.regexes)
|
|
174
|
+
|
|
175
|
+
// an allowed word is one token (a dependency `garden-ui` holds a house word `garden`): blanked to spaces of its
|
|
176
|
+
// length, so lines and offsets stay; a token that goes on as a host (`name.tld`) stays to be scanned
|
|
177
|
+
const tokens = o.allowedWords.map((a) => new RegExp(`(?<![\\p{L}\\p{N}_-]|[\\p{L}\\p{N}]\\.)${a.word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![\\p{L}\\p{N}_-]|\\.[\\p{L}\\p{N}])`, 'giu'))
|
|
178
|
+
const lowerAllowed = o.allowedWords.map((a) => a.word.toLowerCase())
|
|
179
|
+
const blankAllowed = (text: string): string => {
|
|
180
|
+
const lower = text.toLowerCase()
|
|
181
|
+
return tokens.reduce((t, re, i) => (lower.includes(lowerAllowed[i]!) ? t.replace(re, (m) => ' '.repeat(m.length)) : t), text)
|
|
182
|
+
}
|
|
183
|
+
const at = (f: string): string => (o.rel === '' ? f : `${o.rel}/${f}`)
|
|
184
|
+
const refused: PublicCleanResult['refused'] = []
|
|
185
|
+
const targets = []
|
|
186
|
+
for (const f of o.files) {
|
|
187
|
+
if (/(^|\/)manifest\.json$/.test(f.file) && /"manifest_version"\s*:/.test(f.content))
|
|
188
|
+
refused.push({ file: at(f.file), why: 'a browser extension: it is loaded unpacked, never installed from npm' })
|
|
189
|
+
if (!BINARY.test(f.file)) targets.push({ where: 'packed file', file: at(f.file), content: blankAllowed(f.content) })
|
|
190
|
+
}
|
|
191
|
+
const { hits, waived } = evaluateLeak(targets, patterns, o.allow)
|
|
192
|
+
const byFile = new Map(targets.map((t) => [t.file, t.content]))
|
|
193
|
+
const found = new Map<string, Map<string, [number, number][]>>()
|
|
194
|
+
const sites: PublicSite[] = []
|
|
195
|
+
for (const h of hits) {
|
|
196
|
+
const file = h.file!
|
|
197
|
+
const content = byFile.get(file) ?? ''
|
|
198
|
+
if (!found.has(file)) found.set(file, occurrences(content, patterns))
|
|
199
|
+
const lines = new Set((found.get(file)!.get(h.pattern) ?? []).map(([s]) => lineAt(content, s)))
|
|
200
|
+
const label = what.get(h.pattern) ?? 'a keyword row'
|
|
201
|
+
const directives = parseDirectives(file, content).filter((d) => d.reason != null && d.ids.includes(PUBLIC_CLEAN_ID))
|
|
202
|
+
for (const line of [...lines].sort((a, b) => a - b))
|
|
203
|
+
sites.push({ file, line, masked: maskPattern(h.pattern), fingerprint: patternFingerprint(h.pattern), what: label, directive: directives.find((d) => reaches(d, line))?.reason ?? null })
|
|
204
|
+
}
|
|
205
|
+
sites.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line)
|
|
206
|
+
return { hits: sites, refused, allowed, waived: waived.map((w) => ({ file: w.file ?? w.where, masked: maskPattern(w.pattern), reason: w.reason, source: w.source })) }
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** the repo's declared waivers and the machine's, as the commit leak guard loads them */
|
|
210
|
+
export function publicAllow(config: RepoConfig, read: Read): { entries: LoadedAllow[]; notes: string[] } {
|
|
211
|
+
const entries: LoadedAllow[] = []
|
|
212
|
+
const notes: string[] = []
|
|
213
|
+
;(config.hooks?.leakAllow ?? []).forEach((e, i) => {
|
|
214
|
+
const problem = leakAllowProblem(e, `repo.config.ts hooks.leakAllow[${i}]`, true)
|
|
215
|
+
if (problem != null) notes.push(`${problem}, entry IGNORED`)
|
|
216
|
+
else entries.push({ ...e, source: `repo.config.ts hooks.leakAllow[${i}]` })
|
|
217
|
+
})
|
|
218
|
+
const g = globalAllowFile()
|
|
219
|
+
if (g != null && read(g) != null) {
|
|
220
|
+
const loaded = loadAllowFile(g, false)
|
|
221
|
+
entries.push(...loaded.entries)
|
|
222
|
+
notes.push(...loaded.notes)
|
|
223
|
+
}
|
|
224
|
+
return { entries, notes }
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** one unit's tarball against every house word. `read` sees every file the answer depends on */
|
|
228
|
+
export async function publicClean(root: string, config: RepoConfig, unit: { dir: string }, read: Read = readPlain): Promise<PublicCleanResult> {
|
|
229
|
+
const rel = relative(root, unit.dir)
|
|
230
|
+
const notes: string[] = []
|
|
231
|
+
const listed = await packList(unit.dir)
|
|
232
|
+
if ('error' in listed) return { files: [], hits: [], refused: [{ file: rel || '.', why: listed.error }], allowed: [], waived: [], notes }
|
|
233
|
+
const files = listed.files.map((f) => ({ file: f, content: read(join(unit.dir, f)) ?? '' }))
|
|
234
|
+
let pkg: Pkg = {}
|
|
235
|
+
try {
|
|
236
|
+
pkg = JSON.parse(read(join(unit.dir, 'package.json')) ?? '{}') as Pkg
|
|
237
|
+
} catch {
|
|
238
|
+
notes.push(`${rel || '.'}/package.json does not parse: nothing is allowed by name`)
|
|
239
|
+
}
|
|
240
|
+
const kwFiles = [join(root, KEYWORD_FILE), globalKeywordFile()].filter((f): f is string => f != null && read(f) != null)
|
|
241
|
+
if (kwFiles.length === 0) notes.push('no keyword file (.shipkit/private/banned-keywords.txt, here or machine global): its rows are not scanned')
|
|
242
|
+
const idsDir = houseIdentitiesDir(root)
|
|
243
|
+
const ids = idsDir != null && existsSync(idsDir) ? readIdentities(idsDir) : null
|
|
244
|
+
if (ids == null) notes.push('no identities folder in this house: no identity word is scanned')
|
|
245
|
+
else for (const i of ids.identities) for (const f of [i.file, ...i.accounts.map((a) => a.file)]) read(f)
|
|
246
|
+
const allow = publicAllow(config, read)
|
|
247
|
+
notes.push(...allow.notes)
|
|
248
|
+
const scanned = scanPublic({
|
|
249
|
+
rel,
|
|
250
|
+
files,
|
|
251
|
+
words: [...houseRepoWords(root), ...(ids == null ? [] : identityWords(ids))],
|
|
252
|
+
keywordText: kwFiles.map((f) => read(f) ?? '').join('\n'),
|
|
253
|
+
allowedWords: allowedWords(pkg),
|
|
254
|
+
allow: allow.entries,
|
|
255
|
+
})
|
|
256
|
+
return { files: listed.files, notes, ...scanned }
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** the release preflight's refusals: one line a site, the word masked */
|
|
260
|
+
export async function publicCleanBlockers(root: string, config: RepoConfig, unit: { id: string; dir: string; targets: { npm: boolean } }): Promise<string[]> {
|
|
261
|
+
if (!unit.targets.npm) return []
|
|
262
|
+
const r = await publicClean(root, config, unit)
|
|
263
|
+
const sites = [...r.refused.map((x) => `${x.file}: ${x.why}`), ...r.hits.filter((h) => h.directive == null).map((h) => `${h.file}:${h.line}: names ${h.what} (${h.masked}, ${h.fingerprint})`)]
|
|
264
|
+
if (sites.length === 0) return []
|
|
265
|
+
return [`unit '${unit.id}': its tarball names the house (rule SK035, build/shipkit/units.md), ${sites.length} site${sites.length === 1 ? '' : 's'}:\n${sites.slice(0, 20).join('\n')}${sites.length > 20 ? `\n… ${sites.length - 20} more: sk ci --only SK035` : ''}`]
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** every file under `dir` on the disk, ignored ones included (npm packs a gitignored file under `files`), as
|
|
269
|
+
* path, size and mtime; dependency and git folders left out */
|
|
270
|
+
function treeStamp(dir: string, out: string[], base = dir): void {
|
|
271
|
+
let names: string[]
|
|
272
|
+
try {
|
|
273
|
+
names = readdirSync(dir).sort()
|
|
274
|
+
} catch {
|
|
275
|
+
return
|
|
276
|
+
}
|
|
277
|
+
for (const n of names) {
|
|
278
|
+
if (n === 'node_modules' || n === '.git') continue
|
|
279
|
+
const abs = join(dir, n)
|
|
280
|
+
let s
|
|
281
|
+
try {
|
|
282
|
+
s = statSync(abs)
|
|
283
|
+
} catch {
|
|
284
|
+
continue
|
|
285
|
+
}
|
|
286
|
+
if (s.isDirectory()) treeStamp(abs, out, base)
|
|
287
|
+
else out.push(`${relative(base, abs)}:${s.size}:${Math.floor(s.mtimeMs)}`)
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** the cache key part no tracked file carries: each unit's tree on disk, the house repos, the identity files, the
|
|
292
|
+
* keyword and allow files. A new house repo moves it, so the answer never outlives the words it was asked with */
|
|
293
|
+
export function publicCleanKey(root: string, units: { dir: string }[]): string {
|
|
294
|
+
const parts: string[] = []
|
|
295
|
+
for (const u of units) treeStamp(u.dir, parts)
|
|
296
|
+
parts.push(houseRepoWords(root).map((w) => w.word).join(','))
|
|
297
|
+
const ids = houseIdentitiesDir(root)
|
|
298
|
+
if (ids != null) treeStamp(ids, parts)
|
|
299
|
+
for (const f of [join(root, KEYWORD_FILE), globalKeywordFile(), globalAllowFile()]) if (f != null) parts.push(fileStamp(f))
|
|
300
|
+
return createHash('sha256').update(parts.join('\n')).digest('hex').slice(0, 16)
|
|
301
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// the npm versions this machine published, so a fleet run minutes after a
|
|
2
|
+
// release never reads the registry's cached « latest » as the truth: npm's
|
|
3
|
+
// /latest answer lags a publish by minutes, the machine's own record does not
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'
|
|
5
|
+
import { homedir } from 'os'
|
|
6
|
+
import { dirname, join } from 'path'
|
|
7
|
+
|
|
8
|
+
const file = (): string => process.env['SHIPKIT_PUBLISHED_FILE'] || join(homedir(), '.cache', 'shipkit', 'published.json')
|
|
9
|
+
|
|
10
|
+
const read = (): Record<string, string> => {
|
|
11
|
+
try { return existsSync(file()) ? (JSON.parse(readFileSync(file(), 'utf8')) as Record<string, string>) : {} }
|
|
12
|
+
catch { return {} }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function recordPublished(name: string, version: string): void {
|
|
16
|
+
const all = { ...read(), [name]: version }
|
|
17
|
+
mkdirSync(dirname(file()), { recursive: true })
|
|
18
|
+
writeFileSync(file(), JSON.stringify(all, null, 2) + '\n')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** the last version of `name` this machine published, or null */
|
|
22
|
+
export const publishedHere = (name: string): string | null => read()[name] ?? null
|
package/src/release/run-bump.ts
CHANGED
|
@@ -32,6 +32,7 @@ import { join, relative } from 'path'
|
|
|
32
32
|
import { declaredKind, hasUnreleasedNotes, promoteUnreleased } from './changelog.ts'
|
|
33
33
|
import { deriveRemote, dirtyPathList, dirtyPaths, git as gitAt, mergeProbe, remoteTags, tagExistsLocally } from './git-facts.ts'
|
|
34
34
|
import { unitBlockers } from './unit-gate.ts'
|
|
35
|
+
import { publicCleanBlockers } from './public-clean.ts'
|
|
35
36
|
import { releaseScope } from './release-scope.ts'
|
|
36
37
|
import { formatUnitError, releaseOrder, renderTag, resolveUnits, unitById, unitPrepublishScripts, unknownUnit, type ReleaseUnit } from './units.ts'
|
|
37
38
|
import { environmentBlockers, runReleaseGate, releaseUnit } from './run-release.ts'
|
|
@@ -412,7 +413,7 @@ export async function runBump(root: string, config: RepoConfig, kind: BumpKind |
|
|
|
412
413
|
blockers.push(`unit '${unit.id}': tag ${tag} already exists on '${remote.remote}' — that version number is taken, pick another bump`)
|
|
413
414
|
continue
|
|
414
415
|
}
|
|
415
|
-
blockers.push(...unitBlockers(root, config, unit))
|
|
416
|
+
blockers.push(...unitBlockers(root, config, unit), ...(await publicCleanBlockers(root, config, unit)))
|
|
416
417
|
selected.push({ unit, version, changelogRel, kind: unitKind })
|
|
417
418
|
}
|
|
418
419
|
// everything the release needs that does not depend on the new version.
|
|
@@ -13,6 +13,8 @@ import { extractChangelogSection } from './changelog.ts'
|
|
|
13
13
|
import { deriveRemote, dirtyPaths, git, remoteTagState, tagExistsLocally, type RemoteTagState } from './git-facts.ts'
|
|
14
14
|
import { releaseScope } from './release-scope.ts'
|
|
15
15
|
import { publishCommand, unitBlockers, type Publisher } from './unit-gate.ts'
|
|
16
|
+
import { recordPublished } from './published-here.ts'
|
|
17
|
+
import { publicCleanBlockers } from './public-clean.ts'
|
|
16
18
|
import { formatUnitError, resolveUnits, unitById, unknownUnit, type ReleaseUnit } from './units.ts'
|
|
17
19
|
import type { RepoConfig } from '../repo-config.ts'
|
|
18
20
|
import { nestedIn, nestedRefusal } from '../core/nesting.ts'
|
|
@@ -223,7 +225,7 @@ export async function releaseUnit(root: string, config: RepoConfig, unit: Releas
|
|
|
223
225
|
blockers.push(`uncommitted changes in ${scope.describe} (--allow-dirty overrides):\n${dirty.split('\n').slice(0, 10).join('\n')}`)
|
|
224
226
|
if (scope.specs != null) blockers.push('dirt elsewhere in the worktree is deliberately ignored, it cannot reach this tarball or this tag')
|
|
225
227
|
}
|
|
226
|
-
if (o.skipUnitGate !== true) blockers.push(...unitBlockers(root, config, unit))
|
|
228
|
+
if (o.skipUnitGate !== true) blockers.push(...unitBlockers(root, config, unit), ...(await publicCleanBlockers(root, config, unit)))
|
|
227
229
|
|
|
228
230
|
let alreadyPublished = false
|
|
229
231
|
if (wantNpm) {
|
|
@@ -316,6 +318,7 @@ export async function releaseUnit(root: string, config: RepoConfig, unit: Releas
|
|
|
316
318
|
const cmd = publishCommand({ publisher, npmrc, token })
|
|
317
319
|
const p = Bun.spawnSync(cmd.argv, { cwd: unit.dir, env: { ...env, ...cmd.env }, stdout: 'inherit', stderr: 'inherit' })
|
|
318
320
|
if (p.exitCode !== 0) { print(`FAIL: ${publisher} publish failed for ${unit.id} (exit ${p.exitCode})`); return 1 }
|
|
321
|
+
recordPublished(name, version)
|
|
319
322
|
print(`ok: published ${name}@${version}`)
|
|
320
323
|
}
|
|
321
324
|
|
package/src/repo-config.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { RETIRED_CHECK_IDS } from './core/retired-checks.ts'
|
|
|
21
21
|
import { parseWhen } from './core/when.ts'
|
|
22
22
|
import { normalizeVendored, vendoredOfText, vendoredProblem } from './core/vendored.ts'
|
|
23
23
|
import { budgetValueProblem } from './core/budget.ts'
|
|
24
|
+
import { browsersProblem } from './core/slots.ts'
|
|
24
25
|
import type { Rule } from './check.ts'
|
|
25
26
|
import { leakAllowProblems } from './hooks/leak-guard.ts'
|
|
26
27
|
import type { HooksConfig } from './hooks/run-hooks.ts'
|
|
@@ -74,6 +75,24 @@ export type ServeConfig = {
|
|
|
74
75
|
* media store (review cards, trailer cuts...), read only in the house
|
|
75
76
|
* config; its key pair read through `credsReadCommand` */
|
|
76
77
|
mediaSpace?: import('./media-store/space.ts').MediaSpace
|
|
78
|
+
/** the secret whose value is a Cloudflare API token, read through
|
|
79
|
+
* `credsReadCommand`, only in the house config: the site desk asks Pages
|
|
80
|
+
* for a site's last production deployment with it */
|
|
81
|
+
cloudflareToken?: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type RepoBackup = {
|
|
85
|
+
/** files or folders kept whole, an archive over 50 MB included (each file read once: an unchanged size and time
|
|
86
|
+
* is not read again) */
|
|
87
|
+
paths?: string[]
|
|
88
|
+
/** live sqlite files (a glob: `data/*.db`), each a consistent snapshot; `except` leaves rows out per table (a
|
|
89
|
+
* where clause: `{ sessions: '1' }` keeps no login token) */
|
|
90
|
+
sqlite?: (string | {
|
|
91
|
+
/** the live sqlite file, repo relative (a glob matches several) */
|
|
92
|
+
path: string
|
|
93
|
+
/** rows left out of the snapshot, per table: a where clause naming the rows that go */
|
|
94
|
+
except?: Record<string, string>
|
|
95
|
+
})[]
|
|
77
96
|
}
|
|
78
97
|
|
|
79
98
|
export type RepoConfig = {
|
|
@@ -83,8 +102,15 @@ export type RepoConfig = {
|
|
|
83
102
|
name: string
|
|
84
103
|
/** venue ids this repo ships on — selects which contracts are REQUIRED */
|
|
85
104
|
venues?: string[]
|
|
86
|
-
/** social
|
|
105
|
+
/** retired with the v2 social contract: read by nothing; delete the line (`sk social migrate` moves the posts) */
|
|
87
106
|
social?: string[]
|
|
107
|
+
/** the identity that speaks for this repo in public, an id of the house repo's `.shipkit/identities/` (`sk
|
|
108
|
+
* identities`); unset, the one marked `default: true` speaks. A draft may name another (wiki
|
|
109
|
+
* build/shipkit/social.md) */
|
|
110
|
+
speaksAs?: string
|
|
111
|
+
/** machine-only state of this repo the backup keeps beyond its own rule (wiki build/shipkit/media-store.md,
|
|
112
|
+
* Backup, What a repo adds). Paths are repo relative; what git tracks never goes; a secret is refused as always */
|
|
113
|
+
backup?: RepoBackup
|
|
88
114
|
/** prefix for contract fix: pointers (docs checkout or URL) — written by init, never baked in */
|
|
89
115
|
docsBase?: string
|
|
90
116
|
/** a floor slot: a def with a `cmd` or `logic` REPLACES it, and a def
|
|
@@ -287,6 +313,21 @@ export type RepoConfig = {
|
|
|
287
313
|
* visits after a deploy, and how it logs in. The password is a secret
|
|
288
314
|
* NAME: the value never sits in config, argv or env. smoke/run-smoke.ts */
|
|
289
315
|
smoke?: SmokeConfig
|
|
316
|
+
/** what `sk start` does from this repo when it is the house, read only in the house config */
|
|
317
|
+
start?: {
|
|
318
|
+
/** repo names `sk start` never touches: no CLAUDE.md include, no git, no scaffold, no push (a day-job checkout) */
|
|
319
|
+
skip?: string[]
|
|
320
|
+
}
|
|
321
|
+
/** the headless browsers that shoot or record for this repo at once, on any machine (an sk shot ask, a take, a
|
|
322
|
+
* look sheet's tabs, the trailer's films, sk smoke): each holds a slot of the repo's pool for its whole life,
|
|
323
|
+
* and a waiter says whom it waits on. shot/browser-slot.ts */
|
|
324
|
+
browsers?: {
|
|
325
|
+
/** how many at once, a whole number of 1 or more. Default 2 */
|
|
326
|
+
max?: number
|
|
327
|
+
/** the ssh host whose browser films for this repo, like 'wm': on a Mac no browser of the repo starts, every
|
|
328
|
+
* browserSlot there refuses but the box route's own */
|
|
329
|
+
box?: string
|
|
330
|
+
}
|
|
290
331
|
/** the suite budget for a plain `bun test` floor: per suite time limit, the
|
|
291
332
|
* slow suites the quick tier leaves out, and the suites that cannot run in
|
|
292
333
|
* parallel, each with its reason. suite/judge-suites.ts */
|
|
@@ -314,11 +355,12 @@ export type RepoConfig = {
|
|
|
314
355
|
logDir?: string
|
|
315
356
|
}
|
|
316
357
|
|
|
317
|
-
const KNOWN_KEYS = new Set(['name', 'venues', 'social', 'docsBase', 'defaults', 'tasks', 'asks', 'creds', 'credsCommand', 'credsReadCommand', 'notifyCommand', 'contracts', 'gitignore', 'ignoredInputs', 'untrackGenerated', 'nested', 'off', 'when', 'budgets', 'ruleExempt', 'visibility', 'archived', 'reviewer', 'oneWayIn', 'rules', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'checkDefaults', 'tui', 'serve', 'identity', 'logDir', 'smoke', 'tests'])
|
|
358
|
+
const KNOWN_KEYS = new Set(['name', 'venues', 'social', 'speaksAs', 'backup', 'docsBase', 'defaults', 'tasks', 'asks', 'creds', 'credsCommand', 'credsReadCommand', 'notifyCommand', 'contracts', 'gitignore', 'ignoredInputs', 'untrackGenerated', 'nested', 'off', 'when', 'budgets', 'ruleExempt', 'visibility', 'archived', 'reviewer', 'oneWayIn', 'rules', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'checkDefaults', 'tui', 'serve', 'identity', 'logDir', 'smoke', 'tests', 'browsers', 'start'])
|
|
318
359
|
|
|
319
360
|
export function defineRepo(c: RepoConfig): RepoConfig {
|
|
320
361
|
if (typeof c.name !== 'string' || c.name === '') throw new Error('defineRepo: name is required')
|
|
321
362
|
for (const v of c.venues ?? []) if (!/^[a-z0-9-]+$/.test(v)) throw new Error(`defineRepo: venue '${v}' must be kebab-case`)
|
|
363
|
+
if (c.speaksAs != null && !/^[a-z0-9][a-z0-9-]*$/.test(c.speaksAs)) throw new Error(`defineRepo: speaksAs '${String(c.speaksAs)}' must be an identity id, kebab-case (sk identities)`)
|
|
322
364
|
if (c.visibility != null && c.visibility !== 'private' && c.visibility !== 'public')
|
|
323
365
|
throw new Error(`defineRepo: visibility '${String(c.visibility)}' — 'private' or 'public' only`)
|
|
324
366
|
// a half-declared reviewer would lint a path like `.claude/agents/.md`
|
|
@@ -431,6 +473,15 @@ export function defineRepo(c: RepoConfig): RepoConfig {
|
|
|
431
473
|
}
|
|
432
474
|
// a smoke typo would land as a run that visits nothing and exits 0
|
|
433
475
|
if (c.smoke != null) validateSmokeConfig(c.smoke)
|
|
476
|
+
const browsers = browsersProblem(c.browsers)
|
|
477
|
+
if (browsers != null) throw new Error(`defineRepo: ${browsers}`)
|
|
478
|
+
// a malformed skip list would let sk start wire the checkout it exists to leave alone
|
|
479
|
+
if (c.start !== undefined) {
|
|
480
|
+
const skip = (c.start as { skip?: unknown }).skip
|
|
481
|
+
const extra = Object.keys(c.start).filter((k) => k !== 'skip')
|
|
482
|
+
if (extra.length > 0 || (skip !== undefined && !(Array.isArray(skip) && skip.every((n) => typeof n === 'string' && /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(n)))))
|
|
483
|
+
throw new Error(`defineRepo: start is { skip?: <repo names> }, got ${JSON.stringify(c.start)}`)
|
|
484
|
+
}
|
|
434
485
|
// a leak-guard waiver is the one config row that can make a gate quieter,
|
|
435
486
|
// so a malformed one dies here rather than being dropped at commit time
|
|
436
487
|
if (c.hooks?.leakAllow != null) {
|
package/src/review/http.ts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
// the hub's http helpers the review and
|
|
1
|
+
// the hub's http helpers the review, trailer and social routes share: an error answer, the cache headers, a json
|
|
2
|
+
// answer under its ETag, a file with byte ranges
|
|
2
3
|
import { extname } from 'node:path'
|
|
3
4
|
|
|
4
|
-
export const TYPES: Record<string, string> = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.webm': 'video/webm', '.mp4': 'video/mp4' }
|
|
5
|
+
export const TYPES: Record<string, string> = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.webm': 'video/webm', '.mp4': 'video/mp4', '.ico': 'image/x-icon' }
|
|
5
6
|
export const NO_STORE = { 'Cache-Control': 'no-store' }
|
|
6
7
|
/** an item's files never change once written, nor a kept render under its version: a phone keeps what it fetched */
|
|
7
8
|
export const KEEP = { 'Cache-Control': 'private, max-age=86400' }
|
|
8
9
|
|
|
10
|
+
/** a json answer under its ETag: 304 when the page holds it, gzipped when the page takes it and it is worth it. A
|
|
11
|
+
* caller that keeps the answer passes `held`, the zip made once for every page that asks the same tag */
|
|
12
|
+
export function tagged(req: Request, tag: string, body: () => unknown, held?: { tag: string; text: string; zip?: Uint8Array<ArrayBuffer> }): Response {
|
|
13
|
+
const headers = { 'Content-Type': 'application/json', ETag: tag, 'Cache-Control': 'no-cache', Vary: 'Accept-Encoding' }
|
|
14
|
+
if (req.headers.get('If-None-Match') === tag) return new Response(null, { status: 304, headers: { ETag: tag } })
|
|
15
|
+
const kept = held?.tag === tag ? held : null
|
|
16
|
+
const text = kept?.text ?? JSON.stringify(body())
|
|
17
|
+
if (text.length < 4096 || !/\bgzip\b/.test(req.headers.get('Accept-Encoding') ?? '')) return new Response(text, { headers })
|
|
18
|
+
const zip = kept?.zip ?? Bun.gzipSync(new TextEncoder().encode(text))
|
|
19
|
+
if (kept) kept.zip = zip
|
|
20
|
+
return new Response(zip, { headers: { ...headers, 'Content-Encoding': 'gzip' } })
|
|
21
|
+
}
|
|
22
|
+
|
|
9
23
|
export const bad = (e: unknown, status = 400): Response => Response.json({ error: e instanceof Error ? e.message : String(e) }, { status, headers: NO_STORE })
|
|
10
24
|
|
|
11
25
|
/** a file with byte ranges: a player seeks through them */
|
package/src/review/media-kind.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { isUp, recordUp } from '../media-store/remote.ts'
|
|
|
8
8
|
import type { Space } from '../media-store/space.ts'
|
|
9
9
|
import { threadIndex } from './cells.ts'
|
|
10
10
|
import { previewKey, REVIEW_KIND } from './media-read.ts'
|
|
11
|
-
import {
|
|
11
|
+
import { mediaFilesOf } from './model.ts'
|
|
12
12
|
import { previewFile, PREVIEW_W, type PreviewSize } from './previews.ts'
|
|
13
13
|
import { fillMedia, readAll, readAllCached, storeDir, storeStamp } from './store.ts'
|
|
14
14
|
import { membersOf } from './threads.ts'
|
|
@@ -27,7 +27,7 @@ export const reviewMedia: MediaKind = {
|
|
|
27
27
|
for (const x of readAllCached(dir).items) {
|
|
28
28
|
const id = x.item.id
|
|
29
29
|
let item = x.item
|
|
30
|
-
const names =
|
|
30
|
+
const names = mediaFilesOf({ item, thread: x.thread })
|
|
31
31
|
if (names.length === 0) continue
|
|
32
32
|
const size = (n: string): number | undefined => statSync(join(dir, id, n), { throwIfNoEntry: false })?.size
|
|
33
33
|
const lacks = names.some((n) => {
|
|
@@ -63,7 +63,7 @@ export const reviewMedia: MediaKind = {
|
|
|
63
63
|
return (r) => ({ pinned: pinned.has(r.item), used: used.get(r.item) })
|
|
64
64
|
},
|
|
65
65
|
async beforePurge(dir, space, r) {
|
|
66
|
-
if (IMAGE.test(r.name)) await previewsUp(dir, space, r)
|
|
66
|
+
if (IMAGE.test(r.name) && !r.name.startsWith('thread/')) await previewsUp(dir, space, r)
|
|
67
67
|
},
|
|
68
68
|
}
|
|
69
69
|
|
package/src/review/media-read.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { join } from 'node:path'
|
|
|
5
5
|
import { mediaKey } from '../media-store/content.ts'
|
|
6
6
|
import type { MediaFact } from '../media-store/fact.ts'
|
|
7
7
|
import { fetchBack, signedIfUp, signedUrl } from '../media-store/remote.ts'
|
|
8
|
-
import {
|
|
8
|
+
import { ID_RE, isMediaName } from './model.ts'
|
|
9
9
|
|
|
10
10
|
export const REVIEW_KIND = 'review'
|
|
11
11
|
|
|
@@ -16,7 +16,7 @@ export const previewKey = (f: Pick<MediaFact, 'sha'>, size: string): string => `
|
|
|
16
16
|
|
|
17
17
|
/** the fact a head keeps for one of its files, read from its item.json alone */
|
|
18
18
|
export function factOfFile(dir: string, id: string, name: string): MediaFact | null {
|
|
19
|
-
if (!ID_RE.test(id) || !
|
|
19
|
+
if (!ID_RE.test(id) || !isMediaName(name)) return null
|
|
20
20
|
try {
|
|
21
21
|
const head = JSON.parse(readFileSync(join(dir, id, 'item.json'), 'utf8')) as { media?: Record<string, MediaFact> }
|
|
22
22
|
return head.media?.[name] ?? null
|
|
@@ -40,7 +40,7 @@ export async function remotePreviewUrl(dir: string, id: string, name: string, si
|
|
|
40
40
|
/** the path of an item's file on the disk, fetched back from the Space first when the disk let it go; null when neither
|
|
41
41
|
* holds it */
|
|
42
42
|
export async function ensureLocal(dir: string, id: string, name: string): Promise<string | null> {
|
|
43
|
-
if (!ID_RE.test(id) || !
|
|
43
|
+
if (!ID_RE.test(id) || !isMediaName(name)) return null
|
|
44
44
|
const path = join(dir, id, name)
|
|
45
45
|
if (existsSync(path)) return path
|
|
46
46
|
const f = factOfFile(dir, id, name)
|
package/src/review/model.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// is an ITEM, a head (`item.json`: a typed subject, who raised it, the views) and an append only thread of messages
|
|
3
3
|
// (verdicts, replies, ratings, state changes, read marks). The state is derived from the thread, never stored, so the
|
|
4
4
|
// hub and every CLI write at once with no lost update. Pure and browser safe: the store, the routes and the hub page
|
|
5
|
-
// share it. The on disk shape is
|
|
5
|
+
// share it. The on disk shape is the one a project's own review store writes, verbatim, so either store opens in the other.
|
|
6
6
|
import type { MediaFact } from '../media-store/fact.ts'
|
|
7
7
|
|
|
8
8
|
/** WHAT is judged: `shot` (a plain image or clip), `screen`, `frame` (a frame of a trailer cut), or a kind a repo names
|
|
9
|
-
* for itself (
|
|
9
|
+
* for itself (a game's place, creature, song...), read as is */
|
|
10
10
|
export interface Subject {
|
|
11
11
|
kind: string
|
|
12
12
|
[k: string]: unknown
|
|
@@ -28,6 +28,15 @@ export interface FrameSubject extends Subject {
|
|
|
28
28
|
|
|
29
29
|
export const isFrame = (s: Subject): s is FrameSubject => s.kind === 'frame'
|
|
30
30
|
|
|
31
|
+
/** a thing of a store page (wiki build/shipkit/stores.md): a picture by its repo path, or a field as `field:<heading>` */
|
|
32
|
+
export interface StoreSubject extends Subject {
|
|
33
|
+
kind: 'store'
|
|
34
|
+
store: string
|
|
35
|
+
asset: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const isStoreSubject = (s: Subject): s is StoreSubject => s.kind === 'store' && typeof s.store === 'string' && typeof s.asset === 'string'
|
|
39
|
+
|
|
31
40
|
/** what a repo's `review({...})` unit says of one subject kind that the pure model reads (review/unit.ts holds the rest):
|
|
32
41
|
* its words, and on the server its key, its near rule and its problems. The hub gets the words alone */
|
|
33
42
|
export interface SpecKind {
|
|
@@ -57,7 +66,7 @@ export interface Spec {
|
|
|
57
66
|
}
|
|
58
67
|
|
|
59
68
|
/** the kinds every repo has, whatever its unit declares */
|
|
60
|
-
export const BUILTIN_KINDS: Record<string, SpecKind> = { shot: { label: 'images' }, screen: { label: 'screens' }, frame: { label: 'trailer frames' } }
|
|
69
|
+
export const BUILTIN_KINDS: Record<string, SpecKind> = { shot: { label: 'images' }, screen: { label: 'screens' }, frame: { label: 'trailer frames' }, store: { label: 'store pages', icon: '🏪' } }
|
|
61
70
|
|
|
62
71
|
export const NO_SPEC: Spec = { kinds: {}, topics: {}, dispatcher: false }
|
|
63
72
|
|
|
@@ -80,6 +89,7 @@ export type Origin =
|
|
|
80
89
|
export function subjectKey(s: Subject, spec: Spec = NO_SPEC): string | null {
|
|
81
90
|
if (isFrame(s)) return `frame:${s.trailer}/${s.cut}/${s.shot}`
|
|
82
91
|
const kind = spec.kinds[s.kind]
|
|
92
|
+
if (!kind && isStoreSubject(s)) return `store:${s.store}/${s.asset}`
|
|
83
93
|
if (kind) {
|
|
84
94
|
const k = kind.key?.(s)
|
|
85
95
|
return k ? `${s.kind}:${k}` : null
|
|
@@ -106,7 +116,7 @@ export interface ReviewAudio {
|
|
|
106
116
|
waveBefore?: string
|
|
107
117
|
}
|
|
108
118
|
|
|
109
|
-
/** a ring a repo drew over its own shot (
|
|
119
|
+
/** a ring a repo drew over its own shot (a game's world tiles): its center normalized 0..1, its radius as a share of
|
|
110
120
|
* the image width; `side` only on a pair */
|
|
111
121
|
export interface ReviewMark {
|
|
112
122
|
tile: [number, number]
|
|
@@ -650,6 +660,14 @@ export function untakenOf(x: ReviewItem, superseded: boolean, watchers: readonly
|
|
|
650
660
|
|
|
651
661
|
export const ID_RE = /^\d{8}-\d{6}-[a-z0-9-]+$/
|
|
652
662
|
export const FILE_RE = /^((v\d+-)?((image|before|after|poster|wave|before-wave)\.(png|jpe?g|webp)|(video|before|after)\.(webm|mp4)|(audio|before|after)\.(wav|mp3|flac|ogg|opus|m4a))|v\d+-g\d+\.(png|jpe?g|webp))$/
|
|
663
|
+
/** a message's image as an item's media names it: `thread/<file>` */
|
|
664
|
+
export const isThreadMedia = (n: string): boolean => n.startsWith('thread/') && MESSAGE_FILE_RE.test(n.slice('thread/'.length))
|
|
665
|
+
/** a name an item's media may hold: a view's file or a message's image */
|
|
666
|
+
export const isMediaName = (n: string): boolean => FILE_RE.test(n) || isThreadMedia(n)
|
|
667
|
+
/** every file of an item the media store keeps: its views' files, then its messages' images */
|
|
668
|
+
export const mediaFilesOf = (x: { item: Item; thread: readonly Message[] }): string[] => [...viewFilesOf(x.item), ...x.thread.flatMap((m) => (m.image ? [`thread/${m.image}`] : []))]
|
|
669
|
+
/** the message images an item's media already holds: a rewrite of its views keeps their facts */
|
|
670
|
+
export const threadMediaOf = (i: Item): string[] => Object.keys(i.media ?? {}).filter(isThreadMedia)
|
|
653
671
|
const TILE_RE = /^v\d+-g\d+\.(png|jpe?g|webp)$/
|
|
654
672
|
const POSTER_RE = /^(v\d+-)?poster\.png$/
|
|
655
673
|
|
|
@@ -704,6 +722,7 @@ function subjectProblems(s: unknown, spec: Spec): string[] {
|
|
|
704
722
|
const declared = Object.keys(spec.kinds)
|
|
705
723
|
if (!kind && !BUILTIN_KINDS[s.kind] && declared.length > 0) return [`subject: kind « ${s.kind} » is none of ${[...declared, ...Object.keys(BUILTIN_KINDS)].join(', ')}`]
|
|
706
724
|
if (kind?.problems) return kind.problems(s as Subject).map((p) => `subject: ${p}`)
|
|
725
|
+
if (s.kind === 'store' && !kind) return isStoreSubject(s as Subject) && s.store !== '' && s.asset !== '' ? [] : ['subject: a store thing has its store and asset']
|
|
707
726
|
if (s.kind !== 'frame') return []
|
|
708
727
|
const str = (k: string): boolean => typeof s[k] === 'string' && s[k] !== ''
|
|
709
728
|
const num = (k: string): boolean => typeof s[k] === 'number' && Number.isFinite(s[k])
|
|
@@ -757,7 +776,7 @@ export function itemProblems(v: unknown): string[] {
|
|
|
757
776
|
if (!obj(v.media)) out.push('media: { <file name>: { sha, size, type } }, or absent')
|
|
758
777
|
else
|
|
759
778
|
for (const [n, f] of Object.entries(v.media))
|
|
760
|
-
if (!
|
|
779
|
+
if (!isMediaName(n) || !obj(f) || typeof f.sha !== 'string' || !SHA_RE.test(f.sha) || !Number.isInteger(f.size) || (f.size as number) < 0 || typeof f.type !== 'string')
|
|
761
780
|
out.push(`media.${n}: a file of the item, { sha: sha256 hex, size: bytes, type }`)
|
|
762
781
|
}
|
|
763
782
|
return out
|