@kriya-ai/harness 0.2.1 → 0.2.3
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/package.json +1 -1
- package/src/edit/core/ffmpeg.js +5 -1
- package/src/edit/core/layout.js +2 -0
- package/src/edit/core/ops.js +71 -4
- package/src/edit/core/project.js +6 -1
- package/src/edit/core/solver.js +27 -12
- package/src/edit/director/ask.js +58 -13
- package/src/edit/director/plan.js +298 -0
- package/src/edit/director/revise.js +207 -12
- package/src/edit/engine/motion.js +59 -16
- package/src/edit/engine/music-bed.js +110 -0
- package/src/edit/engine/reference.js +134 -0
- package/src/edit/engine/sfx.js +63 -0
- package/src/edit/host/client.js +28 -4
- package/src/edit/host/jobs.js +52 -1
- package/src/edit/host/main.js +4 -2
- package/src/edit/host/paths.js +25 -0
- package/src/edit/host/projects.js +187 -16
- package/src/edit/host/server.js +111 -9
- package/src/edit/index/db.js +28 -1
- package/src/edit/index/layers/retakes.js +7 -1
- package/src/edit/loop/make.js +2 -2
- package/src/edit/recipes/reel.js +127 -17
- package/src/edit/runtime/setup.js +12 -8
- package/studio/dist/studio.css +78 -6
- package/studio/dist/studio.js +5 -1
package/src/edit/recipes/reel.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// the lines to drop; the emphasis words), each with a default that needs no model.
|
|
6
6
|
|
|
7
7
|
import { apply } from "../core/ops.js"
|
|
8
|
+
import { solve } from "../core/solver.js"
|
|
8
9
|
import { LOOKS, pages } from "../engine/captions.js"
|
|
9
10
|
import { paperEdit } from "../index/views.js"
|
|
10
11
|
|
|
@@ -22,11 +23,50 @@ export const REEL_TALKING_HEAD = {
|
|
|
22
23
|
notes: "Recipe: a talking-head reel for phones. The first sentence must work on its own as a hook. Keep the speaker's meaning; drop only lines that repeat or wander.",
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
const STRUCK = new Set(["filler", "stutter", "restart"])
|
|
26
|
+
const STRUCK = new Set(["filler", "stutter", "restart", "trimmed"])
|
|
27
|
+
|
|
28
|
+
const clock = (t) => { const s = Math.round(t / (FLICKS / 10)) / 10; return `${Math.floor(s / 60)}:${(s % 60).toFixed(1).padStart(4, "0")}` }
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The person's trims ("remove everything after 0:25"): each word whose middle falls inside a
|
|
32
|
+
* stretch is marked `trimmed`, so the cut lands between words, never inside one (QG-05).
|
|
33
|
+
* @param {{ from: number, to: number }[]} cuts source flicks of `asset`
|
|
34
|
+
*/
|
|
35
|
+
export function trimIndex(index, asset, cuts = []) {
|
|
36
|
+
if (!cuts.length) return { index, trimmed: 0 }
|
|
37
|
+
let trimmed = 0
|
|
38
|
+
const inside = (w) => cuts.some((c) => (w.start + w.end) / 2 >= c.from && (w.start + w.end) / 2 < c.to)
|
|
39
|
+
const words = index.words.map((w) => (w.asset === asset && inside(w) ? (trimmed++, { ...w, flags: [...w.flags, "trimmed"] }) : w))
|
|
40
|
+
return { index: { ...index, words }, trimmed }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Templates' frames: the reel's 9:16 by default; the same cut also makes a landscape, square or 4:5 film. */
|
|
44
|
+
export const FORMATS = {
|
|
45
|
+
"9:16": { width: 1080, height: 1920, preset: "reel-9x16" },
|
|
46
|
+
"16:9": { width: 1920, height: 1080, preset: "landscape-16x9" },
|
|
47
|
+
"1:1": { width: 1080, height: 1080, preset: "square-1x1" },
|
|
48
|
+
"4:5": { width: 1080, height: 1350, preset: "portrait-4x5" },
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Colour looks as FFmpeg renders them: eq, colortemperature, vibrance and vignette. Data, applied by code. */
|
|
52
|
+
export const GRADES = {
|
|
53
|
+
vivid: { saturation: 1.15, gain: 1.06, vibrance: 0.35 },
|
|
54
|
+
cinematic: { saturation: 0.9, gain: 1.12, gamma: 0.95, temperature: 7200, vignette: 0.45 },
|
|
55
|
+
warm: { temperature: 5200, saturation: 1.05, vibrance: 0.2, vignette: 0.2 },
|
|
56
|
+
bright: { lift: 0.04, gamma: 1.1, vibrance: 0.2 },
|
|
57
|
+
mono: { saturation: 0, gain: 1.1, vignette: 0.3 },
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The recipe in the brief's frame: canvas and export follow `brief.format`. */
|
|
61
|
+
export function recipeFor(brief = {}) {
|
|
62
|
+
const format = FORMATS[brief.format] ?? FORMATS["9:16"]
|
|
63
|
+
const base = REEL_TALKING_HEAD
|
|
64
|
+
return { ...base, canvas: { width: format.width, height: format.height }, deliverable: { ...base.deliverable, preset: format.preset, size: { width: format.width, height: format.height } } }
|
|
65
|
+
}
|
|
26
66
|
|
|
27
67
|
/** The recipe's deliverable; with captions asked for, they burn in and the text gates run (ED8). */
|
|
28
68
|
export function deliverableFor(brief = {}) {
|
|
29
|
-
const base =
|
|
69
|
+
const base = recipeFor(brief).deliverable
|
|
30
70
|
return LOOKS[brief.captions] ? { ...base, burnCaptions: true, gates: [...base.gates, "QG-08", "QG-09", "QG-10"].sort() } : base
|
|
31
71
|
}
|
|
32
72
|
|
|
@@ -105,16 +145,19 @@ const STORY_SCHEMA = {
|
|
|
105
145
|
required: ["hook", "drop"],
|
|
106
146
|
additionalProperties: false,
|
|
107
147
|
}
|
|
108
|
-
const EMPHASIS_SCHEMA = { type: "object", properties: { emphasis: { type: "array", maxItems:
|
|
148
|
+
const EMPHASIS_SCHEMA = { type: "object", properties: { emphasis: { type: "array", maxItems: 8, items: { type: "string", maxLength: 64 } } }, required: ["emphasis"], additionalProperties: false }
|
|
109
149
|
|
|
110
150
|
/**
|
|
111
151
|
* Plans the reel as operations on `project` (which keeps its assets; its cut is replaced).
|
|
112
152
|
* @param {{ project: object, index: object, asset: string, ask: Function, brief?: object, variant?: { tighter?: number, noHook?: boolean }, signal?: AbortSignal }} input
|
|
113
153
|
* @returns {Promise<{ ops: object[], project: object, notes: string[], calls: number, slots: Record<string, string> }>}
|
|
114
154
|
*/
|
|
115
|
-
export async function planReel({ project, index, asset, ask, brief = {}, variant = {}, signal }) {
|
|
116
|
-
const recipe =
|
|
155
|
+
export async function planReel({ project, index: fullIndex, asset, ask, brief = {}, variant = {}, signal }) {
|
|
156
|
+
const recipe = recipeFor(brief)
|
|
117
157
|
const notes = []
|
|
158
|
+
const cuts = (brief.cuts ?? []).filter((c) => Number.isFinite(c.from) && Number.isFinite(c.to) && c.to > c.from)
|
|
159
|
+
const { index, trimmed } = trimIndex(fullIndex, asset, cuts)
|
|
160
|
+
if (cuts.length) notes.push(`Trimmed ${cuts.map((c) => `${clock(c.from)} to ${clock(c.to)}`).join(", ")} of the take, as you asked (${trimmed} word${trimmed === 1 ? "" : "s"}, cut between words).`)
|
|
118
161
|
const slots = {}
|
|
119
162
|
let calls = 0
|
|
120
163
|
const lines = candidateLines(index, asset, brief.picks)
|
|
@@ -137,7 +180,9 @@ export async function planReel({ project, index, asset, ask, brief = {}, variant
|
|
|
137
180
|
calls += story.calls
|
|
138
181
|
slots.story = story.source
|
|
139
182
|
if (story.reason) notes.push(`Story: ${story.reason} Kept every line, in order.`)
|
|
140
|
-
|
|
183
|
+
// A hook the person approved in the Director's plan wins over the model's pick
|
|
184
|
+
const planned = typeof brief.hook === "string" && lines.some((l) => l.id === brief.hook) ? brief.hook : null
|
|
185
|
+
const hook = variant.noHook ? null : (planned ?? story.value.hook)
|
|
141
186
|
let chosen = lines.filter((l) => !story.value.drop.includes(l.id) || mustKeep.includes(l.id))
|
|
142
187
|
|
|
143
188
|
// Length: fit under the maximum, the hook and must-keeps always in
|
|
@@ -145,24 +190,42 @@ export async function planReel({ project, index, asset, ask, brief = {}, variant
|
|
|
145
190
|
const required = new Set([...mustKeep, ...(hook ? [hook] : [])])
|
|
146
191
|
if (chosen.reduce((sum, l) => sum + lengthOf(l), 0) > max) chosen = fitLines(chosen, max, required)
|
|
147
192
|
const total = chosen.reduce((sum, l) => sum + lengthOf(l), 0)
|
|
148
|
-
|
|
193
|
+
// Short footage sets the length: a 29 s take makes a 29 s cut, not a cut that "needs you"
|
|
194
|
+
// for missing a 30 s target nobody can meet (found in use)
|
|
195
|
+
const asked = brief.targetDuration ?? recipe.target.default
|
|
196
|
+
const target = total > 0 && total < asked ? total : asked
|
|
197
|
+
if (target < asked) notes.push(`The footage gives ${(total / FLICKS).toFixed(1)} s of usable speech, so the cut is that long (you asked for about ${Math.round(asked / FLICKS)} s).`)
|
|
149
198
|
if (hook && chosen.some((l) => l.id === hook)) chosen = [chosen.find((l) => l.id === hook), ...chosen.filter((l) => l.id !== hook)]
|
|
150
199
|
if (hook && chosen[0]?.id === hook && lines[0]?.id !== hook) notes.push(`Moved "${hook}" to the front as the hook.`)
|
|
151
200
|
|
|
152
201
|
// The cut: replace whatever is there with the kept runs
|
|
153
202
|
const sequence = project.sequences.find((q) => q.id === project.active)
|
|
154
203
|
const base = new Set(sequence.tracks.filter((t) => t.role === "base").map((t) => t.id))
|
|
204
|
+
// The last cut's captions and music go with it: they hang on its words, and a second
|
|
205
|
+
// make left them all on screen twice (found in use, 2026-11-09)
|
|
206
|
+
const rebuilt = new Set(sequence.tracks.filter((t) => ["base", "caption", "music"].includes(t.role)).map((t) => t.id))
|
|
155
207
|
const ops = [
|
|
156
|
-
...sequence.clips.filter((c) =>
|
|
157
|
-
{ op: "set_brief", format: recipe.id, targetDuration:
|
|
208
|
+
...sequence.clips.filter((c) => rebuilt.has(c.track)).map((c) => ({ op: "ripple_delete", clip: c.id })),
|
|
209
|
+
{ op: "set_brief", format: recipe.id, targetDuration: target, mustKeep: brief.mustKeep ?? [], mustCut: brief.mustCut ?? [], effort: brief.effort ?? "best", ...(brief.language ? { language: brief.language } : {}) },
|
|
158
210
|
{ op: "set_format", width: recipe.canvas.width, height: recipe.canvas.height, fps: recipe.deliverable.fps },
|
|
159
211
|
...(project.deliverables.some((d) => d.preset === recipe.deliverable.preset) ? [] : [{ op: "add_deliverable", ...deliverableFor(brief) }]),
|
|
160
212
|
]
|
|
161
213
|
for (const line of chosen) for (const run of runsOf(line)) ops.push({ op: "keep_range", asset, from: { word: run[0].id, edge: "start" }, to: { word: run.at(-1).id, edge: "end" } })
|
|
214
|
+
// A cold open: a later moment first (an echo, so captions stay on the moment), in black and white
|
|
215
|
+
const takeWords = new Set(index.words.filter((w) => w.asset === asset).map((w) => w.id))
|
|
216
|
+
const cutOut = new Set(index.words.filter((w) => w.flags.includes("trimmed")).map((w) => w.id))
|
|
217
|
+
const coldTrimmed = brief.coldOpen && index.words.some((w) => cutOut.has(w.id) && w.asset === asset && w.start >= (index.words.find((x) => x.id === brief.coldOpen.from)?.start ?? Infinity) && w.end <= (index.words.find((x) => x.id === brief.coldOpen.to)?.end ?? -Infinity))
|
|
218
|
+
if (coldTrimmed) notes.push("No cold open: its moment is inside a stretch you asked to trim.")
|
|
219
|
+
const cold = !coldTrimmed && brief.coldOpen && takeWords.has(brief.coldOpen.from) && takeWords.has(brief.coldOpen.to) ? brief.coldOpen : null
|
|
220
|
+
if (cold) {
|
|
221
|
+
ops.push({ op: "cold_open", asset, from: { word: cold.from, edge: "start" }, to: { word: cold.to, edge: "end" }, mono: cold.mono !== false })
|
|
222
|
+
notes.push(`Opened cold on "${index.words.find((w) => w.id === cold.from).text} …"${cold.mono !== false ? " in black and white" : ""}, then the story starts.`)
|
|
223
|
+
}
|
|
162
224
|
let step = apply(project, ops, { index, author: "agent" })
|
|
163
225
|
if (!step.applied) throw new Error(`The reel's cut was refused: ${step.diagnostics[0].message}`)
|
|
164
226
|
|
|
165
|
-
// Emphasis: a few words worth a punch-in
|
|
227
|
+
// Emphasis: a few words worth a punch-in; a reference's pace can ask for more (EDD-23)
|
|
228
|
+
const most = Number.isInteger(brief.punches) && brief.punches > 0 ? Math.min(brief.punches, 8) : recipe.punch.max
|
|
166
229
|
const kept = chosen.flatMap((l) => runsOf(l).flat())
|
|
167
230
|
const keptIds = new Set(kept.map((w) => w.id))
|
|
168
231
|
const emphasis = await ask({
|
|
@@ -170,24 +233,71 @@ export async function planReel({ project, index, asset, ask, brief = {}, variant
|
|
|
170
233
|
schema: EMPHASIS_SCHEMA,
|
|
171
234
|
recipe: recipe.notes,
|
|
172
235
|
view: paperEdit({ ...scoped, sentences: chosen }, { assets: [asset] }),
|
|
173
|
-
request: `Pick up to ${
|
|
236
|
+
request: `Pick up to ${most} single words to emphasise with a quick zoom: numbers, names, the point of a line. Word ids only.`,
|
|
174
237
|
maxOutput: 200,
|
|
175
238
|
check: ({ emphasis: picked }) => picked.filter((id) => !keptIds.has(id)).map((id) => `"${id}" isn't a kept word`),
|
|
176
|
-
fallback: () => ({ emphasis: kept.filter((w) => /\d/.test(w.text)).slice(0,
|
|
239
|
+
fallback: () => ({ emphasis: kept.filter((w) => /\d/.test(w.text)).slice(0, most).map((w) => w.id) }),
|
|
177
240
|
signal,
|
|
178
241
|
})
|
|
179
242
|
calls += emphasis.calls
|
|
180
243
|
slots.emphasis = emphasis.source
|
|
181
244
|
if (emphasis.reason) notes.push(`Emphasis: ${emphasis.reason}`)
|
|
182
|
-
const punches = [...new Set(emphasis.value.emphasis)].slice(0,
|
|
245
|
+
const punches = [...new Set(emphasis.value.emphasis)].slice(0, most).map((id) => ({ op: "punch_in", at: { word: id, edge: "start" }, until: { word: id, edge: "end" }, scale: brief.zoom ?? recipe.punch.scale }))
|
|
183
246
|
|
|
184
|
-
// Reframe to
|
|
247
|
+
// Reframe to the template's frame: follow the speaker where the index has one, else hold
|
|
248
|
+
// the centre. A frame as wide as the take or wider keeps the whole picture
|
|
185
249
|
const facts = project.assets.find((a) => a.id === asset).facts
|
|
186
250
|
const cropWidth = Math.round((facts.height * recipe.canvas.width) / recipe.canvas.height)
|
|
251
|
+
const crops = cropWidth < facts.width
|
|
187
252
|
const subject = (index.subjects?.[asset]?.length ?? 0) > 0
|
|
188
|
-
if (!subject) notes.push("No face track for this take, so the frame holds the centre.")
|
|
253
|
+
if (crops && !subject) notes.push("No face track for this take, so the frame holds the centre.")
|
|
189
254
|
const clips = step.project.sequences.find((q) => q.id === step.project.active).clips.filter((c) => base.has(c.track))
|
|
190
|
-
const framing = clips.map((c) => (subject ? { op: "reframe", clip: c.id, mode: "subject" } : { op: "reframe", clip: c.id, mode: "fixed", x: Math.max(0, Math.round((facts.width - cropWidth) / 2)) }))
|
|
255
|
+
const framing = crops ? clips.map((c) => (subject ? { op: "reframe", clip: c.id, mode: "subject" } : { op: "reframe", clip: c.id, mode: "fixed", x: Math.max(0, Math.round((facts.width - cropWidth) / 2)) })) : []
|
|
256
|
+
// The template's colour look, on every picture clip
|
|
257
|
+
// The look on every story clip; a cold open keeps its own black and white
|
|
258
|
+
const look = GRADES[brief.grade] ?? (brief.customGrade && typeof brief.customGrade === "object" ? brief.customGrade : null)
|
|
259
|
+
const grading = look ? clips.filter((c) => !c.echo).map((c) => ({ op: "grade", clip: c.id, ...look })) : []
|
|
260
|
+
// Sound design: an effect on every cut of the story, a riser into it after a cold open.
|
|
261
|
+
// Each is placed by its peak, so the loudest moment lands on the cut
|
|
262
|
+
const storyClips = clips.filter((c) => !c.echo)
|
|
263
|
+
const cutSounds = brief.sfx?.cut ? storyClips.slice(1).map((c) => ({ op: "add_sfx", asset: brief.sfx.cut, peak_at: { clip: c.id, edge: "start" } })) : []
|
|
264
|
+
const introSound = brief.sfx?.intro && cold && storyClips[0] ? [{ op: "add_sfx", asset: brief.sfx.intro, peak_at: { clip: storyClips[0].id, edge: "start" } }] : []
|
|
265
|
+
const sounds = [...cutSounds, ...introSound]
|
|
266
|
+
|
|
267
|
+
// Angles: one camera cut like two, wide then tight on alternate story clips (a punch the
|
|
268
|
+
// length of the clip). Emphasis punch-ins come after, so they win on their own clips
|
|
269
|
+
const angles = brief.angles ? storyClips.filter((_, i) => i % 2 === 1).map((c) => ({ op: "punch_in", at: { clip: c.id, edge: "start" }, until: { clip: c.id, edge: "end" }, scale: 1.18 })) : []
|
|
270
|
+
// B-roll from the person's own other clips, over every other story clip after the first,
|
|
271
|
+
// 2.5 s or the clip's length, each from a new part of its source
|
|
272
|
+
const brollSources = brief.broll === "own" ? project.assets.filter((a) => a.kind === "video" && a.id !== asset && (a.facts.duration ?? 0) > FLICKS) : []
|
|
273
|
+
const pieces = solve(step.project, index).picture
|
|
274
|
+
const lengthOfClip = (id) => pieces.filter((p) => p.clip === id).reduce((sum, p) => sum + (p.end - p.at), 0)
|
|
275
|
+
const broll = brollSources.length
|
|
276
|
+
? storyClips
|
|
277
|
+
.slice(1)
|
|
278
|
+
.filter((_, i) => i % 2 === 0)
|
|
279
|
+
.map((c, i) => {
|
|
280
|
+
const source = brollSources[i % brollSources.length]
|
|
281
|
+
const duration = Math.min(Math.round(2.5 * FLICKS), lengthOfClip(c.id))
|
|
282
|
+
const room = Math.max(0, source.facts.duration - duration)
|
|
283
|
+
const from = room ? Math.round((i * 3 * FLICKS) % room) : 0
|
|
284
|
+
return duration > FLICKS / 2 ? { op: "place_broll", asset: source.id, at: { clip: c.id, edge: "start" }, in: from, duration } : null
|
|
285
|
+
})
|
|
286
|
+
.filter(Boolean)
|
|
287
|
+
: []
|
|
288
|
+
if (brief.broll === "own" && !brollSources.length) notes.push("There's no other video in the bin, so the cut has no B-roll. Add clips to the bin and make it again.")
|
|
289
|
+
// Title cards: each emphasis word pops on screen, unless captions already carry the words
|
|
290
|
+
const titleWords = brief.titles && !LOOKS[brief.captions] ? [...new Set(emphasis.value.emphasis)].slice(0, most).map((wid) => index.words.find((w) => w.id === wid)).filter(Boolean) : []
|
|
291
|
+
if (brief.titles && LOOKS[brief.captions]) notes.push("Captions already put the words on screen, so there are no separate title cards.")
|
|
292
|
+
const titles = titleWords.map((w) => ({ op: "add_title", text: w.text.replace(/[^\p{L}\p{N}%$₹' -]/gu, "").toUpperCase().slice(0, 40) || w.text, at: { word: w.id, edge: "start" }, duration: Math.round(1.2 * FLICKS) }))
|
|
293
|
+
// A speed ramp out of the cold open: its last 1.2 s rushes up to 2× into the story
|
|
294
|
+
const coldClip = clips.find((c) => c.echo)
|
|
295
|
+
const coldEnd = cold && index.words.find((w) => w.id === cold.to)?.end
|
|
296
|
+
const coldStart = cold && index.words.find((w) => w.id === cold.from)?.start
|
|
297
|
+
const rampFrom = coldEnd ? Math.max(coldEnd - Math.round(1.2 * FLICKS), coldStart + Math.round((coldEnd - coldStart) / 3)) : 0
|
|
298
|
+
const ramps = brief.ramps && coldClip && coldEnd ? [{ op: "speed_ramp", clip: coldClip.id, from: rampFrom, to: coldEnd, peak: { n: 2, d: 1 } }] : []
|
|
299
|
+
// Background noise out of the voice: FFmpeg's own denoise, EQ, de-ess and compression (clean_voice)
|
|
300
|
+
const cleaning = brief.cleanVoice ? clips.map((c) => ({ op: "clean_voice", clip: c.id, strength: 0.6 })) : []
|
|
191
301
|
|
|
192
302
|
// Captions, when the brief asks for a look: pages of the kept words, timed to the speech
|
|
193
303
|
const captions = LOOKS[brief.captions] ? chosen.flatMap((l) => runsOf(l)).flatMap((run) => pages(run)).map((ids) => ({ op: "caption_style", look: brief.captions, words: ids })) : []
|
|
@@ -195,7 +305,7 @@ export async function planReel({ project, index, asset, ask, brief = {}, variant
|
|
|
195
305
|
const song = brief.music ? project.assets.find((a) => a.id === brief.music && a.kind === "audio") : null
|
|
196
306
|
if (brief.music && !song) notes.push(`There is no sound "${brief.music}" in this project, so the reel has no music.`)
|
|
197
307
|
const music = song ? [{ op: "set_music", asset: song.id }, { op: "music_shape", fit: true, fadeIn: Math.round(FLICKS * 0.3) }, { op: "duck" }] : []
|
|
198
|
-
const all = [...ops, ...punches, ...framing, ...captions, ...music]
|
|
308
|
+
const all = [...ops, ...angles, ...punches, ...framing, ...grading, ...cleaning, ...broll, ...titles, ...captions, ...music, ...sounds, ...ramps]
|
|
199
309
|
step = apply(project, all, { index, author: "agent" })
|
|
200
310
|
if (!step.applied) throw new Error(`The reel was refused: ${step.diagnostics[0].message}`)
|
|
201
311
|
return { ops: all, project: step.project, notes, calls, slots }
|
|
@@ -48,7 +48,7 @@ async function fetchFrom(artifact, offset) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/** Downloads to `part`, resuming what's there. The hash decides; a wrong file is deleted. */
|
|
51
|
-
async function download(artifact, part) {
|
|
51
|
+
async function download(artifact, part, onBytes = () => {}) {
|
|
52
52
|
let offset = sizeOf(part)
|
|
53
53
|
if (offset > artifact.bytes) {
|
|
54
54
|
rmSync(part)
|
|
@@ -70,6 +70,7 @@ async function download(artifact, part) {
|
|
|
70
70
|
break
|
|
71
71
|
}
|
|
72
72
|
if (!out.write(chunk)) await once(out, "drain")
|
|
73
|
+
onBytes(written)
|
|
73
74
|
}
|
|
74
75
|
} catch {
|
|
75
76
|
cut = true
|
|
@@ -88,10 +89,11 @@ async function download(artifact, part) {
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
async function placeArtifact(artifact, root, dir, home, say) {
|
|
92
|
+
async function placeArtifact(artifact, root, dir, home, say, progress = () => {}) {
|
|
92
93
|
say(`Downloading ${artifact.id} ${artifact.version} (${(artifact.bytes / 1e6).toFixed(0)} MB)`)
|
|
93
94
|
const part = join(root, ".downloads", `${artifact.sha256}.part`)
|
|
94
|
-
|
|
95
|
+
progress({ step: artifact.id, done: sizeOf(part), total: artifact.bytes })
|
|
96
|
+
await download(artifact, part, (done) => progress({ step: artifact.id, done, total: artifact.bytes }))
|
|
95
97
|
const target = join(dir, artifact.id)
|
|
96
98
|
mkdirSync(target, { recursive: true })
|
|
97
99
|
if (artifact.unpack === "zip") await runChild(home)("unzip", ["-q", "-o", part, "-d", target])
|
|
@@ -99,8 +101,9 @@ async function placeArtifact(artifact, root, dir, home, say) {
|
|
|
99
101
|
rmSync(part)
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
async function placePython(python, dir, run, say) {
|
|
104
|
+
async function placePython(python, dir, run, say, progress) {
|
|
103
105
|
say(`Installing the ${python.id} environment (Python ${python.version}, ${python.packages.length} packages)`)
|
|
106
|
+
progress({ step: python.id, done: null, total: null })
|
|
104
107
|
const lock = join(dir, `${python.id}.lock`)
|
|
105
108
|
writeFileSync(lock, python.requirements)
|
|
106
109
|
const venv = join(dir, "python")
|
|
@@ -153,9 +156,10 @@ function use(root, version) {
|
|
|
153
156
|
|
|
154
157
|
/**
|
|
155
158
|
* @param {{ text: string, data: object }} opened from openManifest
|
|
156
|
-
* @param {{ home?: string, platform?: string, run?: (command: string, args: string[]) => Promise<string>, free?: (dir: string) => number, say?: (line: string) => void }} [options]
|
|
159
|
+
* @param {{ home?: string, platform?: string, run?: (command: string, args: string[]) => Promise<string>, free?: (dir: string) => number, say?: (line: string) => void, progress?: (at: { step: string, done: number | null, total: number | null }) => void }} [options]
|
|
160
|
+
* progress: bytes of each download as they arrive, for the Studio's progress bar
|
|
157
161
|
*/
|
|
158
|
-
export async function install({ text, data }, { home = kriyaHome(), platform = platformId(), run = runChild(home), free = freeBytes, say = () => {} } = {}) {
|
|
162
|
+
export async function install({ text, data }, { home = kriyaHome(), platform = platformId(), run = runChild(home), free = freeBytes, say = () => {}, progress = () => {} } = {}) {
|
|
159
163
|
const spec = data.platforms[platform]
|
|
160
164
|
if (!spec) throw new RuntimeError(`This runtime isn't available for this computer (${platform}) yet.`)
|
|
161
165
|
refuseLicences(data)
|
|
@@ -183,8 +187,8 @@ export async function install({ text, data }, { home = kriyaHome(), platform = p
|
|
|
183
187
|
rmSync(dir, { recursive: true, force: true })
|
|
184
188
|
mkdirSync(dir, { recursive: true })
|
|
185
189
|
try {
|
|
186
|
-
for (const artifact of spec.artifacts) await placeArtifact(artifact, root, dir, home, say)
|
|
187
|
-
await placePython(spec.python, dir, run, say)
|
|
190
|
+
for (const artifact of spec.artifacts) await placeArtifact(artifact, root, dir, home, say, progress)
|
|
191
|
+
await placePython(spec.python, dir, run, say, progress)
|
|
188
192
|
writeFileSync(join(dir, "manifest.json"), text)
|
|
189
193
|
writeFileSync(join(dir, ".complete"), hash)
|
|
190
194
|
// The environment no longer needs it, and it's as big as the environment
|
package/studio/dist/studio.css
CHANGED
|
@@ -73,6 +73,18 @@ a { color: var(--teal); }
|
|
|
73
73
|
.btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--teal); }
|
|
74
74
|
.field { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 0; background: var(--sheet); color: inherit; font: inherit; box-shadow: inset 0 0 0 1px var(--edge); width: 100%; }
|
|
75
75
|
.field.small { width: auto; }
|
|
76
|
+
/* A select draws its own chevron, inset from the edge, so the arrow never sits on the border */
|
|
77
|
+
.field.select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; cursor: pointer; }
|
|
78
|
+
.field.small.select { min-width: 132px; }
|
|
79
|
+
.btn.wide { width: 100%; }
|
|
80
|
+
.btn:disabled { opacity: 0.55; cursor: default; }
|
|
81
|
+
.note.small { font-size: 13px; }
|
|
82
|
+
.row.tight { flex-wrap: nowrap; }
|
|
83
|
+
.row.tight .field { flex: 1; min-width: 0; }
|
|
84
|
+
.progress { height: 6px; border-radius: 999px; background: var(--hover); overflow: hidden; margin: 4px 0; }
|
|
85
|
+
.progress span { display: block; height: 100%; background: var(--teal); border-radius: inherit; transition: width 0.2s; }
|
|
86
|
+
.progress span.busy { width: 35%; animation: busy 1.2s ease-in-out infinite; }
|
|
87
|
+
@keyframes busy { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
|
|
76
88
|
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
|
|
77
89
|
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
78
90
|
.inline { display: inline-flex; gap: 6px; align-items: center; min-height: 44px; }
|
|
@@ -95,10 +107,14 @@ a { color: var(--teal); }
|
|
|
95
107
|
.projects { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
|
|
96
108
|
|
|
97
109
|
.workspace { display: flex; flex-direction: column; min-height: 100%; }
|
|
98
|
-
|
|
110
|
+
/* --side: the Kriya panel's width; it fits the window unless the person drags it (main.js) */
|
|
111
|
+
.grid { flex: 1; display: grid; gap: 12px; padding: 12px; min-height: 0; grid-template-columns: minmax(0, 1fr) min(var(--side, clamp(340px, 32vw, 560px)), 62vw); grid-template-areas: "monitor kriya" "transcript transcript" "strip strip"; align-content: start; }
|
|
99
112
|
.area-bin { grid-area: bin; }
|
|
100
113
|
.area-monitor { grid-area: monitor; background: var(--surround); color: #eee; }
|
|
101
|
-
.area-kriya { grid-area: kriya; }
|
|
114
|
+
.area-kriya { grid-area: kriya; position: relative; }
|
|
115
|
+
.side-handle { position: absolute; left: -12px; top: 0; bottom: 0; width: 12px; cursor: col-resize; touch-action: none; border-radius: 6px; }
|
|
116
|
+
.side-handle::after { content: ""; position: absolute; left: 4px; top: 50%; width: 4px; height: 48px; margin-top: -24px; border-radius: 999px; background: var(--edge); }
|
|
117
|
+
.side-handle:hover::after, .side-handle:focus-visible::after { background: var(--teal); }
|
|
102
118
|
.area-transcript { grid-area: transcript; }
|
|
103
119
|
.area-strip { grid-area: strip; }
|
|
104
120
|
.area-timeline { grid-area: timeline; }
|
|
@@ -106,14 +122,22 @@ a { color: var(--teal); }
|
|
|
106
122
|
.workspace[data-mode="direct"] :is(.area-bin, .area-timeline, .area-finish) { display: none; }
|
|
107
123
|
.workspace[data-mode="edit"] .grid { grid-template-columns: 280px minmax(0, 1fr) 320px; grid-template-areas: "bin monitor transcript" "timeline timeline timeline"; }
|
|
108
124
|
.workspace[data-mode="edit"] :is(.area-kriya, .area-strip, .area-finish) { display: none; }
|
|
109
|
-
.
|
|
125
|
+
.area-final { grid-area: final; display: none; }
|
|
126
|
+
.workspace[data-mode="finish"] .area-final { display: block; }
|
|
127
|
+
.workspace[data-mode="finish"] .grid { grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "final finish" "monitor finish"; }
|
|
128
|
+
.final-film { width: 100%; max-height: 62vh; background: #000; border-radius: 8px; display: block; }
|
|
129
|
+
.final .row { margin-top: 8px; }
|
|
130
|
+
.final .row select { flex: 1 1 220px; width: auto; min-width: 0; max-width: 100%; }
|
|
131
|
+
.final .note.stale { color: var(--saffron); }
|
|
132
|
+
.final [hidden] { display: none; }
|
|
133
|
+
.did li.watch::before { content: none; }
|
|
110
134
|
.workspace[data-mode="finish"] :is(.area-bin, .area-kriya, .area-transcript, .area-strip, .area-timeline) { display: none; }
|
|
111
135
|
|
|
112
136
|
.monitor-frame { display: flex; justify-content: center; align-items: center; min-height: 200px; }
|
|
113
137
|
.monitor { max-width: 100%; max-height: 62vh; background: #000; display: block; }
|
|
114
138
|
.transport { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
|
|
115
139
|
.area-monitor .chip { background: rgb(255 255 255 / 0.12); color: #ddd; }
|
|
116
|
-
.area-monitor .field { background: #2a2a2a; color: #eee; }
|
|
140
|
+
.area-monitor .field { background-color: #2a2a2a; color: #eee; }
|
|
117
141
|
|
|
118
142
|
.prompt { display: flex; gap: 8px; }
|
|
119
143
|
.chip.selection { background: color-mix(in srgb, var(--teal) 16%, transparent); color: var(--ink); }
|
|
@@ -131,6 +155,9 @@ a { color: var(--teal); }
|
|
|
131
155
|
.word.unsure { text-decoration: underline dotted var(--saffron); }
|
|
132
156
|
.word.now { background: color-mix(in srgb, var(--saffron) 25%, transparent); }
|
|
133
157
|
.word[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--teal); }
|
|
158
|
+
.word.fixed { text-decoration: underline solid color-mix(in srgb, var(--teal) 60%, transparent); text-underline-offset: 4px; }
|
|
159
|
+
.word-edit { font: inherit; color: inherit; background: var(--paper); border: 0; border-radius: 6px; padding: 4px 6px; min-height: 32px; box-shadow: inset 0 0 0 2px var(--teal); }
|
|
160
|
+
.hint { margin-top: -4px; }
|
|
134
161
|
|
|
135
162
|
.timeline { display: grid; grid-template-columns: 80px minmax(0, 1fr); grid-template-rows: auto auto; gap: 0 8px; }
|
|
136
163
|
.lane-labels { display: grid; grid-auto-rows: 50px; font-size: 12px; color: var(--ink-2); align-items: center; }
|
|
@@ -144,6 +171,19 @@ a { color: var(--teal); }
|
|
|
144
171
|
|
|
145
172
|
.bin { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 8px; }
|
|
146
173
|
.asset { display: grid; gap: 4px; }
|
|
174
|
+
.refs { margin-top: 12px; }
|
|
175
|
+
.by-path { margin-top: 10px; }
|
|
176
|
+
.by-path summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--ink-2); font-size: 13px; }
|
|
177
|
+
.make { display: grid; gap: 8px; margin-bottom: 16px; }
|
|
178
|
+
.make-status:empty { display: none; }
|
|
179
|
+
.banner { padding: 8px 12px 0; display: grid; gap: 8px; }
|
|
180
|
+
.banner > .note { margin: 0; padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--teal) 12%, transparent); color: var(--ink); }
|
|
181
|
+
.banner > .note:empty, .banner > [hidden] { display: none; }
|
|
182
|
+
.setup { box-shadow: inset 0 0 0 1px var(--teal); display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
|
|
183
|
+
.setup h2, .setup > div { grid-column: 1 / -1; }
|
|
184
|
+
.setup > div:empty { display: none; }
|
|
185
|
+
.setup > p { margin: 0; }
|
|
186
|
+
.area-kriya h2 + .make { margin-top: 0; }
|
|
147
187
|
.finish { display: grid; gap: 12px; }
|
|
148
188
|
.scope-row { display: flex; gap: 10px; flex-wrap: wrap; }
|
|
149
189
|
.scope-row figure { margin: 0; }
|
|
@@ -153,11 +193,43 @@ a { color: var(--teal); }
|
|
|
153
193
|
|
|
154
194
|
/* Review mode under 760 px (UX_SPEC §12): preview, Kriya, export. No timeline, no bin */
|
|
155
195
|
@media (max-width: 760px) {
|
|
156
|
-
.grid, .workspace[data-mode] .grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "monitor" "kriya" "transcript" "finish"; padding: 8px; }
|
|
196
|
+
.grid, .workspace[data-mode] .grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "final" "monitor" "kriya" "transcript" "finish"; padding: 8px; }
|
|
157
197
|
.workspace[data-mode] :is(.area-bin, .area-timeline, .area-strip) { display: none; }
|
|
158
198
|
.workspace[data-mode="edit"] .area-kriya { display: block; }
|
|
159
199
|
.modes { margin-left: 0; width: 100%; }
|
|
200
|
+
.side-handle { display: none; }
|
|
160
201
|
.modes .btn { flex: 1; }
|
|
161
202
|
.monitor { max-height: 50vh; }
|
|
162
203
|
}
|
|
163
|
-
|
|
204
|
+
/* Home: a project's row with its delete; the folder picker */
|
|
205
|
+
.project-row { display: flex; gap: 8px; align-items: center; }
|
|
206
|
+
.project-row .open { flex: 1; justify-content: flex-start; }
|
|
207
|
+
.btn.danger { color: var(--error); }
|
|
208
|
+
.picker { width: min(560px, 92vw); max-height: 80vh; border: 0; border-radius: 14px; padding: 18px; background: var(--sheet); color: var(--ink); box-shadow: 0 12px 40px rgb(0 0 0 / 0.35); display: grid; gap: 10px; }
|
|
209
|
+
.picker::backdrop { background: rgb(0 0 0 / 0.45); }
|
|
210
|
+
.picker .where { word-break: break-all; color: var(--ink-2); margin: 0; }
|
|
211
|
+
.folders { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; max-height: 46vh; overflow: auto; }
|
|
212
|
+
.btn.folder { width: 100%; justify-content: flex-start; }
|
|
213
|
+
.row.end { justify-content: flex-end; }
|
|
214
|
+
|
|
215
|
+
/* Chat with Kriya */
|
|
216
|
+
.chat { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 8px; max-height: 58vh; overflow: auto; }
|
|
217
|
+
.chat:empty { display: none; }
|
|
218
|
+
.msg { padding: 8px 10px; border-radius: 10px; background: var(--hover); }
|
|
219
|
+
.msg.you { background: color-mix(in srgb, var(--teal) 14%, transparent); }
|
|
220
|
+
.msg .who { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
|
|
221
|
+
.msg p { margin: 2px 0 0; white-space: pre-wrap; }
|
|
222
|
+
.msg .proposal { margin-top: 8px; }
|
|
223
|
+
.chat-input { min-height: 64px; padding: 10px 12px; resize: vertical; line-height: 1.4; }
|
|
224
|
+
.prompt { align-items: flex-end; }
|
|
225
|
+
.time-link { font: inherit; font-family: ui-monospace, "JetBrains Mono", monospace; font-size: 0.92em; color: var(--teal); background: none; border: 0; padding: 0 2px; min-height: 24px; text-decoration: underline; cursor: pointer; }
|
|
226
|
+
.marks { display: inline-flex; gap: 6px; }
|
|
227
|
+
.send { display: grid; gap: 6px; }
|
|
228
|
+
.extras { display: flex; flex-wrap: wrap; gap: 0 14px; }
|
|
229
|
+
.plan .steps { margin: 4px 0; padding-left: 20px; display: grid; gap: 4px; }
|
|
230
|
+
.refs-direct { margin: 0; }
|
|
231
|
+
.refs-direct:empty { display: none; }
|
|
232
|
+
.ref .ref-lines { list-style: none; padding: 0; margin: 2px 0; font-size: 13px; color: var(--ink-2); display: grid; gap: 2px; }
|
|
233
|
+
.area-monitor .marks .btn { background: #2a2a2a; color: #eee; }
|
|
234
|
+
|
|
235
|
+
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
|