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,152 @@
|
|
|
1
|
+
// sk backup: the machine-only state of the house kept in the private Space (media-store/backup/, wiki
|
|
2
|
+
// build/shipkit/media-store.md, Backup): a run now, what is not backed up yet, the runs, a restore, the drill.
|
|
3
|
+
// Every module loads inside execute: the cli registers this file on every `sk` call
|
|
4
|
+
import { Command, Option } from 'clipanion'
|
|
5
|
+
|
|
6
|
+
const DETAILS = `the files of the house that no git and no Space keeps (the veille logs, the media index and the machine db as sqlite snapshots, the rail order, the machine's private folder, the agents' memories, each house repo's untracked .shipkit/ files, its hand tuned .comfy-ts/ files, its gitignored *.local.* files, and what its repo.config.ts names under backup: paths kept whole, sqlite files) go up to the owner's private Space under backup/<sha256>, each run under backup/runs/ with its parts under backup/parts/ (a part unchanged since the last run is not written again). Every version stays: nothing is ever deleted. Secrets never go: a file whose name or text says it holds one is refused, with the reason. The daemon runs it on change (debounced) and every 6 h. Page: wiki build/shipkit/media-store.md, Backup`
|
|
7
|
+
|
|
8
|
+
type Ctx = { stdout: NodeJS.WritableStream; stderr: NodeJS.WritableStream }
|
|
9
|
+
|
|
10
|
+
interface Here {
|
|
11
|
+
out: (l: string) => void
|
|
12
|
+
err: (l: string) => void
|
|
13
|
+
home: string
|
|
14
|
+
repos: string[]
|
|
15
|
+
space: import('../media-store/space.ts').Space
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function run(context: Ctx, body: (h: Here) => Promise<number>): Promise<number> {
|
|
19
|
+
const out = (l: string): void => void context.stdout.write(`${l}\n`)
|
|
20
|
+
const err = (l: string): void => void context.stderr.write(`${l}\n`)
|
|
21
|
+
try {
|
|
22
|
+
const { homedir } = await import('node:os')
|
|
23
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
24
|
+
const { houseRepos } = await import('../serve/project-gutter.ts')
|
|
25
|
+
const { machineSpace } = await import('../media-store/space.ts')
|
|
26
|
+
const home = homedir()
|
|
27
|
+
const house = houseRepos(findRepoRoot(process.cwd()), home)
|
|
28
|
+
const repos = [...house.repos, ...house.archived].map((r) => r.path)
|
|
29
|
+
if (repos.length === 0) throw new Error(`no house repo seen from ${process.cwd()}: run it inside one`)
|
|
30
|
+
const { space, why } = await machineSpace()
|
|
31
|
+
if (!space) throw new Error(why)
|
|
32
|
+
return await body({ out, err, home, repos, space })
|
|
33
|
+
} catch (e) {
|
|
34
|
+
err(`FAIL: backup: ${e instanceof Error ? e.message : String(e)}`)
|
|
35
|
+
return 1
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const mb = (b: number): string => `${(b / 1e6).toFixed(1)} MB`
|
|
40
|
+
|
|
41
|
+
export class BackupCommand extends Command {
|
|
42
|
+
static override paths = [['backup']]
|
|
43
|
+
static override usage = Command.Usage({
|
|
44
|
+
category: 'Media',
|
|
45
|
+
description: 'the machine-only state of the house up to the private Space now: every version kept, secrets refused',
|
|
46
|
+
details: `${DETAILS}\n\nA run reads every source, hashes it (a sqlite: a consistent snapshot first), sends each object the Space lacks, then writes ONE manifest (path, sha, size, time of every file), last. A run whose state equals the last one writes nothing. --check sends nothing: it prints what the Space lacks, what changed since the last run, and what is refused, and exits 1 when something waits.`,
|
|
47
|
+
examples: [['back up now', 'sk backup'], ['what is not backed up yet', 'sk backup --check']],
|
|
48
|
+
})
|
|
49
|
+
check = Option.Boolean('--check', false, { description: 'send nothing: what is not backed up yet, exit 1 when something waits' })
|
|
50
|
+
async execute(): Promise<number> {
|
|
51
|
+
return run(this.context, async (h) => {
|
|
52
|
+
const { backupCheck, backupRun } = await import('../media-store/backup/run.ts')
|
|
53
|
+
const refusedLines = (list: { path: string; why: string }[]): void => {
|
|
54
|
+
for (const r of list) h.out(` refused ~/${r.path}: ${r.why}`)
|
|
55
|
+
}
|
|
56
|
+
if (this.check) {
|
|
57
|
+
const c = await backupCheck(h.space, { home: h.home, repos: h.repos })
|
|
58
|
+
h.out(`${c.files} files read; the last run: ${c.last ? `${c.last.at} (${c.last.key})` : 'none'}`)
|
|
59
|
+
h.out(`${c.waiting.length} not in the Space yet (${mb(c.waiting.reduce((n, w) => n + w.size, 0))}), ${c.changed.length} changed since the last run, ${c.refused.length} refused`)
|
|
60
|
+
for (const w of c.waiting.slice(0, 40)) h.out(` waiting ~/${w.path}`)
|
|
61
|
+
if (c.waiting.length > 40) h.out(` … ${c.waiting.length - 40} more`)
|
|
62
|
+
refusedLines(c.refused)
|
|
63
|
+
return c.waiting.length > 0 || c.changed.length > 0 ? 1 : 0
|
|
64
|
+
}
|
|
65
|
+
const t0 = Date.now()
|
|
66
|
+
const r = await backupRun(h.space, { home: h.home, repos: h.repos })
|
|
67
|
+
h.out(`${r.files} files (${mb(r.bytes)}): ${r.sent} objects up (${mb(r.sentBytes)}), ${r.there} already there, ${r.refused.length} refused, in ${((Date.now() - t0) / 1000).toFixed(1)} s`)
|
|
68
|
+
refusedLines(r.refused)
|
|
69
|
+
for (const f of r.failed.slice(0, 5)) h.err(`FAIL: ${f.key}: ${f.error}`)
|
|
70
|
+
if (r.failed.length > 0) {
|
|
71
|
+
h.err(`FAIL: ${r.failed.length} objects did not go up: no manifest written, the next run tries again`)
|
|
72
|
+
return 1
|
|
73
|
+
}
|
|
74
|
+
h.out(r.manifest ? `run ${r.manifest}: ${r.record.partsSent} of ${r.record.parts} parts written (${(r.record.partsBytes / 1e3).toFixed(1)} kB), the run ${(r.record.runBytes / 1e3).toFixed(1)} kB` : `unchanged since ${r.last?.at} (${r.last?.key}): nothing written`)
|
|
75
|
+
return 0
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class BackupRunsCommand extends Command {
|
|
81
|
+
static override paths = [['backup', 'runs']]
|
|
82
|
+
static override usage = Command.Usage({
|
|
83
|
+
category: 'Media',
|
|
84
|
+
description: 'every backup run the Space holds, oldest first: its time and manifest key',
|
|
85
|
+
details: DETAILS,
|
|
86
|
+
examples: [['the runs', 'sk backup runs']],
|
|
87
|
+
})
|
|
88
|
+
async execute(): Promise<number> {
|
|
89
|
+
return run(this.context, async (h) => {
|
|
90
|
+
const { runsOf } = await import('../media-store/backup/manifest.ts')
|
|
91
|
+
const runs = await runsOf(h.space)
|
|
92
|
+
for (const r of runs) h.out(`${r.at.toISOString()} ${r.key} ${(r.size / 1e3).toFixed(0)} kB`)
|
|
93
|
+
h.out(`${runs.length} runs`)
|
|
94
|
+
return 0
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export class BackupRestoreCommand extends Command {
|
|
100
|
+
static override paths = [['backup', 'restore']]
|
|
101
|
+
static override usage = Command.Usage({
|
|
102
|
+
category: 'Media',
|
|
103
|
+
description: 'a backup run written back, every sha checked: to an empty folder, or in place',
|
|
104
|
+
details: `${DETAILS}\n\nThe run is the last one at or before --at (the last one when it is left out). --to writes every file under the folder, at its path under the home (the folder must be empty or new). --in-place writes over the live files: a live file with other bytes is copied to ~/.shipkit/backup-replaced/<time>/ first, and a sqlite lands beside its live file as <file>.restored (stop pm, then move it). --path keeps the files under one path of the home.`,
|
|
105
|
+
examples: [['the last run into a folder', 'sk backup restore --to ~/restore-1'], ['the veille logs as they were on a day, in place', 'sk backup restore --at 2026-11-04 --in-place --path .config/shipkit/home/veille']],
|
|
106
|
+
})
|
|
107
|
+
to = Option.String('--to', { description: 'an empty or new folder the files land under' })
|
|
108
|
+
inPlace = Option.Boolean('--in-place', false, { description: 'over the live files, each one replaced copied aside first' })
|
|
109
|
+
at = Option.String('--at', { description: 'the last run at or before this time: 2026-11-04T13:50Z, 2026-11-04 or 20261104T135000Z' })
|
|
110
|
+
under = Option.String('--path', { description: 'only the files under this path of the home: .config/shipkit/home/veille' })
|
|
111
|
+
async execute(): Promise<number> {
|
|
112
|
+
return run(this.context, async (h) => {
|
|
113
|
+
const { restore } = await import('../media-store/backup/restore.ts')
|
|
114
|
+
const { parseAt } = await import('../media-store/backup/keys.ts')
|
|
115
|
+
const r = await restore(h.space, { home: h.home, ...(this.to !== undefined ? { to: this.to } : {}), inPlace: this.inPlace, ...(this.at ? { at: parseAt(this.at) } : {}), ...(this.under ? { only: this.under } : {}) })
|
|
116
|
+
h.out(`run ${r.at} (${r.run}): ${r.files} files, ${r.written} written (${mb(r.bytes)})${this.inPlace ? `, ${r.same} already the same` : ''}`)
|
|
117
|
+
if (r.aside.n > 0) h.out(`${r.aside.n} live files copied aside first, into ${r.aside.dir}`)
|
|
118
|
+
for (const b of r.beside) h.out(` a sqlite landed beside its live file: ${b} (stop pm, then move it over)`)
|
|
119
|
+
for (const f of r.failed) h.err(`FAIL: ~/${f.path}: ${f.error}`)
|
|
120
|
+
return r.failed.length > 0 ? 1 : 0
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export class BackupDrillCommand extends Command {
|
|
126
|
+
static override paths = [['backup', 'drill']]
|
|
127
|
+
static override usage = Command.Usage({
|
|
128
|
+
category: 'Media',
|
|
129
|
+
description: 'a backup run restored into a scratch folder, every sha compared with the live files',
|
|
130
|
+
details: `${DETAILS}\n\n--at drills an older run (a run of the first version, one manifest, reads too). A file the live machine changed since the run counts apart (the next run takes it), and so does one gone from the disk; a sqlite compares its rows per table. Exit 1 when a file did not come back with its sha. The scratch folder is removed unless --to names one.`,
|
|
131
|
+
examples: [['the drill', 'sk backup drill'], ['an older run', 'sk backup drill --at 20261104T130646Z']],
|
|
132
|
+
})
|
|
133
|
+
to = Option.String('--to', { description: 'restore into this empty or new folder, and keep it' })
|
|
134
|
+
at = Option.String('--at', { description: 'the last run at or before this time, an older run: 2026-11-04T13:50Z or 20261104T135000Z' })
|
|
135
|
+
async execute(): Promise<number> {
|
|
136
|
+
return run(this.context, async (h) => {
|
|
137
|
+
const { drill } = await import('../media-store/backup/restore.ts')
|
|
138
|
+
const { parseAt } = await import('../media-store/backup/keys.ts')
|
|
139
|
+
const t0 = Date.now()
|
|
140
|
+
const d = await drill(h.space, { home: h.home, ...(this.to !== undefined ? { to: this.to } : {}), ...(this.at ? { at: parseAt(this.at) } : {}) })
|
|
141
|
+
h.out(`run ${d.at} (${d.run}, version ${d.v}): ${d.files} files (${mb(d.bytes)}), ${d.restored} restored with their sha, in ${((Date.now() - t0) / 1000).toFixed(1)} s`)
|
|
142
|
+
h.out(`against the live files: ${d.sameAsLive} the same, ${d.liveMoved.length} moved since the run, ${d.liveGone.length} gone from the disk, ${d.failed.length} failed`)
|
|
143
|
+
for (const s of d.sqlite) h.out(` sqlite ~/${s.path}: restored ${JSON.stringify(s.restored)}, live now ${JSON.stringify(s.live)}`)
|
|
144
|
+
for (const p of d.liveMoved.slice(0, 20)) h.out(` moved since ~/${p}`)
|
|
145
|
+
for (const p of d.liveGone.slice(0, 20)) h.out(` gone ~/${p}`)
|
|
146
|
+
for (const f of d.failed) h.err(`FAIL: ~/${f.path}: ${f.error}`)
|
|
147
|
+
return d.failed.length > 0 ? 1 : 0
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export const BACKUP_COMMANDS = [BackupCommand, BackupRunsCommand, BackupRestoreCommand, BackupDrillCommand]
|
package/src/cli/cmd_Ci.ts
CHANGED
|
@@ -18,11 +18,8 @@ export class CiCommand extends Command {
|
|
|
18
18
|
details: 'THE command. Repairs what a machine can (imports, repo shape), then runs every check the gate asks for, through one DAG. A check that declares blocking:false warns instead of failing. Run this instead of anything else.',
|
|
19
19
|
examples: [
|
|
20
20
|
['full gate, mechanical fixes applied', 'sk ci'],
|
|
21
|
-
['gate without the repair pass (checks can still write)', 'sk ci --no-fix'],
|
|
22
|
-
['leave repo config files alone', 'sk ci --no-fix-rules'],
|
|
23
21
|
['stop at the first failure', 'sk ci --bail'],
|
|
24
|
-
['one check + its dep closure,
|
|
25
|
-
['one check, its own repair first', 'sk ci --only SK004 --fix'],
|
|
22
|
+
['one check + its dep closure, its own repair first', 'sk ci --only typecheck'],
|
|
26
23
|
['every check declaring one group', 'sk ci --only wiki'],
|
|
27
24
|
['run everything, take nothing from the cache', 'sk ci --fresh'],
|
|
28
25
|
['include an opt in check', 'sk ci --with up:itch'],
|
|
@@ -33,12 +30,14 @@ export class CiCommand extends Command {
|
|
|
33
30
|
|
|
34
31
|
bail = Option.Boolean('--bail', false, { description: 'stop at the first failure' })
|
|
35
32
|
json = Option.Boolean('--json', false, { description: 'machine-readable result instead of wire lines' })
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
// every run repairs (core/fix-scope.ts). The flags stay accepted and ignored
|
|
34
|
+
// until 2026-11-18, so a session started under the old rule keeps working
|
|
35
|
+
fix = Option.Boolean('--fix', { hidden: true })
|
|
36
|
+
fixRules = Option.Boolean('--fix-rules', true, { hidden: true })
|
|
38
37
|
frozen = Option.Boolean('--frozen', false, { description: 'report-only mode for self-maintaining checks: SK005 never touches package.json, and generated paths are never untracked. STATUS.md is still refreshed on disk, but it is gitignored, so a run leaves the tree clean' })
|
|
39
38
|
skip = Option.Array('--skip', [], { description: 'skip a check group (repeatable)' })
|
|
40
39
|
withIds = Option.Array('--with', [], { description: 'include a check the quick gate leaves out (repeatable)' })
|
|
41
|
-
only = Option.Array('--only', [], { description: 'run only this check + its dep closure (repeatable, or comma separated). A group name runs every check declaring that group.
|
|
40
|
+
only = Option.Array('--only', [], { description: 'run only this check + its dep closure (repeatable, or comma separated). A group name runs every check declaring that group. Repairs only what the named checks own' })
|
|
42
41
|
fresh = Option.Boolean('--fresh', false, { description: 'run every check: no answer comes from the cache, and what this run finds is stored fresh' })
|
|
43
42
|
full = Option.Boolean('--full', false, { description: `run the FULL test tier: every suite the repo declares, the slow ones it skips while you work included. What the release path always runs. Same as SHIPKIT_TEST_FULL=1` })
|
|
44
43
|
|
|
@@ -70,8 +69,6 @@ export class CiCommand extends Command {
|
|
|
70
69
|
return [
|
|
71
70
|
...(this.bail ? ['--bail'] : []),
|
|
72
71
|
...(this.json ? ['--json'] : []),
|
|
73
|
-
...(this.fix === true ? ['--fix'] : this.fix === false ? ['--no-fix'] : []),
|
|
74
|
-
...(this.fixRules ? [] : ['--no-fix-rules']),
|
|
75
72
|
...(this.frozen ? ['--frozen'] : []),
|
|
76
73
|
...this.skip.flatMap((v) => ['--skip', v]),
|
|
77
74
|
...this.withIds.flatMap((v) => ['--with', v]),
|
|
@@ -90,8 +87,7 @@ export class CiCommand extends Command {
|
|
|
90
87
|
const opts = {
|
|
91
88
|
bail: this.bail,
|
|
92
89
|
json: this.json,
|
|
93
|
-
fix:
|
|
94
|
-
fixRules: this.fixRules,
|
|
90
|
+
fix: true,
|
|
95
91
|
armHooks: true,
|
|
96
92
|
frozen: this.frozen,
|
|
97
93
|
skipGroups: this.skip,
|
|
@@ -102,6 +98,7 @@ export class CiCommand extends Command {
|
|
|
102
98
|
...(this.verbose ? { verbose: true } : {}),
|
|
103
99
|
}
|
|
104
100
|
const print = (l: string): void => { this.context.stdout.write(`${l}\n`) }
|
|
101
|
+
if (this.fix === false || !this.fixRules) this.context.stderr.write('note: --no-fix and --no-fix-rules are ignored: every run repairs, a repair is mechanical and safe in a shared tree\n')
|
|
105
102
|
// on a machine with the home, the repo's hub runs it (home/via-hub.ts)
|
|
106
103
|
// a job is already the run, wherever it was started from
|
|
107
104
|
const via = this.job != null ? null : await runViaHub(root, 'ci', opts, { print, printErr: (l) => this.context.stderr.write(`${l}\n`) })
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// `sk drill`: the records of a measured drill (wiki build/speed-up-agents.md). report = one run's transcript
|
|
2
|
+
// as run<n>.json + run<n>.md, verdict = the judged quality added to a run, compare = every run of a drill side
|
|
3
|
+
// by side. It reads transcripts and writes files; it never starts an agent (core/agent-spawn.ts). Exit 0 with
|
|
4
|
+
// the files written, 1 when a transcript or a run is missing or an argument does not parse, 2 on a bad verdict or --out.
|
|
5
|
+
import { Command, Option } from 'clipanion'
|
|
6
|
+
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'fs'
|
|
7
|
+
import { basename, dirname, join, resolve } from 'path'
|
|
8
|
+
|
|
9
|
+
const RUN_FILE = /^run(\d+)\.json$/
|
|
10
|
+
|
|
11
|
+
/** a transcript by path, or by a session or agent id, under every config root */
|
|
12
|
+
async function findTranscript(ref: string): Promise<string | null> {
|
|
13
|
+
if (ref.endsWith('.jsonl')) return existsSync(ref) ? resolve(ref) : null
|
|
14
|
+
const { discoverConfigRoots } = await import('../reflect/prompt-corpus.ts')
|
|
15
|
+
const id = ref.replace(/^agent-/, '')
|
|
16
|
+
for (const root of discoverConfigRoots()) {
|
|
17
|
+
if (!existsSync(root.projects)) continue
|
|
18
|
+
for (const pattern of [`*/${id}.jsonl`, `*/*/subagents/agent-${id}.jsonl`]) {
|
|
19
|
+
for (const hit of new Bun.Glob(pattern).scanSync({ cwd: root.projects, onlyFiles: true })) return join(root.projects, hit)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const writeRun = async (outBase: string, run: import('../drill/run.ts').DrillRun): Promise<void> => {
|
|
26
|
+
const { renderRun } = await import('../drill/render.ts')
|
|
27
|
+
writeFileSync(`${outBase}.json`, JSON.stringify(run, null, 2) + '\n')
|
|
28
|
+
writeFileSync(`${outBase}.md`, renderRun(run, basename(outBase)))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class DrillReportCommand extends Command {
|
|
32
|
+
static override paths = [['drill', 'report']]
|
|
33
|
+
static override usage = Command.Usage({
|
|
34
|
+
category: 'Drill',
|
|
35
|
+
description: 'one drill run read from its transcript: run<n>.json and run<n>.md, numbers, pages read, phases, cost',
|
|
36
|
+
details: [
|
|
37
|
+
'The transcript is a path, or a session or agent id (the agent id an Agent call returns), found under every config root.',
|
|
38
|
+
'Counts calls, turns, failures, searches, reads, tokens and context at end; times the first md page read, the first write and the first check; lists every md page read with when; splits the wall into model and tools like `sk time`.',
|
|
39
|
+
'--root names the run folder, cut from every path so runs in two folders compare. --patch adds the stats of the run diff the method keeps. Text is masked through the leak guard before it is written.',
|
|
40
|
+
].join(' '),
|
|
41
|
+
examples: [
|
|
42
|
+
['a sub-agent run, by its agent id', 'sk drill report a7e0f9cd61f44cfb4 --out .shipkit/plans/20261104-speed-up/form/run1 --root ~/drills/app--form --patch .shipkit/plans/20261104-speed-up/form/run1.patch'],
|
|
43
|
+
['a transcript file', 'sk drill report ~/.claude/projects/x/abc.jsonl --out runs/run1'],
|
|
44
|
+
],
|
|
45
|
+
})
|
|
46
|
+
ref = Option.String({ required: true, name: 'transcript' })
|
|
47
|
+
out = Option.String('--out', { required: true, description: 'the run record, without extension: <dir>/run<n> gets .json and .md' })
|
|
48
|
+
root = Option.String('--root', { description: 'the run folder, cut from every path' })
|
|
49
|
+
patch = Option.String('--patch', { description: 'the run diff, for its stats' })
|
|
50
|
+
|
|
51
|
+
async execute(): Promise<number> {
|
|
52
|
+
const err = this.context.stderr
|
|
53
|
+
const file = await findTranscript(this.ref)
|
|
54
|
+
if (file == null) {
|
|
55
|
+
err.write(`FAIL: no transcript for ${this.ref}: a .jsonl path, or a session or agent id under ~/.claude*/projects\n`)
|
|
56
|
+
return 1
|
|
57
|
+
}
|
|
58
|
+
if (this.patch != null && !existsSync(this.patch)) {
|
|
59
|
+
err.write(`FAIL: --patch ${this.patch} does not exist\n`)
|
|
60
|
+
return 1
|
|
61
|
+
}
|
|
62
|
+
const outDir = dirname(resolve(this.out))
|
|
63
|
+
if (!existsSync(outDir)) {
|
|
64
|
+
err.write(`FAIL: --out ${this.out}: the folder ${outDir} does not exist\n`)
|
|
65
|
+
return 2
|
|
66
|
+
}
|
|
67
|
+
const { drillRun } = await import('../drill/run.ts')
|
|
68
|
+
const { loadMasker } = await import('../agent-time/mask.ts')
|
|
69
|
+
const run = drillRun(readFileSync(file, 'utf8').split('\n'), {
|
|
70
|
+
transcript: file.replace(process.env.HOME ?? '\0', '~'),
|
|
71
|
+
root: this.root == null ? undefined : resolve(this.root.replace(/^~(?=\/)/, process.env.HOME ?? '~')),
|
|
72
|
+
patch: this.patch == null ? undefined : readFileSync(this.patch, 'utf8'),
|
|
73
|
+
mask: loadMasker(process.cwd()),
|
|
74
|
+
})
|
|
75
|
+
const base = resolve(this.out)
|
|
76
|
+
await writeRun(base, run)
|
|
77
|
+
this.context.stdout.write(`ok: ${base}.json and .md: ${run.calls} calls, ${run.turns} turns, ${Math.round(run.wall / 1000)}s, ${run.docs.length} md pages read, ${run.errors} failed\n`)
|
|
78
|
+
return 0
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export class DrillVerdictCommand extends Command {
|
|
83
|
+
static override paths = [['drill', 'verdict']]
|
|
84
|
+
static override usage = Command.Usage({
|
|
85
|
+
category: 'Drill',
|
|
86
|
+
description: 'the judged result added to a drill run: done, quality, tests, design, and its md written again',
|
|
87
|
+
details: 'A saving counts only when the verdict holds, so compare shows these rows beside the speed. Fields: done=<n>/<m>, quality=1-5, tests=ran|written|none, design=ok|wrong, and an optional note=<text> with no comma.',
|
|
88
|
+
examples: [['judge run 2, quoted so a note can hold spaces', 'sk drill verdict .shipkit/plans/20261104-speed-up/form/run2.json "done=3/3,quality=4,tests=ran,design=ok,note=its own endpoint"']],
|
|
89
|
+
})
|
|
90
|
+
run = Option.String({ required: true, name: 'run.json' })
|
|
91
|
+
verdict = Option.String({ required: true, name: 'verdict' })
|
|
92
|
+
|
|
93
|
+
async execute(): Promise<number> {
|
|
94
|
+
const err = this.context.stderr
|
|
95
|
+
if (!existsSync(this.run)) {
|
|
96
|
+
err.write(`FAIL: ${this.run} does not exist: write it with sk drill report first\n`)
|
|
97
|
+
return 1
|
|
98
|
+
}
|
|
99
|
+
const { parseVerdict } = await import('../drill/run.ts')
|
|
100
|
+
const v = parseVerdict(this.verdict)
|
|
101
|
+
if (typeof v === 'string') {
|
|
102
|
+
err.write(`FAIL: ${v}\n`)
|
|
103
|
+
return 2
|
|
104
|
+
}
|
|
105
|
+
const run = JSON.parse(readFileSync(this.run, 'utf8')) as import('../drill/run.ts').DrillRun
|
|
106
|
+
await writeRun(resolve(this.run).replace(/\.json$/, ''), { ...run, verdict: v })
|
|
107
|
+
this.context.stdout.write(`ok: ${this.run}: done ${v.done}, quality ${v.quality}, tests ${v.tests}, design ${v.design}\n`)
|
|
108
|
+
return 0
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export class DrillCompareCommand extends Command {
|
|
113
|
+
static override paths = [['drill', 'compare']]
|
|
114
|
+
static override usage = Command.Usage({
|
|
115
|
+
category: 'Drill',
|
|
116
|
+
description: 'every run of a drill side by side in compare.md: deltas, verdicts, when each md page was read',
|
|
117
|
+
details: 'Reads the run<n>.json records of one task folder in run order and writes compare.md beside them. Flags a run whose prompt differs from the first. A ratio always reads up from 1: "1.7x more", never "0.6x fewer".',
|
|
118
|
+
examples: [['one task of a speed-up drill', 'sk drill compare .shipkit/plans/20261104-speed-up/form']],
|
|
119
|
+
})
|
|
120
|
+
dir = Option.String({ required: true, name: 'dir' })
|
|
121
|
+
|
|
122
|
+
async execute(): Promise<number> {
|
|
123
|
+
const err = this.context.stderr
|
|
124
|
+
const dir = resolve(this.dir)
|
|
125
|
+
if (!existsSync(dir)) {
|
|
126
|
+
err.write(`FAIL: ${this.dir} does not exist\n`)
|
|
127
|
+
return 1
|
|
128
|
+
}
|
|
129
|
+
const labels = readdirSync(dir)
|
|
130
|
+
.map((f) => RUN_FILE.exec(f))
|
|
131
|
+
.filter((m): m is RegExpExecArray => m != null)
|
|
132
|
+
.sort((a, b) => Number(a[1]) - Number(b[1]))
|
|
133
|
+
.map((m) => `run${m[1]}`)
|
|
134
|
+
if (labels.length === 0) {
|
|
135
|
+
err.write(`FAIL: no run<n>.json in ${this.dir}: write each with sk drill report --out ${this.dir}/run<n>\n`)
|
|
136
|
+
return 1
|
|
137
|
+
}
|
|
138
|
+
const { renderCompare } = await import('../drill/render.ts')
|
|
139
|
+
const runs = labels.map((label) => ({ label, run: JSON.parse(readFileSync(join(dir, `${label}.json`), 'utf8')) as import('../drill/run.ts').DrillRun }))
|
|
140
|
+
const out = join(dir, 'compare.md')
|
|
141
|
+
writeFileSync(out, renderCompare(basename(dir), runs))
|
|
142
|
+
this.context.stdout.write(`ok: ${out}: ${runs.length} runs\n`)
|
|
143
|
+
return 0
|
|
144
|
+
}
|
|
145
|
+
}
|
package/src/cli/cmd_Home.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// shipkit pm, daemon, web and gui: the machine's one app. Thin clipanion surface; logic in home/.
|
|
2
2
|
import { Command, Option } from 'clipanion'
|
|
3
3
|
import { LIB_VERSION } from '../core/lib-version.ts'
|
|
4
|
+
import { stampConsole, stampedIo } from '../core/log-stamp.ts'
|
|
4
5
|
import { fileURLToPath } from 'url'
|
|
5
6
|
import { basename } from 'path'
|
|
6
7
|
import { markAutostart } from '../home/autostart.ts'
|
|
@@ -19,6 +20,12 @@ const io = (c: Command) => ({
|
|
|
19
20
|
printErr: (l: string) => c.context.stderr.write(`${l}\n`),
|
|
20
21
|
})
|
|
21
22
|
|
|
23
|
+
/** a long running role's io: its log lines and every console line of the process carry the time */
|
|
24
|
+
const roleIo = (c: Command) => {
|
|
25
|
+
stampConsole()
|
|
26
|
+
return stampedIo(io(c))
|
|
27
|
+
}
|
|
28
|
+
|
|
22
29
|
/** the --port value, undefined when absent, null when it is not a port */
|
|
23
30
|
function portOf(c: Command, raw: string | undefined): number | undefined | null {
|
|
24
31
|
if (raw == null) return undefined
|
|
@@ -48,7 +55,7 @@ export class PmCommand extends Command {
|
|
|
48
55
|
const port = portOf(this, this.port)
|
|
49
56
|
if (port === null) return 1
|
|
50
57
|
if (execPm({ port })) return 0
|
|
51
|
-
return runPm(process.cwd(),
|
|
58
|
+
return runPm(process.cwd(), roleIo(this), { port })
|
|
52
59
|
}
|
|
53
60
|
}
|
|
54
61
|
|
|
@@ -72,7 +79,47 @@ export class DaemonCommand extends Command {
|
|
|
72
79
|
if (port === null) return 1
|
|
73
80
|
// the daemon hosts every hub, image tools included: loaded when it runs
|
|
74
81
|
const { runDaemon } = await import('../home/run-daemon.ts')
|
|
75
|
-
return runDaemon(process.cwd(),
|
|
82
|
+
return runDaemon(process.cwd(), roleIo(this), { port })
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export class DaemonJobCommand extends Command {
|
|
87
|
+
static override paths = [['daemon', 'job']]
|
|
88
|
+
|
|
89
|
+
static override usage = Command.Usage({
|
|
90
|
+
category: 'Serve',
|
|
91
|
+
description: 'a daemon background job now, in this process: backup, retention sweep, media store, global context',
|
|
92
|
+
details: 'what the daemon runs off its loop: it starts each job as this command in a child process, niced, its lines appended to the daemon\'s log, and never runs a job\'s body itself, so a walk, a VACUUM or a hash pass never holds a page. The backup looks every 2 min and runs when its sources moved and held still, the retention sweep runs hourly, the media store passes every 30 s, the global context is written when the stamp of its sources moved. What a job remembers between two runs lives in the machine db. Page: wiki build/shipkit/home.md, Nothing heavy on the daemon\'s loop',
|
|
93
|
+
examples: [
|
|
94
|
+
['a retention sweep now', 'sk daemon job "retention sweep"'],
|
|
95
|
+
['one media store pass', 'sk daemon job "media store"'],
|
|
96
|
+
['the house\'s global context written now', 'sk daemon job "global context"'],
|
|
97
|
+
],
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
id = Option.String({ required: true, name: 'id' })
|
|
101
|
+
|
|
102
|
+
async execute(): Promise<number> {
|
|
103
|
+
const { isJobId, DAEMON_JOBS, runJobBody } = await import('../home/daemon-jobs.ts')
|
|
104
|
+
if (!isJobId(this.id)) {
|
|
105
|
+
this.context.stderr.write(`FAIL: no daemon job ${JSON.stringify(this.id)}: ${DAEMON_JOBS.map((j) => j.id).join(', ')}\n`)
|
|
106
|
+
return 1
|
|
107
|
+
}
|
|
108
|
+
const { homedir } = await import('node:os')
|
|
109
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
110
|
+
// its lines land in the daemon's log: each one stamped and named
|
|
111
|
+
stampConsole()
|
|
112
|
+
const base = stampedIo(io(this))
|
|
113
|
+
const id = this.id
|
|
114
|
+
const named = (l: string): string => (l.includes(`${id}:`) ? l : `${id}: ${l}`)
|
|
115
|
+
const jobIo = { print: (l: string) => base.print(named(l)), printErr: (l: string) => base.printErr(named(l)) }
|
|
116
|
+
try {
|
|
117
|
+
await runJobBody(id, { root: findRepoRoot(process.cwd()), home: homedir(), ...jobIo })
|
|
118
|
+
return 0
|
|
119
|
+
} catch (e) {
|
|
120
|
+
jobIo.printErr(`FAIL: ${(e as Error).message}`)
|
|
121
|
+
return 1
|
|
122
|
+
}
|
|
76
123
|
}
|
|
77
124
|
}
|
|
78
125
|
|
|
@@ -94,7 +141,7 @@ export class WebCommand extends Command {
|
|
|
94
141
|
async execute(): Promise<number> {
|
|
95
142
|
const port = portOf(this, this.port)
|
|
96
143
|
if (port === null) return 1
|
|
97
|
-
return runWeb(
|
|
144
|
+
return runWeb(roleIo(this), { port })
|
|
98
145
|
}
|
|
99
146
|
}
|
|
100
147
|
|
package/src/cli/cmd_Media.ts
CHANGED
|
@@ -20,7 +20,8 @@ async function run(context: Ctx, o: { repo?: string | undefined; kind?: string |
|
|
|
20
20
|
const err = (l: string): void => void context.stderr.write(`${l}\n`)
|
|
21
21
|
try {
|
|
22
22
|
const { findRepoRoot } = await import('../ts/config.ts')
|
|
23
|
-
const {
|
|
23
|
+
const { mediaKinds } = await import('../media-kinds.ts')
|
|
24
|
+
const MEDIA_KINDS = mediaKinds()
|
|
24
25
|
const { existsSync } = await import('node:fs')
|
|
25
26
|
const { basename, dirname, join } = await import('node:path')
|
|
26
27
|
const here = findRepoRoot(process.cwd())
|
|
@@ -40,7 +41,7 @@ async function run(context: Ctx, o: { repo?: string | undefined; kind?: string |
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
const repoOpt = (): string | undefined => Option.String('--repo', { description: 'a sibling repo by name, in place of this one' })
|
|
43
|
-
const kindOpt = (): string | undefined => Option.String('--kind', { description: 'one kind alone: review, trailer' })
|
|
44
|
+
const kindOpt = (): string | undefined => Option.String('--kind', { description: 'one kind alone: review, trailer, or a label sk media put wrote' })
|
|
44
45
|
|
|
45
46
|
export class MediaCommand extends Command {
|
|
46
47
|
static override paths = [['media']]
|
|
@@ -77,7 +78,7 @@ export class MediaUploadCommand extends Command {
|
|
|
77
78
|
category: 'Media',
|
|
78
79
|
description: 'every waiting file of the media store up to the Space now: resumable, dedup by sha',
|
|
79
80
|
details: `${DETAILS}\n\nThe files not hashed yet are hashed first. A file the Space already holds (same key, same size) is only marked up. The daemon does the same in the background; this runs it now, to the end.`,
|
|
80
|
-
examples: [['this repo', 'sk media upload'], ['what
|
|
81
|
+
examples: [['this repo', 'sk media upload'], ['what a project would send of its trailers', 'sk media upload --repo my-game --kind trailer --dry']],
|
|
81
82
|
})
|
|
82
83
|
repo = repoOpt()
|
|
83
84
|
kind = kindOpt()
|
|
@@ -116,7 +117,7 @@ export class MediaPurgeCommand extends Command {
|
|
|
116
117
|
category: 'Media',
|
|
117
118
|
description: 'free the disk of media the Space holds, never a file its kind pins or a recent one',
|
|
118
119
|
details: `${DETAILS}\n\nA file goes only when the index says it is up AND a HEAD answers its size AND its kind agrees (review sends an image's previews up first; trailer checks the file hashes to its key), and never while a process holds it open. Kept: what each kind pins (review: an active card; trailer: the newest render of each cut, a render an open frame note was written on) and every file used in the last --older days (14). Oldest first. A purged file comes back on demand. --auto on lets the daemon purge every kind on its own whenever the disk has under 40 GB free, until it is back over; --auto off stops it.`,
|
|
119
|
-
examples: [['what it would free', 'sk media purge --dry'], ['
|
|
120
|
+
examples: [['what it would free', 'sk media purge --dry'], ['a project\'s trailers, every file that would go', 'sk media purge --repo my-game --kind trailer --dry --list'], ['the daemon purges under 40 GB free', 'sk media purge --auto on']],
|
|
120
121
|
})
|
|
121
122
|
repo = repoOpt()
|
|
122
123
|
kind = kindOpt()
|
|
@@ -161,4 +162,94 @@ export class MediaPurgeCommand extends Command {
|
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
|
|
165
|
+
const PUT_DETAILS = `The one way an agent of any repo keeps a file in the owner's private Space: never call the Space client directly. Each file is kept by its content as <label>/<sha256>.<ext>, private: its index row (its repo, its place, its original name) first, then the upload, checked by a HEAD of its size; a content the Space already holds is only marked. The object never expires and nothing deletes it from the Space; the file stays on the disk, purgeable by the usual rules (sk media purge). A link is signed on the CDN edge and downloads under the file's name; it lasts at most 7d, the SigV4 limit of a signed URL, and sk media link makes a new one at any time. Page: wiki build/shipkit/media-store.md, Put a file from any repo`
|
|
166
|
+
|
|
167
|
+
export class MediaPutCommand extends Command {
|
|
168
|
+
static override paths = [['media', 'put']]
|
|
169
|
+
static override usage = Command.Usage({
|
|
170
|
+
category: 'Media',
|
|
171
|
+
description: 'keep files in the private Space by content, a signed link at most 7 days',
|
|
172
|
+
details: `${PUT_DETAILS}\n\n--json prints one line a file: { key, sha, size, name, url, expires }, url and expires only with --link.`,
|
|
173
|
+
examples: [
|
|
174
|
+
['a file, its key printed', 'sk media put notes.txt'],
|
|
175
|
+
['release zips, a week long link each, as json', 'sk media put dist/a.zip dist/b.zip --kind private-build --link 7d --json'],
|
|
176
|
+
],
|
|
177
|
+
})
|
|
178
|
+
kind = Option.String('--kind', { description: 'the label, the key prefix: lowercase letters, digits, dashes (files)' })
|
|
179
|
+
link = Option.String('--link', { description: 'a signed link for this long: 30m, 2h, 7d (at most 7d)' })
|
|
180
|
+
json = Option.Boolean('--json', false, { description: 'one JSON line a file' })
|
|
181
|
+
files = Option.Rest({ required: 1 })
|
|
182
|
+
async execute(): Promise<number> {
|
|
183
|
+
return run(this.context, {}, async (h) => {
|
|
184
|
+
const { durationS, linkMedia, putMedia } = await import('../media-store/put.ts')
|
|
185
|
+
const { mb } = await import('../media-store/upload.ts')
|
|
186
|
+
const seconds = this.link === undefined ? null : durationS(this.link)
|
|
187
|
+
for (const f of this.files) {
|
|
188
|
+
const p = await putMedia(f, { ...(this.kind !== undefined ? { kind: this.kind } : {}) })
|
|
189
|
+
const l = seconds === null ? null : await linkMedia(p.key, { seconds, name: p.name })
|
|
190
|
+
if (this.json) h.out(JSON.stringify({ key: p.key, sha: p.sha, size: p.size, name: p.name, ...(l ? { url: l.url, expires: l.expires } : {}) }))
|
|
191
|
+
else {
|
|
192
|
+
h.out(`${p.key} ${p.name} ${mb(p.size)} ${p.sent ? 'up' : 'already in the Space'}`)
|
|
193
|
+
if (l) h.out(` ${l.url}\n expires ${l.expires}`)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return 0
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export class MediaLinkCommand extends Command {
|
|
202
|
+
static override paths = [['media', 'link']]
|
|
203
|
+
static override usage = Command.Usage({
|
|
204
|
+
category: 'Media',
|
|
205
|
+
description: 'a fresh signed link to a file the Space holds, by key, sha or path',
|
|
206
|
+
details: `${PUT_DETAILS}\n\nThe reference is a key (<label>/<sha256>.<ext>), a sha (12 hex of it are enough), or a file the store holds. The link downloads under the name the index keeps for it, or --name. --for defaults to 24h, at most 7d. --json prints { key, sha, size, name, url, expires }.`,
|
|
207
|
+
examples: [
|
|
208
|
+
['a link for a day', 'sk media link private-build/<sha>.zip'],
|
|
209
|
+
['a week, under a name, as json', 'sk media link private-build/<sha>.zip --for 7d --name dgen-1.2.0-mac-arm64.zip --json'],
|
|
210
|
+
],
|
|
211
|
+
})
|
|
212
|
+
for = Option.String('--for', { description: 'how long the link lasts: 30m, 2h, 7d (24h, at most 7d)' })
|
|
213
|
+
name = Option.String('--name', { description: 'the file name the link downloads under (the index row\'s name)' })
|
|
214
|
+
json = Option.Boolean('--json', false, { description: 'one JSON line' })
|
|
215
|
+
ref = Option.String({ required: true })
|
|
216
|
+
async execute(): Promise<number> {
|
|
217
|
+
return run(this.context, {}, async (h) => {
|
|
218
|
+
const { durationS, linkMedia } = await import('../media-store/put.ts')
|
|
219
|
+
const l = await linkMedia(this.ref, { seconds: durationS(this.for ?? '24h'), ...(this.name !== undefined ? { name: this.name } : {}) })
|
|
220
|
+
if (this.json) h.out(JSON.stringify(l))
|
|
221
|
+
else h.out(`${l.url}\n ${l.key} ${l.name}, expires ${l.expires}`)
|
|
222
|
+
return 0
|
|
223
|
+
})
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export class MediaVersioningCommand extends Command {
|
|
228
|
+
static override paths = [['media', 'versioning']]
|
|
229
|
+
static override usage = Command.Usage({
|
|
230
|
+
category: 'Media',
|
|
231
|
+
description: "turn on the Space's versioning: a delete from outside can be undone; --check reads it",
|
|
232
|
+
details: `PutBucketVersioning, then GetBucketVersioning to confirm: an object deleted or overwritten from the DigitalOcean dashboard or by a stray key keeps its older version. DigitalOcean offers it through the S3 API only. Once on, it can only be suspended, never turned off. The house key is limited to the bucket's objects and cannot change it: --key names a full access key pair kept once in the keychain for this call. Page: wiki build/shipkit/media-store.md, Versioning`,
|
|
233
|
+
examples: [
|
|
234
|
+
['turn it on', 'sk media versioning'],
|
|
235
|
+
['turn it on with a one time full access key', 'sk media versioning --key rv/shipkit/spaces-admin'],
|
|
236
|
+
['read it', 'sk media versioning --check'],
|
|
237
|
+
],
|
|
238
|
+
})
|
|
239
|
+
check = Option.Boolean('--check', false, { description: 'read the state, change nothing' })
|
|
240
|
+
key = Option.String('--key', { description: 'the secret holding a full access KEY:SECRET pair, in place of the house key' })
|
|
241
|
+
async execute(): Promise<number> {
|
|
242
|
+
return run(this.context, {}, async (h) => {
|
|
243
|
+
const { spaceFromHouse } = await import('../media-store/space.ts')
|
|
244
|
+
const { space, why } = await spaceFromHouse(this.key)
|
|
245
|
+
if (!space) throw new Error(`no Space: ${why}`)
|
|
246
|
+
const before = await space.versioning()
|
|
247
|
+
if (!this.check && before !== 'Enabled') await space.enableVersioning()
|
|
248
|
+
const now = this.check ? before : await space.versioning()
|
|
249
|
+
h.out(`${space.where}: versioning ${now}${this.check || before === now ? '' : ` (was ${before})`}`)
|
|
250
|
+
return this.check || now === 'Enabled' ? 0 : 1
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export const MEDIA_COMMANDS = [MediaCommand, MediaUploadCommand, MediaPurgeCommand, MediaPutCommand, MediaLinkCommand, MediaVersioningCommand]
|
package/src/cli/cmd_Review.ts
CHANGED
|
@@ -374,6 +374,10 @@ export class ReviewShowCommand extends Command {
|
|
|
374
374
|
return 0
|
|
375
375
|
}
|
|
376
376
|
const t = threadOfItem(x.item.id, threadsOf(all.items))
|
|
377
|
+
// the image paths it prints are on the disk: a message image the purge let go comes back first
|
|
378
|
+
const { ensureLocal } = await import('../review/media-read.ts')
|
|
379
|
+
const { membersOf } = await import('../review/threads.ts')
|
|
380
|
+
await Promise.all((t ? membersOf(t) : [x]).flatMap((y) => y.thread.flatMap((m) => (m.image ? [ensureLocal(h.dir, y.item.id, `thread/${m.image}`).catch((e: Error) => h.err(`review: WARN thread/${m.image}: ${e.message}`))] : []))))
|
|
377
381
|
h.out(t && (t.head.item.id === x.item.id || t.answers.length > 0) ? threadDetail(t, h.dir, true, h.say) : detail(x, h.dir, true, false, h.say))
|
|
378
382
|
return 0
|
|
379
383
|
})
|
|
@@ -840,9 +844,11 @@ export class ReviewAutoCommand extends Command {
|
|
|
840
844
|
return run(this.context, async (h) => {
|
|
841
845
|
const { autoLogDir, nextRun, readAutoLog, runRule } = await import('../review/auto.ts')
|
|
842
846
|
const { readAll } = await import('../review/store.ts')
|
|
843
|
-
const
|
|
847
|
+
const { autoRulesOf } = await import('../veille/auto.ts')
|
|
848
|
+
const { dirname } = await import('node:path')
|
|
849
|
+
const rules = autoRulesOf(dirname(dirname(h.dir)), h.unit)
|
|
844
850
|
if (this.verb === undefined) {
|
|
845
|
-
if (rules.length === 0) h.out("no auto rule: the repo's review unit declares none (auto: [...])")
|
|
851
|
+
if (rules.length === 0) h.out("no auto rule: the repo's review unit declares none (auto: [...]), and no Veille names this repo")
|
|
846
852
|
const now = Date.now()
|
|
847
853
|
const ago = (t: number): string => `${Math.round(Math.abs(now - t) / 60_000)} min`
|
|
848
854
|
for (const r of rules) {
|