rvlib-shipkit 2.2.0 → 2.3.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 +38 -0
- package/package.json +1 -1
- package/src/agent-time/mask.ts +43 -0
- package/src/agent-time/render.ts +187 -0
- package/src/agent-time/report.ts +335 -0
- package/src/agent-time/shape.ts +271 -0
- package/src/agent-time/signals.ts +84 -0
- package/src/agent-time/store.ts +379 -0
- package/src/agent-time/timeline.ts +218 -0
- package/src/agent-time/turns.ts +135 -0
- package/src/cli/cmd_Commands.ts +5 -0
- package/src/cli/cmd_Review.ts +948 -0
- package/src/cli/cmd_Time.ts +112 -0
- package/src/cli/cmd_Trailer.ts +259 -6
- package/src/cli/kit/verb.ts +14 -4
- package/src/cli.ts +6 -4
- package/src/collections/collection-types.ts +6 -1
- package/src/collections/providers.ts +3 -0
- package/src/collections/review.ts +70 -0
- package/src/core/layout.ts +2 -0
- package/src/reflect/prompt-corpus.ts +15 -119
- package/src/reflect/transcript.ts +254 -0
- package/src/review/anim.ts +228 -0
- package/src/review/auto.ts +141 -0
- package/src/review/format.ts +150 -0
- package/src/review/http.ts +23 -0
- package/src/review/marks.ts +43 -0
- package/src/review/media.ts +45 -0
- package/src/review/model.ts +854 -0
- package/src/review/project.ts +110 -0
- package/src/review/role.ts +48 -0
- package/src/review/routes.ts +228 -0
- package/src/review/store.ts +1002 -0
- package/src/review/threads.ts +237 -0
- package/src/review/trailer-desk.ts +385 -0
- package/src/review/trailer-model.ts +183 -0
- package/src/review/trailer-routes.ts +136 -0
- package/src/review/unit.ts +165 -0
- package/src/review/watchers.ts +54 -0
- package/src/serve/embed.ts +35 -0
- package/src/serve/hub-app/activity-view.tsx +1 -1
- package/src/serve/hub-app/activity.css +0 -4
- package/src/serve/hub-app/dock-view.tsx +5 -4
- package/src/serve/hub-app/hash-route.ts +28 -1
- package/src/serve/hub-app/header-bar.tsx +3 -1
- package/src/serve/hub-app/home-st.ts +10 -2
- package/src/serve/hub-app/home-strip.tsx +3 -2
- package/src/serve/hub-app/home.html +1 -0
- package/src/serve/hub-app/hub-app.tsx +80 -11
- package/src/serve/hub-app/hub.css +45 -13
- package/src/serve/hub-app/icons.tsx +9 -0
- package/src/serve/hub-app/index.html +1 -0
- package/src/serve/hub-app/insights-view.tsx +4 -3
- package/src/serve/hub-app/keys.ts +14 -10
- package/src/serve/hub-app/layout-st.ts +63 -2
- package/src/serve/hub-app/planned-view.tsx +3 -2
- package/src/serve/hub-app/planned.css +0 -1
- package/src/serve/hub-app/project-list.css +22 -4
- package/src/serve/hub-app/project-list.tsx +41 -8
- package/src/serve/hub-app/projects-svc.ts +4 -0
- package/src/serve/hub-app/repo-sections.ts +15 -3
- package/src/serve/hub-app/repo-st.ts +45 -3
- package/src/serve/hub-app/review/clip-st.ts +208 -0
- package/src/serve/hub-app/review/kind-view.tsx +171 -0
- package/src/serve/hub-app/review/kit.tsx +113 -0
- package/src/serve/hub-app/review/review-answer.tsx +239 -0
- package/src/serve/hub-app/review/review-board.tsx +46 -0
- package/src/serve/hub-app/review/review-list.tsx +156 -0
- package/src/serve/hub-app/review/review-page.tsx +101 -0
- package/src/serve/hub-app/review/review-st.ts +779 -0
- package/src/serve/hub-app/review/review-views.tsx +503 -0
- package/src/serve/hub-app/review/trailer-page.tsx +416 -0
- package/src/serve/hub-app/review/trailer-st.ts +602 -0
- package/src/serve/hub-app/review/trailer-timeline.tsx +207 -0
- package/src/serve/hub-app/review.css +329 -0
- package/src/serve/hub-app/theme-st.ts +56 -0
- package/src/serve/hub-app/tree-build.ts +4 -0
- package/src/serve/hub-app/tree-row.tsx +1 -1
- package/src/serve/hub-app/tree-svc.ts +4 -0
- package/src/serve/hub-runtime.ts +5 -3
- package/src/serve/same-origin.ts +5 -1
- package/src/serve/serve-hub.ts +8 -0
- package/src/shipkit-files.ts +9 -5
- package/src/trailer/adapter.ts +58 -3
- package/src/trailer/build.ts +300 -41
- package/src/trailer/ffmpeg.ts +22 -0
- package/src/trailer/footage.ts +109 -40
- package/src/trailer/grammar.ts +444 -69
- package/src/trailer/graph.ts +199 -14
- package/src/trailer/holes.ts +72 -0
- package/src/trailer/load-unit.ts +20 -3
- package/src/trailer/look.ts +17 -3
- package/src/trailer/passage.ts +129 -0
- package/src/trailer/plan.ts +80 -21
- package/src/trailer/prune.ts +193 -0
- package/src/trailer/score/compose.ts +240 -0
- package/src/trailer/score/dsp.ts +272 -0
- package/src/trailer/score/palette.ts +188 -0
- package/src/trailer/score/pattern.ts +91 -0
- package/src/trailer/score/score.ts +214 -0
- package/src/trailer/score/sound.ts +112 -0
- package/src/trailer/score/synth.ts +361 -0
- package/src/trailer/states.ts +76 -0
- package/src/trailer/stitch.ts +92 -9
- package/src/trailer/titles.ts +123 -18
- package/src/trailer/vocab.ts +23 -4
- package/src/trailer/words.ts +254 -0
package/src/trailer/footage.ts
CHANGED
|
@@ -1,52 +1,96 @@
|
|
|
1
1
|
// the takes on disk: each film line that writes its own take (a project CLI film row, a `film run`, a `film url`) filmed once into
|
|
2
2
|
// `.shipkit/cache/trailer/footage/<key>.<ext>`, a stamp beside it naming the world it was filmed on. A take of an older
|
|
3
3
|
// world is reported, and filmed again only on --refilm. Written aside then renamed, two at once
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { join } from 'node:path'
|
|
4
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs'
|
|
5
|
+
import { tmpdir } from 'node:os'
|
|
6
|
+
import { isAbsolute, join } from 'node:path'
|
|
7
|
+
import type { TrailerFilmLine, TrailerUnit } from './adapter.ts'
|
|
7
8
|
import { duration } from './ffmpeg.ts'
|
|
8
|
-
import type { Trailer } from './grammar.ts'
|
|
9
|
-
import { cliArgv, isTake, runCommand, type Stamp, type Take, type TakeFilm, takeIsStill, takeName, takeSeconds } from './plan.ts'
|
|
9
|
+
import type { Shot, Trailer } from './grammar.ts'
|
|
10
|
+
import { cliArgv, isTake, recipeText, recipeWords, runCommand, type Stamp, specOf, type Take, type TakeFilm, type TakeSpec, takeIsStill, takeName, takeSeconds } from './plan.ts'
|
|
11
|
+
import { statesOf } from './states.ts'
|
|
10
12
|
|
|
11
|
-
export const trailerCache = (root: string, part: 'footage' | 'pieces' | 'titles' | 'sound'): string => join(root, '.shipkit', 'cache', 'trailer', part)
|
|
13
|
+
export const trailerCache = (root: string, part: 'footage' | 'pieces' | 'titles' | 'sound' | 'score'): string => join(root, '.shipkit', 'cache', 'trailer', part)
|
|
12
14
|
|
|
13
|
-
/**
|
|
14
|
-
export
|
|
15
|
+
/** a recipe file a `@<file>` word names: its repo relative path, its text */
|
|
16
|
+
export interface Recipe {
|
|
17
|
+
path: string
|
|
18
|
+
text: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** what a take reads past its line: the recipe files, the repo's trailer unit */
|
|
22
|
+
export interface TakeContext {
|
|
23
|
+
recipes: ReadonlyMap<string, Recipe>
|
|
24
|
+
unit: TrailerUnit | null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** a film line as the unit sees it */
|
|
28
|
+
export function filmLineOf(shot: Shot, f: Extract<TakeFilm, { kind: 'cli' }>, c: Pick<TakeContext, 'recipes'>): TrailerFilmLine {
|
|
29
|
+
const files = Object.fromEntries(recipeWords(f.argv).flatMap((w) => (c.recipes.has(w) ? [[w, c.recipes.get(w)!.text]] : [])))
|
|
30
|
+
return { line: f.line, shot: shot.name, argv: f.argv, output: f.output, files }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** a take's spec and the words it runs: its row's defaults, the unit's `take` over them, each `@<file>` resolved */
|
|
34
|
+
export function specFor(shot: Shot, f: TakeFilm, c: TakeContext): { spec: TakeSpec; argv?: string[] } {
|
|
35
|
+
// a run keys the files it says it reads, by their content
|
|
36
|
+
if (f.kind === 'run') return { spec: specOf(f, Object.fromEntries((f.reads ?? []).map((p) => [`reads:${p}`, c.recipes.get(`reads:${p}`)?.text ?? '']))) }
|
|
37
|
+
if (f.kind !== 'cli') return { spec: specOf(f) }
|
|
38
|
+
const line = filmLineOf(shot, f, c)
|
|
39
|
+
// a declared file word keys its content, and reaches the row as its repo relative path
|
|
40
|
+
const declared = Object.fromEntries((f.files ?? []).flatMap((i) => (c.recipes.has(`file:${f.argv[i]}`) ? [[`file:${f.argv[i]}`, c.recipes.get(`file:${f.argv[i]}`)!.text]] : [])))
|
|
41
|
+
const base = specOf(f, { ...Object.fromEntries(Object.entries(line.files).map(([w, text]) => [w, recipeText(text)])), ...declared })
|
|
42
|
+
const got = c.unit?.take?.({ ...line, version: base.version, length: base.length })
|
|
43
|
+
const spec: TakeSpec = got
|
|
44
|
+
? { ...base, version: got.version ?? base.version, length: got.length ?? base.length, world: got.world ?? null, recipe: got.recipe === undefined ? base.recipe : { recipe: got.recipe, files: (base.recipe as { files?: unknown }).files ?? null } }
|
|
45
|
+
: base
|
|
46
|
+
const files = new Set(f.files ?? [])
|
|
47
|
+
return { spec, argv: f.argv.map((w, i) => (files.has(i) ? (c.recipes.get(`file:${w}`)?.path ?? w) : c.recipes.has(w) ? `@${c.recipes.get(w)!.path}` : w)) }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** every shot's and footage block's take, with its stamp when it was filmed */
|
|
51
|
+
export function takesOf(t: Trailer, root: string, c: TakeContext = { recipes: new Map(), unit: null }): Take[] {
|
|
15
52
|
const dir = trailerCache(root, 'footage')
|
|
16
|
-
return t.shots.flatMap((shot) => {
|
|
53
|
+
return [...t.shots, ...t.footage].flatMap((shot) => {
|
|
17
54
|
const film = shot.film
|
|
18
|
-
if (!isTake(film)) return []
|
|
19
|
-
const
|
|
55
|
+
if (!isTake(film) || shot.broken) return []
|
|
56
|
+
const { spec, argv } = specFor(shot, film, c)
|
|
57
|
+
const file = join(dir, takeName(shot, film, t, spec))
|
|
20
58
|
const stampFile = `${file}.json`
|
|
21
59
|
const stamp = existsSync(file) && existsSync(stampFile) ? (JSON.parse(readFileSync(stampFile, 'utf8')) as Stamp) : null
|
|
22
|
-
return [{ shot, film, file, stamp }]
|
|
60
|
+
return [{ shot, film, file, stamp, spec, ...(argv ? { argv } : {}) }]
|
|
23
61
|
})
|
|
24
62
|
}
|
|
25
63
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
64
|
+
/** a git run's output, null when it fails; no size limit: a big repo lists many files */
|
|
65
|
+
const git = (root: string, args: string[], env?: Record<string, string>): string | null => {
|
|
66
|
+
const r = Bun.spawnSync(['git', ...args], { cwd: root, stdout: 'pipe', stderr: 'pipe', ...(env ? { env: { ...process.env, ...env } } : {}) })
|
|
67
|
+
return r.exitCode === 0 ? r.stdout.toString() : null
|
|
29
68
|
}
|
|
30
69
|
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
70
|
+
/**
|
|
71
|
+
* the world the takes show: every file of the repo as it stands, by its content (`trailer/` and `.shipkit/` left out),
|
|
72
|
+
* or only the `paths` the trailer unit's `stamp` names; a repo with no git: `no-git`. Content addressed: the working
|
|
73
|
+
* tree is staged into a throwaway copy of the index and the staged entries hashed, so the same content dirty or
|
|
74
|
+
* committed is one world, and an edit of the cut alone moves nothing
|
|
75
|
+
*/
|
|
76
|
+
export function worldStamp(root: string, paths?: readonly string[]): string {
|
|
77
|
+
const real = git(root, ['rev-parse', '--git-path', 'index'])
|
|
78
|
+
if (real === null) return 'no-git'
|
|
79
|
+
const spec = paths ? ['--', ...paths] : ['--', '.', ':(exclude)trailer', ':(exclude).shipkit']
|
|
80
|
+
if (paths) for (const p of paths) if (!existsSync(join(root, p))) throw new Error(`the trailer unit's stamp names a path the repo does not hold: ${p}`)
|
|
81
|
+
const index = join(tmpdir(), `sk-world-${process.pid}-${Math.random().toString(36).slice(2)}`)
|
|
82
|
+
try {
|
|
83
|
+
// a copy of the real index keeps git's stat cache: only the files that changed are read again
|
|
84
|
+
const from = isAbsolute(real.trim()) ? real.trim() : join(root, real.trim())
|
|
85
|
+
if (existsSync(from)) copyFileSync(from, index)
|
|
86
|
+
const env = { GIT_INDEX_FILE: index }
|
|
87
|
+
if (git(root, ['add', '-A', ...spec], env) === null) throw new Error('git add into the world\'s throwaway index failed')
|
|
88
|
+
const staged = git(root, ['ls-files', '-s', ...spec], env)
|
|
89
|
+
if (staged === null) throw new Error('git ls-files of the world\'s throwaway index failed')
|
|
90
|
+
return new Bun.CryptoHasher('sha1').update(staged).digest('hex').slice(0, 12)
|
|
91
|
+
} finally {
|
|
92
|
+
rmSync(index, { force: true })
|
|
48
93
|
}
|
|
49
|
-
return h.digest('hex').slice(0, 12)
|
|
50
94
|
}
|
|
51
95
|
|
|
52
96
|
export interface FilmContext {
|
|
@@ -55,6 +99,8 @@ export interface FilmContext {
|
|
|
55
99
|
world: string
|
|
56
100
|
/** the project CLI's argv, null when the repo has none */
|
|
57
101
|
cli: readonly string[] | null
|
|
102
|
+
/** a clip take that drops its picture is filmed again once, then refused (the unit's `holes`) */
|
|
103
|
+
holes?: boolean
|
|
58
104
|
say: (line: string) => void
|
|
59
105
|
}
|
|
60
106
|
|
|
@@ -64,12 +110,33 @@ export async function filmTake(tk: Take, c: FilmContext): Promise<Take> {
|
|
|
64
110
|
const part = tk.file.replace(/(\.\w+)$/, '.part$1')
|
|
65
111
|
rmSync(part, { force: true })
|
|
66
112
|
const t0 = performance.now()
|
|
67
|
-
const seconds = takeSeconds(tk.shot, tk.film)
|
|
113
|
+
const seconds = takeSeconds(tk.shot, tk.film, tk.spec.length)
|
|
68
114
|
const f = tk.film
|
|
69
|
-
const said = f.kind === 'url' ? await urlTake(tk, f, part, seconds, c) : await commandTake(tk, f, part, seconds, c)
|
|
70
|
-
renameSync(part, tk.file)
|
|
71
115
|
const still = takeIsStill(f)
|
|
72
|
-
|
|
116
|
+
let said = ''
|
|
117
|
+
for (let attempt = 1; ; attempt++) {
|
|
118
|
+
said = f.kind === 'url' ? await urlTake(tk, f, part, seconds, c) : await commandTake(tk, f, part, seconds, c)
|
|
119
|
+
if (still || !c.holes) break
|
|
120
|
+
const holes = await (await import('./holes.ts')).takeHoles(part)
|
|
121
|
+
if (holes.length === 0) break
|
|
122
|
+
const where = `the picture drops out on frames ${holes[0]} to ${holes.at(-1)}`
|
|
123
|
+
if (attempt >= 2) {
|
|
124
|
+
rmSync(part, { force: true })
|
|
125
|
+
throw new Error(`shot ${tk.shot.name} (line ${f.line}): ${where}, twice`)
|
|
126
|
+
}
|
|
127
|
+
c.say(` ${tk.shot.name}: ${where}, filmed again`)
|
|
128
|
+
}
|
|
129
|
+
renameSync(part, tk.file)
|
|
130
|
+
const states = statesOf(said)
|
|
131
|
+
const first = (said.split('\n')[0] ?? '').replace(/\s·\sstates \S+/, '').replace(part, '').trim()
|
|
132
|
+
const stamp: Stamp = {
|
|
133
|
+
world: tk.spec.world ?? c.world,
|
|
134
|
+
filmedAt: new Date().toISOString(),
|
|
135
|
+
seconds: still ? 0 : duration(tk.file),
|
|
136
|
+
note: first.slice(0, 200),
|
|
137
|
+
...(states ? { states } : {}),
|
|
138
|
+
...(tk.spec.world ? { fixed: true as const } : {}),
|
|
139
|
+
}
|
|
73
140
|
writeFileSync(`${tk.file}.json`, JSON.stringify(stamp, null, 2))
|
|
74
141
|
c.say(` filmed ${tk.shot.name}: ${still ? 'a still' : `${stamp.seconds.toFixed(2)} s`} in ${((performance.now() - t0) / 1000).toFixed(1)} s`)
|
|
75
142
|
return { ...tk, stamp }
|
|
@@ -78,13 +145,15 @@ export async function filmTake(tk: Take, c: FilmContext): Promise<Take> {
|
|
|
78
145
|
/** a take a command writes at `part` (a `film run`, a project CLI row); what it said, or a throw with its last lines */
|
|
79
146
|
async function commandTake(tk: Take, f: Exclude<TakeFilm, { kind: 'url' }>, part: string, seconds: number | null, c: FilmContext): Promise<string> {
|
|
80
147
|
if (f.kind === 'cli' && c.cli === null) throw new Error(`shot ${tk.shot.name} (line ${f.line}): film ${f.argv.join(' ')} needs the project CLI (the cli script of package.json)`)
|
|
81
|
-
const argv = f.kind === 'run' ? ['sh', '-c', runCommand(f, { out: part, seconds, size: c.t.size, fps: c.t.fps })] : cliArgv(c.cli!, f, part, seconds)
|
|
82
|
-
|
|
148
|
+
const argv = f.kind === 'run' ? ['sh', '-c', runCommand(f, { out: part, seconds, size: c.t.size, fps: c.t.fps })] : cliArgv(c.cli!, f, part, seconds, tk.argv)
|
|
149
|
+
// the cut's frame and rate: a row that films at the cut's size reads them
|
|
150
|
+
const env = { ...process.env, SK_TRAILER_SIZE: `${c.t.size[0]}x${c.t.size[1]}`, SK_TRAILER_FPS: String(c.t.fps) }
|
|
151
|
+
const p = Bun.spawn(argv, { cwd: c.root, stdout: 'pipe', stderr: 'pipe', env })
|
|
83
152
|
const [out, err, code] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text(), p.exited])
|
|
84
153
|
const said = `${out}${err}`.trim()
|
|
85
154
|
if (code !== 0 || !existsSync(part)) {
|
|
86
155
|
rmSync(part, { force: true })
|
|
87
|
-
const shown = f.kind === 'run' ? f.cmd : [...(c.cli ?? []), ...f.argv].join(' ')
|
|
156
|
+
const shown = f.kind === 'run' ? f.cmd : [...(c.cli ?? []), ...(tk.argv ?? f.argv)].join(' ')
|
|
88
157
|
throw new Error(`shot ${tk.shot.name} (line ${f.line}): ${shown} ${code !== 0 ? `exited ${code}` : `wrote no file at its --out`}${said ? `\n${said.split('\n').slice(-8).join('\n')}` : ''}`)
|
|
89
158
|
}
|
|
90
159
|
return said
|