@kriya-ai/harness 0.2.4 → 2.0.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/RELEASE_NOTES.md +121 -0
- package/SAFETY.md +181 -0
- package/THIRD_PARTY_NOTICES.md +113 -0
- package/bin/kriya.js +188 -2
- package/bundle/cordis.patch.yml +49 -0
- package/contract/SOURCE.md +3 -3
- package/contract/contract.json +504 -3
- package/contract/schemas/api.json +64 -0
- package/contract/schemas/auth_matrix.json +44 -0
- package/contract/schemas/component_states.json +33 -0
- package/contract/schemas/design_tokens.json +34 -0
- package/contract/schemas/scene_direction.json +82 -0
- package/contract/schemas/threat_model.json +44 -0
- package/package.json +2 -1
- package/plugins/changes/client.js +5 -3
- package/plugins/deploy/index.js +215 -0
- package/plugins/deploy/package.json +13 -0
- package/plugins/grounding/index.js +81 -0
- package/plugins/grounding/lookup.js +373 -0
- package/plugins/grounding/package.json +13 -0
- package/plugins/kriya-tools/index.js +2 -1
- package/plugins/loop/index.js +376 -10
- package/plugins/mcp/index.js +79 -0
- package/plugins/mcp/package.json +13 -0
- package/plugins/mirror/index.js +17 -0
- package/plugins/overview/client.js +5 -2
- package/plugins/preview/client.js +12 -6
- package/plugins/progress/client.js +7 -4
- package/plugins/repo/index.js +230 -0
- package/plugins/repo/package.json +13 -0
- package/plugins/repo/repo.js +348 -0
- package/plugins/runstrip/client.js +426 -0
- package/plugins/runstrip/index.js +301 -0
- package/plugins/runstrip/package.json +23 -0
- package/src/cartridges.js +133 -0
- package/src/contracts.js +130 -0
- package/src/critic.js +78 -0
- package/src/daemon.js +7 -1
- package/src/doctor.js +67 -0
- package/src/edit/core/effects.js +185 -0
- package/src/edit/core/ffmpeg.js +82 -5
- package/src/edit/core/layout.js +46 -1
- package/src/edit/core/ops.js +175 -3
- package/src/edit/core/plan.js +95 -9
- package/src/edit/core/project.d.ts +24 -0
- package/src/edit/core/project.js +64 -0
- package/src/edit/core/solver.js +34 -6
- package/src/edit/core/style-brief.js +211 -0
- package/src/edit/core/style-packs.js +57 -0
- package/src/edit/core/transitions.js +17 -0
- package/src/edit/core/type-kit.js +173 -0
- package/src/edit/director/ask.js +37 -3
- package/src/edit/director/assembly.js +829 -0
- package/src/edit/director/continuity.js +137 -0
- package/src/edit/director/custom-motion.js +88 -0
- package/src/edit/director/graphics.js +186 -0
- package/src/edit/director/intent.js +125 -0
- package/src/edit/director/mentions.js +52 -0
- package/src/edit/director/plan.js +89 -12
- package/src/edit/director/revise.js +172 -7
- package/src/edit/director/viewer.js +136 -0
- package/src/edit/director/watch-fix.js +119 -0
- package/src/edit/engine/captions.js +110 -5
- package/src/edit/engine/confine.js +81 -4
- package/src/edit/engine/custom.js +243 -0
- package/src/edit/engine/dna2.js +893 -0
- package/src/edit/engine/fonts.js +218 -0
- package/src/edit/engine/graphics.js +439 -0
- package/src/edit/engine/index.js +14 -5
- package/src/edit/engine/motion.js +153 -14
- package/src/edit/engine/music-bed.js +59 -1
- package/src/edit/engine/packs.js +11 -0
- package/src/edit/engine/reference2.js +26 -0
- package/src/edit/engine/sfx.js +56 -1
- package/src/edit/engine/tool.js +21 -5
- package/src/edit/gates/assembly.js +194 -0
- package/src/edit/gates/copy.js +7 -4
- package/src/edit/gates/index.js +76 -8
- package/src/edit/gates/picture.js +6 -3
- package/src/edit/gates/reference.js +115 -0
- package/src/edit/gates/tile.js +96 -0
- package/src/edit/host/client.js +4 -3
- package/src/edit/host/clips.js +33 -0
- package/src/edit/host/jobs.js +9 -3
- package/src/edit/host/layers.js +134 -0
- package/src/edit/host/main.js +17 -7
- package/src/edit/host/paths.js +34 -3
- package/src/edit/host/preview.js +108 -0
- package/src/edit/host/projects.js +494 -29
- package/src/edit/host/server.js +263 -19
- package/src/edit/host/tavi.js +77 -0
- package/src/edit/loop/make.js +44 -3
- package/src/edit/recipes/assembly.js +352 -0
- package/src/edit/recipes/graphic-clips.js +59 -0
- package/src/edit/recipes/openings.js +36 -0
- package/src/edit/recipes/reel.js +138 -17
- package/src/edit/recipes/reference-look.js +29 -0
- package/src/edit/recipes/short-from-long.js +3 -3
- package/src/edit/recipes/sound.js +71 -0
- package/src/edit/runtime/cli.js +26 -5
- package/src/edit/runtime/fetch.js +4 -3
- package/src/edit/runtime/licences.js +7 -1
- package/src/explore.js +103 -0
- package/src/failure.js +1 -1
- package/src/gate-commands.js +114 -0
- package/src/gates/api.js +127 -0
- package/src/gates/commands.js +111 -0
- package/src/gates/detectors.js +370 -0
- package/src/gates/http.js +62 -0
- package/src/gates/index.js +196 -0
- package/src/gates/page.js +264 -0
- package/src/gates/sast.js +64 -0
- package/src/gates/stack.js +110 -0
- package/src/gates/tenant.js +162 -0
- package/src/gates/three.js +407 -0
- package/src/gates/ui.js +111 -0
- package/src/launch.js +15 -3
- package/src/loop.js +199 -7
- package/src/mcp.js +126 -0
- package/src/milestones.js +188 -0
- package/src/modes.js +32 -0
- package/src/orchestra.js +43 -0
- package/src/outcomes.js +88 -0
- package/src/profiles.js +5 -0
- package/src/receipts.js +238 -0
- package/src/release.js +356 -0
- package/src/runstrip.js +122 -0
- package/src/stack.js +120 -0
- package/src/verify.js +67 -20
- package/studio/dist/fonts/fraunces.woff2 +0 -0
- package/studio/dist/fonts/geist.woff2 +0 -0
- package/studio/dist/fonts/jetbrains-mono.woff2 +0 -0
- package/studio/dist/studio.css +452 -3
- package/studio/dist/studio.js +3 -3
package/src/edit/recipes/reel.js
CHANGED
|
@@ -5,11 +5,17 @@
|
|
|
5
5
|
// the lines to drop; the emphasis words), each with a default that needs no model.
|
|
6
6
|
|
|
7
7
|
import { isSceneBlock } from "../core/layout.js"
|
|
8
|
+
import { graphicOps, isPlanGraphic } from "./graphic-clips.js"
|
|
9
|
+
import { TRANSITION_DEFAULT, TRANSITIONS } from "../core/transitions.js"
|
|
8
10
|
import { apply } from "../core/ops.js"
|
|
9
11
|
import { solve } from "../core/solver.js"
|
|
10
|
-
import {
|
|
12
|
+
import { ALL_LOOKS, pageLimits, pages, placeOf, readablePages } from "../engine/captions.js"
|
|
11
13
|
import { paperEdit } from "../index/views.js"
|
|
12
14
|
import { sceneOps } from "./scene-clips.js"
|
|
15
|
+
import { busOf } from "../core/audio.js"
|
|
16
|
+
import { compile } from "../core/plan.js"
|
|
17
|
+
import { onBeat, quietStretch, splitOps, timelineBeats } from "./sound.js"
|
|
18
|
+
import { referenceLook } from "./reference-look.js"
|
|
13
19
|
|
|
14
20
|
const FLICKS = 705_600_000
|
|
15
21
|
|
|
@@ -69,7 +75,7 @@ export function recipeFor(brief = {}) {
|
|
|
69
75
|
/** The recipe's deliverable; with captions asked for, they burn in and the text gates run (ED8). */
|
|
70
76
|
export function deliverableFor(brief = {}) {
|
|
71
77
|
const base = recipeFor(brief).deliverable
|
|
72
|
-
return
|
|
78
|
+
return ALL_LOOKS[brief.captions] ? { ...base, burnCaptions: true, gates: [...base.gates, "QG-08", "QG-09", "QG-10"].sort() } : base
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
/** Lines worth keeping: each take group's best, with restarts and abandoned attempts out. */
|
|
@@ -141,7 +147,49 @@ export function fitLines(lines, max, required = new Set(), valueOf = (line, cost
|
|
|
141
147
|
return lines.filter((l) => chosen.has(l.id))
|
|
142
148
|
}
|
|
143
149
|
|
|
144
|
-
|
|
150
|
+
/**
|
|
151
|
+
* The clips a remake takes out: those `rebuilt` names, and whatever hung on one of them.
|
|
152
|
+
* B-roll, a cut's sound or a wide-and-tight punch anchored to a clip of the old cut has
|
|
153
|
+
* nothing left to sit on: it never played again, but it stayed in the project and piled up
|
|
154
|
+
* with every make (EH-60a, found 2026-11-11). The person's own clips are left as they are.
|
|
155
|
+
*/
|
|
156
|
+
export function remadeClips(sequence, rebuilt) {
|
|
157
|
+
const gone = new Set(sequence.clips.filter(rebuilt).map((c) => c.id))
|
|
158
|
+
for (let grew = true; grew; ) {
|
|
159
|
+
grew = false
|
|
160
|
+
for (const c of sequence.clips) if (!gone.has(c.id) && c.createdBy !== "person" && [c.at, c.until].some((ref) => gone.has(ref?.clip))) ((grew = true), gone.add(c.id))
|
|
161
|
+
}
|
|
162
|
+
return sequence.clips.filter((c) => gone.has(c.id))
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* B-roll by meaning (TP8, CRAFT_UPGRADE §6.5): without the Smart search pack, a cutaway's source is the
|
|
166
|
+
person's clip whose label, role, file name and own words share the most words with the line it plays over */
|
|
167
|
+
|
|
168
|
+
const STOP = new Set("a an and are as at be but by for from has have i in is it its me my of on or our so that the this to was we were what when with you your".split(" "))
|
|
169
|
+
export const wordsOf = (text) => String(text ?? "").normalize("NFKC").toLowerCase().split(/[^\p{L}\p{N}]+/u).filter((w) => w.length > 1 && !STOP.has(w)).map((w) => w.replace(/(?<=..)(ing|es|s)$/u, ""))
|
|
170
|
+
|
|
171
|
+
/** The words said over a story clip's solved pieces (source times), from the index, as text. */
|
|
172
|
+
export function spokenOver(pieces, index) {
|
|
173
|
+
return index.words.filter((w) => pieces.some((p) => w.asset === p.asset && w.start >= p.in && w.end <= p.out)).map((w) => w.text).join(" ")
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* The best source for a line: most shared words with its label, file name and own speech, a clip the
|
|
178
|
+
* person marked B-roll ahead of one they didn't, then the one used least and longest ago. Never
|
|
179
|
+
* the same source twice running when another is there.
|
|
180
|
+
*/
|
|
181
|
+
export function byMeaning(sources, said, index, used = []) {
|
|
182
|
+
const line = new Set(wordsOf(said))
|
|
183
|
+
const scored = sources.map((a, order) => {
|
|
184
|
+
const own = [a.label, String(a.path ?? "").split(/[\\/]/).at(-1).replace(/\.[^.]*$/, ""), index.words.filter((w) => w.asset === a.id).map((w) => w.text).join(" ")]
|
|
185
|
+
const shared = new Set(own.flatMap(wordsOf).filter((w) => line.has(w))).size
|
|
186
|
+
return { a, order, shared, broll: a.role === "broll" ? 1 : 0, uses: used.filter((id) => id === a.id).length, last: used.at(-1) === a.id && sources.length > 1 ? 1 : 0 }
|
|
187
|
+
})
|
|
188
|
+
scored.sort((x, y) => x.last - y.last || y.shared - x.shared || y.broll - x.broll || x.uses - y.uses || x.order - y.order)
|
|
189
|
+
return scored[0].a
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export const STORY_SCHEMA = {
|
|
145
193
|
type: "object",
|
|
146
194
|
properties: { hook: { anyOf: [{ type: "string", maxLength: 64 }, { type: "null" }] }, drop: { type: "array", maxItems: 40, items: { type: "string", maxLength: 64 } } },
|
|
147
195
|
required: ["hook", "drop"],
|
|
@@ -168,7 +216,10 @@ export async function planReel({ project, index: fullIndex, asset, ask, brief =
|
|
|
168
216
|
const scoped = { ...index, sentences: lines, words: lines.flatMap((l) => l.words), takes: [] }
|
|
169
217
|
|
|
170
218
|
// Story: the hook, and the lines that add nothing (sentence ids only)
|
|
171
|
-
|
|
219
|
+
// A change to a cut that's already made keeps its story (continuity.js): the Host passes the
|
|
220
|
+
// last make's choice, checked here against this footage, and no model is asked
|
|
221
|
+
const keptStory = brief.story && typeof brief.story === "object" ? { hook: ids.has(brief.story.hook) ? brief.story.hook : null, drop: (Array.isArray(brief.story.drop) ? brief.story.drop : []).filter((id) => ids.has(id)) } : null
|
|
222
|
+
const story = keptStory ? { value: keptStory, source: "kept", calls: 0 } : await ask({
|
|
172
223
|
task: "story",
|
|
173
224
|
schema: STORY_SCHEMA,
|
|
174
225
|
recipe: recipe.notes,
|
|
@@ -217,7 +268,7 @@ export async function planReel({ project, index: fullIndex, asset, ask, brief =
|
|
|
217
268
|
const rebuilt = new Set(sequence.tracks.filter((t) => ["base", "caption", "music"].includes(t.role)).map((t) => t.id))
|
|
218
269
|
const ops = [
|
|
219
270
|
// Scenes too: an earlier make's scenes hang on the words of that cut
|
|
220
|
-
...sequence
|
|
271
|
+
...remadeClips(sequence, (c) => rebuilt.has(c.track) || c.effects?.some((e) => isSceneBlock(e) || isPlanGraphic(e))).map((c) => ({ op: "ripple_delete", clip: c.id })),
|
|
221
272
|
{ op: "set_brief", format: recipe.id, targetDuration: target, mustKeep: brief.mustKeep ?? [], mustCut: brief.mustCut ?? [], effort: brief.effort ?? "best", ...(brief.language ? { language: brief.language } : {}) },
|
|
222
273
|
{ op: "set_format", width: recipe.canvas.width, height: recipe.canvas.height, fps: recipe.deliverable.fps },
|
|
223
274
|
...(project.deliverables.some((d) => d.preset === recipe.deliverable.preset) ? [] : [{ op: "add_deliverable", ...deliverableFor(brief) }]),
|
|
@@ -240,11 +291,18 @@ export async function planReel({ project, index: fullIndex, asset, ask, brief =
|
|
|
240
291
|
const most = Number.isInteger(brief.punches) && brief.punches > 0 ? Math.min(brief.punches, 8) : recipe.punch.max
|
|
241
292
|
const kept = chosen.flatMap((l) => runsOf(l).flat())
|
|
242
293
|
// The approved plan's scenes, on the cut as solved. A zoom or title under one would never be seen
|
|
243
|
-
const scenes = brief.scenes?.length || brief.pictures?.length || brief.terms?.length ? sceneOps({ scenes: brief.scenes ?? [], pictures: brief.pictures ?? [], terms: brief.terms ?? [], project: step.project, index, asset, kept, captions: !!
|
|
294
|
+
const scenes = brief.scenes?.length || brief.pictures?.length || brief.terms?.length ? sceneOps({ scenes: brief.scenes ?? [], pictures: brief.pictures ?? [], terms: brief.terms ?? [], project: step.project, index, asset, kept, captions: !!ALL_LOOKS[brief.captions], sound: { scene: brief.sfx?.scene, reveal: brief.sfx?.reveal } }) : { ops: [], covered: new Set(), notes: [] }
|
|
244
295
|
notes.push(...scenes.notes)
|
|
296
|
+
// The approved plan's motion graphics (MOTION_GRAPHICS.md), placed on the cut with its scenes in, so none lands on one
|
|
297
|
+
const withScenes = scenes.ops.length ? apply(step.project, scenes.ops, { index, author: "agent" }) : null
|
|
298
|
+
const graphics = brief.graphics?.length ? graphicOps({ graphics: brief.graphics, project: withScenes?.applied ? withScenes.project : step.project, index, asset, kept }) : { ops: [], notes: [] }
|
|
299
|
+
notes.push(...graphics.notes)
|
|
245
300
|
const visible = kept.filter((w) => !scenes.covered.has(w.id))
|
|
246
301
|
const keptIds = new Set(visible.map((w) => w.id))
|
|
247
|
-
|
|
302
|
+
// The same words stay punched in while the plan asks for as many as before
|
|
303
|
+
const was = keptStory && brief.story.emphasis
|
|
304
|
+
const keptWords = was && was.most === most && Array.isArray(was.ids) ? was.ids.filter((id) => keptIds.has(id)) : null
|
|
305
|
+
const emphasis = keptWords ? { value: { emphasis: keptWords }, source: "kept", calls: 0 } : await ask({
|
|
248
306
|
task: "emphasis",
|
|
249
307
|
schema: EMPHASIS_SCHEMA,
|
|
250
308
|
recipe: recipe.notes,
|
|
@@ -272,7 +330,8 @@ export async function planReel({ project, index: fullIndex, asset, ask, brief =
|
|
|
272
330
|
// The template's colour look, on every picture clip
|
|
273
331
|
// The look on every story clip; a cold open keeps its own black and white
|
|
274
332
|
const look = GRADES[brief.grade] ?? (brief.customGrade && typeof brief.customGrade === "object" ? brief.customGrade : null)
|
|
275
|
-
|
|
333
|
+
// TP6: a reference's colour as a measured match (a LUT the Host wrote), in place of a grade, only when this brief carries one
|
|
334
|
+
const grading = brief.lut ? clips.filter((c) => !c.echo).map((c) => ({ op: "apply_lut", clip: c.id, asset: brief.lut })) : look ? clips.filter((c) => !c.echo).map((c) => ({ op: "grade", clip: c.id, ...look })) : []
|
|
276
335
|
// Sound design: an effect on every cut of the story, a riser into it after a cold open.
|
|
277
336
|
// Each is placed by its peak, so the loudest moment lands on the cut
|
|
278
337
|
const storyClips = clips.filter((c) => !c.echo)
|
|
@@ -290,12 +349,15 @@ export async function planReel({ project, index: fullIndex, asset, ask, brief =
|
|
|
290
349
|
const brollSources = brief.broll === "own" ? project.assets.filter((a) => a.kind === "video" && a.id !== asset && (a.facts.duration ?? 0) > FLICKS) : []
|
|
291
350
|
const pieces = solve(step.project, index).picture
|
|
292
351
|
const lengthOfClip = (id) => pieces.filter((p) => p.clip === id).reduce((sum, p) => sum + (p.end - p.at), 0)
|
|
352
|
+
const chosenFor = new Map()
|
|
293
353
|
const broll = brollSources.length
|
|
294
354
|
? storyClips
|
|
295
355
|
.slice(1)
|
|
296
356
|
.filter((_, i) => i % 2 === 0)
|
|
297
|
-
.map((c, i) => {
|
|
298
|
-
|
|
357
|
+
.map((c, i, hosts) => {
|
|
358
|
+
// TP8 (editing.directorLoop): the source whose label, role and words best match what's said over it
|
|
359
|
+
const source = brief.brollByMeaning ? byMeaning(brollSources, spokenOver(pieces.filter((p) => p.clip === c.id), index), index, hosts.slice(0, i).map((h) => chosenFor.get(h.id))) : brollSources[i % brollSources.length]
|
|
360
|
+
chosenFor.set(c.id, source.id)
|
|
299
361
|
const duration = Math.min(Math.round(2.5 * FLICKS), lengthOfClip(c.id))
|
|
300
362
|
const room = Math.max(0, source.facts.duration - duration)
|
|
301
363
|
const from = room ? Math.round((i * 3 * FLICKS) % room) : 0
|
|
@@ -305,8 +367,8 @@ export async function planReel({ project, index: fullIndex, asset, ask, brief =
|
|
|
305
367
|
: []
|
|
306
368
|
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.")
|
|
307
369
|
// Title cards: each emphasis word pops on screen, unless captions already carry the words
|
|
308
|
-
const titleWords = brief.titles && !
|
|
309
|
-
if (brief.titles &&
|
|
370
|
+
const titleWords = brief.titles && !ALL_LOOKS[brief.captions] ? [...new Set(emphasis.value.emphasis)].slice(0, most).map((wid) => index.words.find((w) => w.id === wid)).filter(Boolean) : []
|
|
371
|
+
if (brief.titles && ALL_LOOKS[brief.captions]) notes.push("Captions already put the words on screen, so there are no separate title cards.")
|
|
310
372
|
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) }))
|
|
311
373
|
// A speed ramp out of the cold open: its last 1.2 s rushes up to 2× into the story
|
|
312
374
|
const coldClip = clips.find((c) => c.echo)
|
|
@@ -318,15 +380,74 @@ export async function planReel({ project, index: fullIndex, asset, ask, brief =
|
|
|
318
380
|
const cleaning = brief.cleanVoice ? clips.map((c) => ({ op: "clean_voice", clip: c.id, strength: 0.6 })) : []
|
|
319
381
|
|
|
320
382
|
// Captions, when the brief asks for a look: pages of the kept words, timed to the speech
|
|
321
|
-
const captions =
|
|
383
|
+
const captions = ALL_LOOKS[brief.captions] ? chosen.flatMap((l) => runsOf(l)).flatMap((run) => readablePages(pages(run, pageLimits(brief.captions)), run)).map((ids) => ({ op: "caption_style", look: brief.captions, words: ids })) : []
|
|
322
384
|
// Music, when the brief names a sound in the project: fitted on its downbeats, ducked under the speech (ED9)
|
|
323
385
|
const song = brief.music ? project.assets.find((a) => a.id === brief.music && a.kind === "audio") : null
|
|
324
386
|
if (brief.music && !song) notes.push(`There is no sound "${brief.music}" in this project, so the reel has no music.`)
|
|
325
387
|
const music = song ? [{ op: "set_music", asset: song.id }, { op: "music_shape", fit: true, fadeIn: Math.round(FLICKS * 0.3) }, { op: "duck" }] : []
|
|
326
|
-
const captionLook = { ...(brief.captionStyle ?? {}), ...(brief.holdCaptions ? { hold: true } : {}) }
|
|
327
|
-
const style =
|
|
328
|
-
|
|
388
|
+
const captionLook = { ...(brief.captionStyle ?? {}), ...(brief.holdCaptions ? { hold: true } : {}), ...(placeOf(brief.captions) ? { place: placeOf(brief.captions) } : {}) }
|
|
389
|
+
const style = ALL_LOOKS[brief.captions] && Object.keys(captionLook).length ? [{ op: "set_look", caption: captionLook }] : []
|
|
390
|
+
// Transitions (transitions.js): where the story changes moment (out of the cold open, a line moved
|
|
391
|
+
// up, a jump of seconds in the take), or on every cut when the person asked. A filler cut stays a cut
|
|
392
|
+
const joins = []
|
|
393
|
+
if (Object.hasOwn(TRANSITIONS, brief.transition ?? "")) {
|
|
394
|
+
const SECTION = 3 * FLICKS
|
|
395
|
+
// The story as it plays: each clip's stretch of the take, in order (a clip's own source is word anchors)
|
|
396
|
+
const played = []
|
|
397
|
+
for (const p of solve(step.project, index).picture) {
|
|
398
|
+
if (p.hold) continue
|
|
399
|
+
if (played.at(-1)?.clip === p.clip) played.at(-1).out = p.out
|
|
400
|
+
else played.push({ clip: p.clip, asset: p.asset, in: p.in, out: p.out, echo: !!p.echo })
|
|
401
|
+
}
|
|
402
|
+
for (let i = 1; i < played.length; i++) {
|
|
403
|
+
const [a, b] = [played[i - 1], played[i]]
|
|
404
|
+
const moment = a.echo !== b.echo || a.asset !== b.asset || b.in < a.out || b.in - a.out > SECTION
|
|
405
|
+
if (brief.transitionAll || moment) joins.push({ op: "transition", clip: b.clip, kind: brief.transition, duration: TRANSITION_DEFAULT })
|
|
406
|
+
}
|
|
407
|
+
if (!joins.length) notes.push(`No ${brief.transition} transition: this cut runs straight through, with no change of moment to dress.`)
|
|
408
|
+
}
|
|
409
|
+
// TP10 (editing.craft, only what this brief asks): accents in the bed's key on every join, a room tone from
|
|
410
|
+
// the take's own quiet, J and L cuts through silence. None of these keys is in a brief without the switch
|
|
411
|
+
const sound = []
|
|
412
|
+
if (brief.accent) sound.push(...storyClips.slice(1).map((c) => ({ op: "add_sfx", asset: brief.accent, peak_at: { clip: c.id, edge: "start" } })))
|
|
413
|
+
if (brief.ambience) {
|
|
414
|
+
const quiet = quietStretch(index.words, asset, facts.duration)
|
|
415
|
+
if (quiet) sound.push({ op: "room_tone", asset, from: quiet.from, to: quiet.to })
|
|
416
|
+
else notes.push("No room tone: the take has no second of quiet between its words to make one from.")
|
|
417
|
+
}
|
|
418
|
+
if (brief.splits) {
|
|
419
|
+
const played = []
|
|
420
|
+
for (const p of solve(step.project, index).picture) {
|
|
421
|
+
if (p.hold) continue
|
|
422
|
+
if (played.at(-1)?.clip === p.clip) played.at(-1).out = p.out
|
|
423
|
+
else played.push({ clip: p.clip, asset: p.asset, in: p.in, out: p.out })
|
|
424
|
+
}
|
|
425
|
+
sound.push(...splitOps(played.filter((p) => storyClips.some((c) => c.id === p.clip)), index.words))
|
|
426
|
+
}
|
|
427
|
+
const all = [...ops, ...style, ...angles, ...punches, ...framing, ...grading, ...cleaning, ...broll, ...titles, ...scenes.ops, ...graphics.ops, ...captions, ...music, ...sounds, ...ramps, ...joins, ...sound]
|
|
329
428
|
step = apply(project, all, { index, author: "agent" })
|
|
330
429
|
if (!step.applied) throw new Error(`The reel was refused: ${step.diagnostics[0].message}`)
|
|
331
|
-
|
|
430
|
+
// TP6: a reference's grain, corners and bars over the whole film, only when this brief carries them (EH-59)
|
|
431
|
+
if (brief.fx?.length) step = referenceLook({ project, all, step, fx: brief.fx, index, notes })
|
|
432
|
+
// B-roll on the beat (TP10): each moved later to the music's nearest beat within reach, inside its host clip.
|
|
433
|
+
// Only the B-roll moves: the picture and the words under it stay where they are
|
|
434
|
+
if (brief.beatJoins && music.length && broll.length) {
|
|
435
|
+
const plan = compile(step.project, index, { engineVersion: "beats", runtimeVersion: "beats" })
|
|
436
|
+
const beats = timelineBeats(plan.audio.items.find((item) => busOf(item.role) === "music"), index.beats ?? [])
|
|
437
|
+
const placed = solve(step.project, index).picture
|
|
438
|
+
let moved = 0
|
|
439
|
+
for (const op of broll) {
|
|
440
|
+
const host = placed.filter((p) => p.clip === op.at.clip)
|
|
441
|
+
if (!host.length) continue
|
|
442
|
+
const [start, end] = [Math.min(...host.map((p) => p.at)), Math.max(...host.map((p) => p.end))]
|
|
443
|
+
const at = onBeat(start, end, op.duration, beats)
|
|
444
|
+
if (at !== start) (op.at = at), moved++
|
|
445
|
+
}
|
|
446
|
+
if (moved) {
|
|
447
|
+
step = apply(project, all, { index, author: "agent" })
|
|
448
|
+
if (!step.applied) throw new Error(`The reel was refused: ${step.diagnostics[0].message}`)
|
|
449
|
+
notes.push(`${moved} B-roll cutaway${moved === 1 ? " lands" : "s land"} on the music's beat.`)
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return { ops: all, project: step.project, notes, calls, slots, story: { hook: story.value.hook ?? null, drop: story.value.drop ?? [], emphasis: { most, ids: [...new Set(emphasis.value.emphasis)].slice(0, most) } } }
|
|
332
453
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// A reference's look on a cut (TP6, CRAFT_UPGRADE §4.2), only when the make's own brief carries it:
|
|
2
|
+
// grain, darker corners and bars as adjustments over the whole film, each a row of the effects
|
|
3
|
+
// registry (TP5). Each hangs on the cut's first clip, so the next make finds it and takes it out
|
|
4
|
+
// with that clip (audit §6 rule 6). One that doesn't fit (restraint, a missing filter, the effects
|
|
5
|
+
// switch off) is left out with a note and never fails the make (rule 7).
|
|
6
|
+
|
|
7
|
+
import { EFFECTS } from "../core/effects.js"
|
|
8
|
+
import { apply } from "../core/ops.js"
|
|
9
|
+
import { solve } from "../core/solver.js"
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {{ project: object, all: object[], step: { project: object }, fx: { effect: string, params?: object }[], index: object, notes: string[] }} input `all` gains the operations that were taken
|
|
13
|
+
* @returns {{ project: object, applied: true }} the step to go on from
|
|
14
|
+
*/
|
|
15
|
+
export function referenceLook({ project, all, step, fx, index, notes }) {
|
|
16
|
+
const timeline = solve(step.project, index)
|
|
17
|
+
const first = timeline.picture.find((p) => !p.hold)
|
|
18
|
+
if (!first) return step
|
|
19
|
+
for (const { effect, params } of fx) {
|
|
20
|
+
if (!Object.hasOwn(EFFECTS, effect)) continue
|
|
21
|
+
const op = { op: "add_adjustment", at: { clip: first.clip, edge: "start" }, duration: timeline.duration, effect, ...(params ? { params } : {}) }
|
|
22
|
+
const tried = apply(project, [...all, op], { index, author: "agent" })
|
|
23
|
+
if (tried.applied) {
|
|
24
|
+
all.push(op)
|
|
25
|
+
step = tried
|
|
26
|
+
} else notes.push(`The reference's ${EFFECTS[effect].label.toLowerCase()} was left out: ${tried.diagnostics[0]?.message ?? "it doesn't fit this cut"}.`)
|
|
27
|
+
}
|
|
28
|
+
return step
|
|
29
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { apply } from "../core/ops.js"
|
|
9
9
|
import { compile } from "../core/plan.js"
|
|
10
|
-
import {
|
|
10
|
+
import { ALL_LOOKS, pageLimits, pages } from "../engine/captions.js"
|
|
11
11
|
import { candidateLines, fitLines, runsOf } from "./reel.js"
|
|
12
12
|
|
|
13
13
|
const FLICKS = 705_600_000
|
|
@@ -29,7 +29,7 @@ export const SHORT_FROM_LONG = {
|
|
|
29
29
|
/** With captions asked for, they burn in and the text gates run, as for the reel (ED8). */
|
|
30
30
|
export function deliverableFor(brief = {}) {
|
|
31
31
|
const base = SHORT_FROM_LONG.deliverable
|
|
32
|
-
return
|
|
32
|
+
return ALL_LOOKS[brief.captions] ? { ...base, burnCaptions: true, gates: [...base.gates, "QG-08", "QG-09", "QG-10"].sort() } : base
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// Openers that lean on something said before: a short that starts here starts mid-thought
|
|
@@ -229,7 +229,7 @@ export function planShort({ project, index, asset, brief = {}, variant = {} }) {
|
|
|
229
229
|
if (!subject) notes.push("No face track for this recording, so the frame holds the centre.")
|
|
230
230
|
const clips = step.project.sequences.find((q) => q.id === step.project.active).clips.filter((c) => base.has(c.track))
|
|
231
231
|
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)) }))
|
|
232
|
-
const captions =
|
|
232
|
+
const captions = ALL_LOOKS[brief.captions] ? best.lines.flatMap((l) => runsOf(l, recipe.joinGap)).flatMap((run) => pages(run, pageLimits(brief.captions))).map((ids) => ({ op: "caption_style", look: brief.captions, words: ids })) : []
|
|
233
233
|
const all = [...ops, ...framing, ...captions]
|
|
234
234
|
const done = apply(project, all, { index, author: "agent" })
|
|
235
235
|
if (!done.applied) throw new Error(`The short was refused: ${done.diagnostics[0].message}`)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// The make's sound, arranged to the cut (TP10, CRAFT_UPGRADE §8, EDD-69), behind editing.craft and only
|
|
2
|
+
// when the make's own brief asks (audit rule 4). Every sound is still one Kriya wrote. Code knows where
|
|
3
|
+
// every join is, so an accent in the bed's key lands on each; a quiet bed comes from the take's own
|
|
4
|
+
// silence; J and L cuts let a voice lead or trail its picture only through silence, never into a word;
|
|
5
|
+
// and B-roll lands on the music's beat, which moves no word, since the picture under it doesn't move.
|
|
6
|
+
|
|
7
|
+
const FLICKS = 705_600_000
|
|
8
|
+
export const SPLIT_MAX = Math.round(0.15 * FLICKS) // how far a J or L cut leads or trails
|
|
9
|
+
const MARGIN = Math.round(0.04 * FLICKS) // kept clear of a word on either side
|
|
10
|
+
const QUIET_MIN = Math.round(1.2 * FLICKS) // the shortest gap between words that can be a room tone
|
|
11
|
+
const BEAT_REACH = Math.round(0.25 * FLICKS) // how far a B-roll may move to meet a beat, later only
|
|
12
|
+
|
|
13
|
+
/** The take's quietest stretch: its longest gap between words, less a margin at each end; null if none is long enough. */
|
|
14
|
+
export function quietStretch(words, asset, length) {
|
|
15
|
+
const own = words.filter((w) => w.asset === asset).sort((a, b) => a.start - b.start)
|
|
16
|
+
const gaps = []
|
|
17
|
+
let from = 0
|
|
18
|
+
for (const w of own) {
|
|
19
|
+
gaps.push({ from, to: w.start })
|
|
20
|
+
from = Math.max(from, w.end)
|
|
21
|
+
}
|
|
22
|
+
if (length !== undefined) gaps.push({ from, to: length })
|
|
23
|
+
const best = gaps.filter((g) => g.to - g.from >= QUIET_MIN).sort((a, b) => b.to - b.from - (a.to - a.from) || a.from - b.from)[0]
|
|
24
|
+
return best ? { from: best.from + Math.round(0.2 * FLICKS), to: best.to - Math.round(0.2 * FLICKS) } : null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* J and L cuts at the story's joins: the incoming clip's voice leads its picture (J) where the take is silent
|
|
29
|
+
* before its first word, else the outgoing one trails (L) where it is silent after its last. Never more than
|
|
30
|
+
* the silence less a margin, never more than SPLIT_MAX, so the extra sound is room, not speech.
|
|
31
|
+
* @param {{ clip: string, asset: string, in: number, out: number }[]} played the story's clips as they play, in order
|
|
32
|
+
*/
|
|
33
|
+
export function splitOps(played, words) {
|
|
34
|
+
const ops = []
|
|
35
|
+
const sorted = [...words].sort((a, b) => a.start - b.start)
|
|
36
|
+
for (let i = 1; i < played.length; i++) {
|
|
37
|
+
const [a, b] = [played[i - 1], played[i]]
|
|
38
|
+
// J: the incoming voice starts this much before its picture, through the silence before b's cut point
|
|
39
|
+
const before = sorted.filter((w) => w.asset === b.asset && w.end <= b.in).at(-1)
|
|
40
|
+
const lead = Math.min(SPLIT_MAX, b.in - (before?.end ?? 0) - MARGIN)
|
|
41
|
+
if (lead >= MARGIN) {
|
|
42
|
+
ops.push({ op: "trim", clip: b.clip, audioLead: Math.round(lead) })
|
|
43
|
+
continue
|
|
44
|
+
}
|
|
45
|
+
// L: the outgoing voice trails its picture, through the silence after a's cut point
|
|
46
|
+
const after = sorted.find((w) => w.asset === a.asset && w.start >= a.out)
|
|
47
|
+
const lag = after ? Math.min(SPLIT_MAX, after.start - a.out - MARGIN) : 0
|
|
48
|
+
if (lag >= MARGIN) ops.push({ op: "trim", clip: a.clip, audioLag: Math.round(lag) })
|
|
49
|
+
}
|
|
50
|
+
return ops
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The music's beats where they play on the timeline, through a fitted bed's pieces and their crossfades. */
|
|
54
|
+
export function timelineBeats(item, beats) {
|
|
55
|
+
if (!item) return []
|
|
56
|
+
const own = beats.filter((b) => b.asset === item.asset).map((b) => b.t)
|
|
57
|
+
const pieces = item.fit?.segments?.length ? item.fit.segments : [{ in: item.in, out: item.out }]
|
|
58
|
+
const out = []
|
|
59
|
+
let start = item.at
|
|
60
|
+
for (const [i, piece] of pieces.entries()) {
|
|
61
|
+
for (const t of own) if (t >= piece.in && t < piece.out) out.push(start + (t - piece.in))
|
|
62
|
+
start += piece.out - piece.in - (i < pieces.length - 1 ? (item.fit?.crossfade ?? 0) : 0)
|
|
63
|
+
}
|
|
64
|
+
return out.filter((t) => t >= item.at && t < item.end).sort((x, y) => x - y)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** A B-roll start moved later onto the nearest beat within reach, inside its host clip; unchanged otherwise. */
|
|
68
|
+
export function onBeat(start, hostEnd, length, beats) {
|
|
69
|
+
const beat = beats.find((t) => t >= start && t - start <= BEAT_REACH)
|
|
70
|
+
return beat !== undefined && beat + length <= hostEnd ? beat : start
|
|
71
|
+
}
|
package/src/edit/runtime/cli.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// `kriya edit setup` and `kriya edit doctor`, loaded only with the switch on.
|
|
2
2
|
|
|
3
|
+
import { spawn } from "node:child_process"
|
|
4
|
+
|
|
3
5
|
import { KriyaError } from "../../api.js"
|
|
4
6
|
import { kriyaHome } from "../../paths.js"
|
|
5
7
|
import { readDevice } from "../../store.js"
|
|
@@ -9,7 +11,7 @@ import { RuntimeError } from "./manifest.js"
|
|
|
9
11
|
import { install, installPack, removePack, rollback } from "./setup.js"
|
|
10
12
|
|
|
11
13
|
const USAGE = `Usage:
|
|
12
|
-
kriya edit
|
|
14
|
+
kriya edit [--no-open] open the Editing Studio in your browser (--no-open: only print its link)
|
|
13
15
|
kriya edit setup [--rollback] install the Media Runtime, or go back to the last one
|
|
14
16
|
kriya edit setup --pack <name> add a capability pack (color, voice-clean, depth)
|
|
15
17
|
kriya edit setup --remove-pack <name>
|
|
@@ -22,12 +24,31 @@ const USAGE = `Usage:
|
|
|
22
24
|
with no folder, list them. Nothing runs until you tap the card
|
|
23
25
|
kriya edit unwatch <folder> stop`
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
/** The Studio's one-time link in the person's own browser, as `kriya login` opens its page. No browser: the printed link is enough. */
|
|
28
|
+
export function openInBrowser(url, { platform = process.platform, run = spawn } = {}) {
|
|
29
|
+
const [command, args] = platform === "darwin" ? ["open", [url]] : platform === "win32" ? ["cmd", ["/c", "start", "", url]] : ["xdg-open", [url]]
|
|
26
30
|
try {
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
run(command, args, { stdio: "ignore", detached: true }).on("error", () => {}).unref()
|
|
32
|
+
return true
|
|
33
|
+
} catch {
|
|
34
|
+
return false
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function editCommand([action, ...rest], { say = (line) => process.stdout.write(`${line}\n`), open = openInBrowser, interactive = process.stdout.isTTY === true, host = () => import("../host/client.js") } = {}) {
|
|
39
|
+
try {
|
|
40
|
+
// Typed in a terminal, `kriya edit` opens the Studio itself, never the harness's Web UI. Piped (a script)
|
|
41
|
+
// or with --no-open, it prints only the link, as it always did
|
|
42
|
+
if (action === undefined || (action === "--no-open" && rest.length === 0)) {
|
|
43
|
+
const { ensureHost, hostCall } = await host()
|
|
29
44
|
await ensureHost()
|
|
30
|
-
|
|
45
|
+
const { url } = await hostCall(kriyaHome(), "POST", "/internal/launch")
|
|
46
|
+
if (action === "--no-open" || !interactive) {
|
|
47
|
+
say(url)
|
|
48
|
+
return 0
|
|
49
|
+
}
|
|
50
|
+
say(`Opening the Kriya Editing Studio in your browser. If it didn't open, this link works once, for a short while:\n${url}`)
|
|
51
|
+
open(url)
|
|
31
52
|
return 0
|
|
32
53
|
}
|
|
33
54
|
if ((action === "watch" && rest.length <= 1) || (action === "unwatch" && rest.length === 1)) {
|
|
@@ -7,14 +7,15 @@ import { openManifest, RuntimeError, TRUSTED_KEYS } from "./manifest.js"
|
|
|
7
7
|
/**
|
|
8
8
|
* What this Kriya has switched on for editing (EH-01). Any failure, a server with no such
|
|
9
9
|
* route among them, means off: the server ships first, and a client never assumes (track E rule 17).
|
|
10
|
-
* @returns {Promise<{ visuals: boolean, playbooks: boolean, mediaSearch: boolean }>}
|
|
10
|
+
* @returns {Promise<{ visuals: boolean, playbooks: boolean, mediaSearch: boolean, motion: boolean, customMotion: boolean, assembly: boolean }>}
|
|
11
11
|
*/
|
|
12
12
|
export async function fetchFeatures(device) {
|
|
13
13
|
try {
|
|
14
14
|
const found = await call(device.url, "GET", "/editing/features", { token: device.token })
|
|
15
|
-
|
|
15
|
+
// motion, customMotion, assembly, livePreview, intent, craft, typeKit, referenceIntent, directorLoop, taviOrder: a server from before them says nothing, which is off
|
|
16
|
+
return { visuals: found?.visuals === true, playbooks: found?.playbooks === true, mediaSearch: found?.mediaSearch === true, motion: found?.motion === true, customMotion: found?.customMotion === true, assembly: found?.assembly === true, livePreview: found?.livePreview === true, intent: found?.intent === true, craft: found?.craft === true, typeKit: found?.typeKit === true, referenceIntent: found?.referenceIntent === true, directorLoop: found?.directorLoop === true, taviOrder: found?.taviOrder === true }
|
|
16
17
|
} catch {
|
|
17
|
-
return { visuals: false, playbooks: false, mediaSearch: false }
|
|
18
|
+
return { visuals: false, playbooks: false, mediaSearch: false, motion: false, customMotion: false, assembly: false, livePreview: false, intent: false, craft: false, typeKit: false, referenceIntent: false, directorLoop: false, taviOrder: false }
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -65,7 +65,13 @@ export function manifestLicenceProblems(data) {
|
|
|
65
65
|
for (const [platform, spec] of Object.entries(data?.platforms ?? {})) {
|
|
66
66
|
for (const artifact of spec.artifacts ?? []) check(`${platform}/${artifact.id}`, artifact.licence, "runtime")
|
|
67
67
|
for (const pkg of spec.python?.packages ?? []) check(`${platform}/python/${pkg.name}`, pkg.licence, "runtime")
|
|
68
|
-
for (const [pack, offered] of Object.entries(spec.packs ?? {}))
|
|
68
|
+
for (const [pack, offered] of Object.entries(spec.packs ?? {})) {
|
|
69
|
+
for (const artifact of offered.artifacts ?? []) {
|
|
70
|
+
check(`${platform}/${pack}/${artifact.id}`, artifact.licence, "weight")
|
|
71
|
+
// The table allows OFL-1.1 for fonts only (TP7): anywhere but the font pack it isn't a font
|
|
72
|
+
if (pack !== "pack-fonts" && /\bOFL-/.test(artifact.licence ?? "")) problems.push({ item: `${platform}/${pack}/${artifact.id}`, problem: "OFL-1.1 is allowed for fonts only, and this isn't the font pack" })
|
|
73
|
+
}
|
|
74
|
+
}
|
|
69
75
|
}
|
|
70
76
|
return problems
|
|
71
77
|
}
|
package/src/explore.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { createHash } from "node:crypto"
|
|
2
|
+
import { readFileSync } from "node:fs"
|
|
3
|
+
import { join } from "node:path"
|
|
4
|
+
|
|
5
|
+
import { CONTRACTS_DIR } from "./contracts.js"
|
|
6
|
+
|
|
7
|
+
// Harness 2.0 W14 (WD-18): Explore (Kriya-Tavi docs/kriya-harness/upgrade_2.0/
|
|
8
|
+
// THREE_D_AND_CREATIVE.md §5). A creative step marked `explore: 2 | 3` builds
|
|
9
|
+
// that many takes one after another in the same folder (a builder can't get
|
|
10
|
+
// its own directory), each from the step's starting files and each in a
|
|
11
|
+
// different direction chosen here, by code, so diversity isn't left to
|
|
12
|
+
// sampling. Only gates decide pass; the person (or, with no UI, the critic)
|
|
13
|
+
// picks among passing takes. Pure helpers; src/loop.js runs the takes.
|
|
14
|
+
|
|
15
|
+
export const EXPLORE_ROLES = Object.freeze(["frontend", "designer", "graphics"])
|
|
16
|
+
export const MIN_TAKES = 2
|
|
17
|
+
export const MAX_TAKES = 3
|
|
18
|
+
export const RELOAD_MS = 20_000
|
|
19
|
+
|
|
20
|
+
/** THREE_D_AND_CREATIVE §3's lighting recipes, in table order (graphics). */
|
|
21
|
+
export const SCENE_DIRECTIONS = Object.freeze([
|
|
22
|
+
["studio-product", "Studio product: an HDR studio environment with a soft key and a rim light, a contact shadow, filmic tone mapping (AgX or ACES)."],
|
|
23
|
+
["daylight-exterior", "Daylight exterior: a sky environment and one directional sun with a single shadow, filmic tone mapping."],
|
|
24
|
+
["night-neon", "Night and neon: a dark environment, emissive materials, restrained bloom, neutral tone mapping."],
|
|
25
|
+
["soft-clay", "Soft clay, illustrative: an ambient environment and one soft key, no hard shadows, neutral tone mapping."],
|
|
26
|
+
["data-abstract", "Data and abstract: unlit or minimal light, instanced points and lines, no or neutral tone mapping."],
|
|
27
|
+
])
|
|
28
|
+
/** Visual directions for interface steps (frontend, designer), in table order. */
|
|
29
|
+
export const UI_DIRECTIONS = Object.freeze([
|
|
30
|
+
["editorial", "Editorial: generous whitespace, one strong typeface in two weights, restrained colour, content first."],
|
|
31
|
+
["precise", "Dense and precise: compact spacing on a strict grid, tabular figures, quiet colour, information first."],
|
|
32
|
+
["warm", "Warm and soft: rounded shapes, gentle tinted surfaces, friendly copy, generous touch targets."],
|
|
33
|
+
["bold", "Bold: high contrast, large display type, one confident accent colour, strong hierarchy."],
|
|
34
|
+
])
|
|
35
|
+
|
|
36
|
+
const readJson = (root, file) => {
|
|
37
|
+
try {
|
|
38
|
+
return JSON.parse(readFileSync(join(root, CONTRACTS_DIR, file), "utf8"))
|
|
39
|
+
} catch {
|
|
40
|
+
return undefined
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The takes' direction hints, by code: the first is the contract's own
|
|
46
|
+
* direction (scene_direction.json `lighting` for graphics, design_tokens.json
|
|
47
|
+
* `direction` for interface steps), the others its two neighbours in the table.
|
|
48
|
+
* @returns {Array<{ id: string, text: string }>}
|
|
49
|
+
*/
|
|
50
|
+
export function directionHints(role, takes, root) {
|
|
51
|
+
const table = role === "graphics" ? SCENE_DIRECTIONS : UI_DIRECTIONS
|
|
52
|
+
const named = role === "graphics" ? readJson(root, "scene_direction.json")?.lighting : readJson(root, "design_tokens.json")?.direction
|
|
53
|
+
const at = Math.max(0, table.findIndex(([id]) => id === named))
|
|
54
|
+
const order = [at, (at + 1) % table.length, (at - 1 + table.length) % table.length]
|
|
55
|
+
return order.slice(0, takes).map((i) => ({ id: table[i][0], text: table[i][1] }))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The section a take's builder gets after its normal prompt. */
|
|
59
|
+
export const takeSection = (take, of, hint) =>
|
|
60
|
+
[
|
|
61
|
+
`## This is take ${take} of ${of}`,
|
|
62
|
+
"",
|
|
63
|
+
`The person will compare ${of} takes of this step side by side and keep one. Build the whole step, fully working, in this direction:`,
|
|
64
|
+
"",
|
|
65
|
+
hint.text,
|
|
66
|
+
"",
|
|
67
|
+
"Commit to it: a half-way take loses the comparison. The checks still decide pass or fail; the direction never excuses a failing check.",
|
|
68
|
+
].join("\n")
|
|
69
|
+
|
|
70
|
+
/** What a served route looks like now: its ETag or Last-Modified, else a hash of its body. */
|
|
71
|
+
export async function fingerprint(url, fetchImpl = fetch) {
|
|
72
|
+
const r = await fetchImpl(url, { cache: "no-store", redirect: "manual" })
|
|
73
|
+
const tag = r.headers.get("etag") ?? r.headers.get("last-modified")
|
|
74
|
+
return tag ? `h:${tag}` : `b:${createHash("sha256").update(Buffer.from(await r.arrayBuffer())).digest("hex")}`
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Waits until the dev server serves something other than `before` (its file
|
|
79
|
+
* watcher reloaded the take), up to RELOAD_MS.
|
|
80
|
+
* shortcut: fingerprints the route itself, not its main module; upgrade if a dev server serves an unchanged HTML shell for changed modules.
|
|
81
|
+
* @returns {Promise<{ ok: true } | { ok: false, reason: string }>}
|
|
82
|
+
*/
|
|
83
|
+
export async function waitForReload(url, before, { timeoutMs = RELOAD_MS, everyMs = 250, fetchImpl = fetch, now = Date.now, sleep = (ms) => new Promise((r) => setTimeout(r, ms)) } = {}) {
|
|
84
|
+
const until = now() + timeoutMs
|
|
85
|
+
for (;;) {
|
|
86
|
+
try {
|
|
87
|
+
if ((await fingerprint(url, fetchImpl)) !== before) return { ok: true }
|
|
88
|
+
} catch {
|
|
89
|
+
// Reloading: try again
|
|
90
|
+
}
|
|
91
|
+
if (now() >= until) return { ok: false, reason: "dev server didn't reload" }
|
|
92
|
+
await sleep(everyMs)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The person's choice among passing takes: one option per take, in take order. */
|
|
97
|
+
export const takeQuestion = (survivors, stepTitle) => ({
|
|
98
|
+
id: "kriya-explore",
|
|
99
|
+
header: "Explore",
|
|
100
|
+
question: `Which take of "${stepTitle}" do you want to keep?`,
|
|
101
|
+
detail: "Every take shown passed the project's check and its gates. The others stay in kriya undo --list.",
|
|
102
|
+
options: survivors.map((t) => ({ label: `Take ${t.v}`, description: t.hint.text })),
|
|
103
|
+
})
|
package/src/failure.js
CHANGED
|
@@ -20,7 +20,7 @@ export const CLASSES = [
|
|
|
20
20
|
]
|
|
21
21
|
|
|
22
22
|
// The order a fix can move through: lower is further from passing
|
|
23
|
-
export const RANK = { timeout: 0, environment: 0, syntax: 1, type: 2, unknown: 2, assertion: 3, "tests changed": 3, silenced: 3, "invariant broken": 3, acceptance: 3, "no reproduction": 3, "invariant violated": 3, "regression hazard": 3, "no negative test": 3, "premortem open": 3, pass: 4 }
|
|
23
|
+
export const RANK = { timeout: 0, environment: 0, syntax: 1, type: 2, unknown: 2, assertion: 3, "tests changed": 3, silenced: 3, "invariant broken": 3, acceptance: 3, "no reproduction": 3, "invariant violated": 3, "regression hazard": 3, "no negative test": 3, "premortem open": 3, gate: 3, "contract changed": 3, flaky: 3, "not checked": 0, pass: 4 }
|
|
24
24
|
|
|
25
25
|
const EXCERPT = 2500
|
|
26
26
|
|