rushes 0.10.1 → 0.12.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/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +14 -4
- package/README.md +14 -8
- package/dist/cli/demo.js +3 -2
- package/dist/cli/main.js +33 -1
- package/dist/core/agentRules.js +7 -0
- package/dist/core/balance.js +238 -0
- package/dist/core/batches.js +29 -11
- package/dist/core/exportNotes.js +4 -2
- package/dist/core/films.js +114 -0
- package/dist/core/log.js +35 -3
- package/dist/core/logEvents.js +7 -7
- package/dist/core/notes.js +19 -1
- package/dist/core/schema.js +69 -14
- package/dist/core/script.js +67 -0
- package/dist/core/tabs.js +15 -7
- package/dist/core/takes.js +1 -1
- package/dist/mcp/tools.js +90 -23
- package/dist/server/agent/adapters.js +39 -8
- package/dist/server/agent/rules.js +106 -9
- package/dist/server/agent/runner.js +135 -35
- package/dist/server/agent/setupOnce.js +44 -0
- package/dist/server/app.js +348 -65
- package/dist/server/assets.js +40 -14
- package/dist/server/balance.js +103 -0
- package/dist/server/brief.js +9 -7
- package/dist/server/files.js +3 -2
- package/dist/server/films.js +43 -0
- package/dist/server/found.js +2 -1
- package/dist/server/logbook.js +28 -2
- package/dist/server/plans.js +68 -0
- package/dist/server/record.js +31 -13
- package/dist/server/start.js +15 -7
- package/dist/server/storyboard.js +8 -6
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/rushes/SKILL.md +4 -4
- package/web-dist/assets/{index-BIJlv6zN.css → index-BCYA0Awp.css} +1 -1
- package/web-dist/assets/index-LPvsS2vO.js +70 -0
- package/web-dist/index.html +2 -2
- package/web-dist/assets/index-D430jOsg.js +0 -70
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// §31: everything on the desk belongs to a film. With a film selected, every tab shows only that film's material.
|
|
2
|
+
// The one exception is Visuals, which stay project-wide (campaign material) and show on every film as shared.
|
|
3
|
+
// Nothing is on no film: a note, take or file that names none is the project's first film's (`videos[0]`), and the
|
|
4
|
+
// one-time move (server/films.ts) writes that down.
|
|
5
|
+
import { RushesError } from "./errors.js";
|
|
6
|
+
import { slugify } from "./ids.js";
|
|
7
|
+
import { toSchema2 } from "./script.js";
|
|
8
|
+
import { variantFilms } from "./schema.js";
|
|
9
|
+
/** The project's first film, whose the old project-wide plan files and anything on no film are (§31.2.1, §31.2.4). */
|
|
10
|
+
export function firstFilm(project) {
|
|
11
|
+
return project.videos[0]?.id ?? null;
|
|
12
|
+
}
|
|
13
|
+
/** Whether something that names `own` (a film id, or none) is on `film`. On no film is on the first film. */
|
|
14
|
+
function ownsFilm(own, film, videos) {
|
|
15
|
+
return own ? own === film : videos.length === 0 || videos[0].id === film;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* §31.5: whether a note shows on `film`. A note on a visual shows on every film (Visuals are shared, §31.2.3); any
|
|
19
|
+
* other note is its film's, and one that names none is the first film's. With no film named, every note.
|
|
20
|
+
*/
|
|
21
|
+
export function noteOnFilm(note, film, videos) {
|
|
22
|
+
if (!film || note.stage === "visuals")
|
|
23
|
+
return true;
|
|
24
|
+
return ownsFilm(note.video, film, videos);
|
|
25
|
+
}
|
|
26
|
+
/** A registered file's film: its own, or (naming none) the first film's. */
|
|
27
|
+
export function fileOnFilm(file, film, videos) {
|
|
28
|
+
return !film || ownsFilm(file.video, film, videos);
|
|
29
|
+
}
|
|
30
|
+
export const BRIEF_NAME = "brief.md";
|
|
31
|
+
export const STORYBOARD_NAME = "storyboard.md";
|
|
32
|
+
/** The folder every film but the first keeps its own plan files in: films/<film-id>/. */
|
|
33
|
+
export const FILMS_DIR = "films";
|
|
34
|
+
/** The paths of a film's plan files (§31.3): the root's for the first film or no film, else films/<film-id>/. */
|
|
35
|
+
export function filmPlace(project, video) {
|
|
36
|
+
const first = firstFilm(project);
|
|
37
|
+
const film = video ?? first;
|
|
38
|
+
if (film === null || film === first)
|
|
39
|
+
return { video: film, first: true, brief: BRIEF_NAME, storyboard: STORYBOARD_NAME, slot: null };
|
|
40
|
+
return { video: film, first: false, brief: `${FILMS_DIR}/${film}/${BRIEF_NAME}`, storyboard: `${FILMS_DIR}/${film}/${STORYBOARD_NAME}`, slot: film };
|
|
41
|
+
}
|
|
42
|
+
/** How a film is named back: "Five views (five-views)". */
|
|
43
|
+
const filmWords = (v) => (v.name === v.id ? v.id : `${v.name} (${v.id})`);
|
|
44
|
+
/** §31.6: a film's material asked for without saying which film, in a project with several. Lists them. */
|
|
45
|
+
export class FilmRequiredError extends RushesError {
|
|
46
|
+
constructor(videos, what = "this") {
|
|
47
|
+
super(`This project has ${videos.length} films, so say which one ${what} is for: ${videos.map(filmWords).join(", ")}.`, 400, "film_required", { films: videos.map((v) => ({ id: v.id, name: v.name })) });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The film a request is about (§31.6): the one it names (an id or a name, as resolveVideo reads them), or, naming none,
|
|
52
|
+
* the only film. With several and none named, a FilmRequiredError that lists them. Null while there is no film.
|
|
53
|
+
*/
|
|
54
|
+
export function chooseFilm(project, given, what) {
|
|
55
|
+
if (given) {
|
|
56
|
+
const slug = slugify(given);
|
|
57
|
+
const v = project.videos.find((x) => x.id === given) ?? project.videos.find((x) => x.id === slug) ?? project.videos.find((x) => x.name.toLowerCase() === given.toLowerCase());
|
|
58
|
+
if (!v)
|
|
59
|
+
throw new RushesError(`No film "${given}". Films: ${project.videos.map(filmWords).join(", ") || "none yet"}.`, 404, "not_found", { films: project.videos.map((x) => ({ id: x.id, name: x.name })) });
|
|
60
|
+
return v;
|
|
61
|
+
}
|
|
62
|
+
if (project.videos.length > 1)
|
|
63
|
+
throw new FilmRequiredError(project.videos, what);
|
|
64
|
+
return project.videos[0] ?? null;
|
|
65
|
+
}
|
|
66
|
+
export const movedAnything = (m) => m.notes + m.takes + m.files > 0 || m.script;
|
|
67
|
+
/**
|
|
68
|
+
* §31.4, on drafts: gives the first film every note on no film (except a visual's), every read, bed and pass on no
|
|
69
|
+
* film, every registered file on no film, and a schema 1 script (as schema 2). Only with two or more films; a second
|
|
70
|
+
* run finds nothing. Visuals (visuals.json) are never touched.
|
|
71
|
+
*/
|
|
72
|
+
export function moveToFirstFilm(d, film, filmCount) {
|
|
73
|
+
const moved = { film, notes: 0, takes: 0, files: 0, sections: 0, script: false };
|
|
74
|
+
if (filmCount < 2)
|
|
75
|
+
return moved;
|
|
76
|
+
for (const n of d.notes?.notes ?? []) {
|
|
77
|
+
if (n.video || n.stage === "visuals")
|
|
78
|
+
continue;
|
|
79
|
+
n.video = film.id;
|
|
80
|
+
moved.notes += 1;
|
|
81
|
+
}
|
|
82
|
+
for (const lane of d.project?.lanes ?? []) {
|
|
83
|
+
for (const v of lane.variants) {
|
|
84
|
+
if (variantFilms(v).length > 0)
|
|
85
|
+
continue;
|
|
86
|
+
v.videos = [film.id];
|
|
87
|
+
moved.takes += 1;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (const f of d.project?.files ?? []) {
|
|
91
|
+
if (f.video)
|
|
92
|
+
continue;
|
|
93
|
+
f.video = film.id;
|
|
94
|
+
moved.files += 1;
|
|
95
|
+
}
|
|
96
|
+
if (d.script?.schema === 1) {
|
|
97
|
+
moved.sections = d.script.sections.length;
|
|
98
|
+
toSchema2(d.script, film.id);
|
|
99
|
+
moved.script = true;
|
|
100
|
+
}
|
|
101
|
+
return moved;
|
|
102
|
+
}
|
|
103
|
+
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
104
|
+
/** The one Activity line the move writes: "Moved to Meet your agents: 3 notes, 2 takes and the script (4 sections)". */
|
|
105
|
+
export function movedText(m) {
|
|
106
|
+
const parts = [
|
|
107
|
+
m.notes ? plural(m.notes, "note", "notes") : "",
|
|
108
|
+
m.takes ? plural(m.takes, "take", "takes") : "",
|
|
109
|
+
m.files ? plural(m.files, "file", "files") : "",
|
|
110
|
+
m.script ? `the script (${plural(m.sections, "section", "sections")})` : "",
|
|
111
|
+
].filter(Boolean);
|
|
112
|
+
const list = parts.length > 1 ? `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}` : parts[0];
|
|
113
|
+
return `Moved to ${m.film.name}: ${list}, which were on no film`;
|
|
114
|
+
}
|
package/dist/core/log.js
CHANGED
|
@@ -5,6 +5,7 @@ import { newId } from "./ids.js";
|
|
|
5
5
|
import { oneLineOf } from "./labels.js";
|
|
6
6
|
import { STAGE_WORDS, cutEvent, fileEvent, notesSentEvent } from "./logEvents.js";
|
|
7
7
|
import { LOG_MAX, MERGE_MS, logText } from "./logText.js";
|
|
8
|
+
import { sectionsOf } from "./script.js";
|
|
8
9
|
/** The newest entry this event may merge into: same kind, area and writer, within the window (R4). */
|
|
9
10
|
function mergeTarget(entries, event, by, t) {
|
|
10
11
|
const window = event.windowMs ?? MERGE_MS;
|
|
@@ -17,7 +18,8 @@ function mergeTarget(entries, event, by, t) {
|
|
|
17
18
|
continue;
|
|
18
19
|
if (!(age <= window))
|
|
19
20
|
return -1; // older than the window, and so is everything before it
|
|
20
|
-
|
|
21
|
+
// §30: and about the same film, so one film's line never takes in another film's count or text.
|
|
22
|
+
if (e.kind === event.kind && e.area === event.area && e.by === by && (e.video ?? null) === (event.video ?? null))
|
|
21
23
|
return i;
|
|
22
24
|
}
|
|
23
25
|
return -1;
|
|
@@ -148,7 +150,7 @@ export function backfillLog(file, src, before) {
|
|
|
148
150
|
export function undatedRefs(project, script) {
|
|
149
151
|
const refs = [
|
|
150
152
|
...project.lanes.flatMap((l) => l.variants.map((v) => `${l.id}/${v.id}`)),
|
|
151
|
-
...script.
|
|
153
|
+
...sectionsOf(script).flatMap((s) => s.takes.map((t) => `${s.id}:${t.id}`)),
|
|
152
154
|
];
|
|
153
155
|
return refs.slice(0, LOG_MAX);
|
|
154
156
|
}
|
|
@@ -166,11 +168,39 @@ export function undatedLines(refs, ctx) {
|
|
|
166
168
|
const name = oneLineOf(lane.name);
|
|
167
169
|
out.push({ area: lane.stage, text: logText(name && name !== word ? `${word}: ${lane.name} (${n} ${noun})` : `${word}: ${n} ${noun}`) });
|
|
168
170
|
}
|
|
169
|
-
const sections = ctx.script.
|
|
171
|
+
const sections = sectionsOf(ctx.script).filter((s) => s.takes.some((t) => set.has(`${s.id}:${t.id}`))).length;
|
|
170
172
|
if (sections)
|
|
171
173
|
out.push({ area: "voice", text: `Voiceover: ${sections} section${sections === 1 ? "" : "s"} with takes` });
|
|
172
174
|
return out;
|
|
173
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* §30: the films a Change Log line is about. Its own film when it has one; for a line written before lines carried
|
|
178
|
+
* one, the films of the notes it names (a reply line's `notes:<ids>`) or of the take it is about (`<lane>/<variant>`).
|
|
179
|
+
* Empty: the line is about the whole project, or its film can't be told. The dashboard's copy is web/src/lib.ts.
|
|
180
|
+
*/
|
|
181
|
+
export function lineFilms(line, ctx) {
|
|
182
|
+
if (line.video)
|
|
183
|
+
return [line.video];
|
|
184
|
+
const ref = line.ref ?? "";
|
|
185
|
+
if (ref.startsWith("notes:")) {
|
|
186
|
+
const ids = new Set(ref.slice("notes:".length).split(","));
|
|
187
|
+
return [...new Set(ctx.notes.filter((n) => ids.has(n.id) && n.video).map((n) => n.video))];
|
|
188
|
+
}
|
|
189
|
+
const slash = ref.indexOf("/");
|
|
190
|
+
if (slash > 0) {
|
|
191
|
+
const variant = ctx.lanes.find((l) => l.id === ref.slice(0, slash))?.variants.find((v) => v.id === ref.slice(slash + 1));
|
|
192
|
+
if (variant)
|
|
193
|
+
return variant.videos ?? (variant.video === undefined ? [] : [variant.video]);
|
|
194
|
+
}
|
|
195
|
+
return [];
|
|
196
|
+
}
|
|
197
|
+
/** §30, §31.5: whether Activity on `film` shows a line: its own and the project's. With one film (or none) every line. */
|
|
198
|
+
export function lineOnFilm(line, film, ctx) {
|
|
199
|
+
if (!film || ctx.videos.length < 2)
|
|
200
|
+
return true;
|
|
201
|
+
const films = lineFilms(line, ctx);
|
|
202
|
+
return films.length === 0 || films.includes(film);
|
|
203
|
+
}
|
|
174
204
|
/** §22.7: the newest `limit` lines (default 30), newest first, matching `area` and `since`. */
|
|
175
205
|
export function logView(file, q, ctx) {
|
|
176
206
|
const asked = Number.isFinite(q.limit) ? Math.floor(q.limit) : 30;
|
|
@@ -183,6 +213,8 @@ export function logView(file, q, ctx) {
|
|
|
183
213
|
continue;
|
|
184
214
|
if (from !== null && !(Date.parse(e.at) > from))
|
|
185
215
|
continue;
|
|
216
|
+
if (q.video !== undefined && ctx.films && !lineOnFilm(e, q.video, ctx.films))
|
|
217
|
+
continue;
|
|
186
218
|
matching.push(e);
|
|
187
219
|
}
|
|
188
220
|
const undated = from !== null ? [] : undatedLines(file.undated, ctx).filter((l) => q.area === undefined || l.area === q.area);
|
package/dist/core/logEvents.js
CHANGED
|
@@ -122,9 +122,9 @@ export function takeEvent(section, take, number) {
|
|
|
122
122
|
many: (n, subject) => `Voiceover: ${plural(n, "take", "takes")} added${subject ? ` to ${subject}` : ""}`,
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
|
-
/** "Script set: 6 sections". */
|
|
126
|
-
export function scriptEvent(sections) {
|
|
127
|
-
return { area: "script", kind: "script", merge: "replace", text: `Script set: ${plural(sections, "section", "sections")}` };
|
|
125
|
+
/** "Script set: 6 sections". §31.2.1: a film's script line is that film's (`video`), so Activity shows it only there. */
|
|
126
|
+
export function scriptEvent(sections, video = null) {
|
|
127
|
+
return { area: "script", kind: "script", merge: "replace", ...(video ? { video, subject: video } : {}), text: `Script set: ${plural(sections, "section", "sections")}` };
|
|
128
128
|
}
|
|
129
129
|
/** `Picks: voice “Vo Jules, full read”, music “Night drive, held back”`, the whole set after the change; for one film, `Picks for “Key”: …`. */
|
|
130
130
|
export function picksEvent(project, lanes, video) {
|
|
@@ -162,7 +162,7 @@ export function filmEvent(video, shelved) {
|
|
|
162
162
|
return { area: "picture", kind: "film", merge: "replace", subject: video.id, text, video: video.id, version: null };
|
|
163
163
|
}
|
|
164
164
|
/** "3 notes sent from Picture"; on Script, "1 note and 2 script edits sent from Script"; from more than one tab, "5 notes sent from several tabs". */
|
|
165
|
-
export function notesSentEvent(batch) {
|
|
165
|
+
export function notesSentEvent(batch, video = null) {
|
|
166
166
|
const tab = batch.stage === null ? "" : TAB_NAMES[batch.stage];
|
|
167
167
|
const notes = batch.noteIds.length;
|
|
168
168
|
const edits = batch.sectionIds.length;
|
|
@@ -170,7 +170,7 @@ export function notesSentEvent(batch) {
|
|
|
170
170
|
? `${plural(notes, "note", "notes")} and ${plural(edits, "script edit", "script edits")}`
|
|
171
171
|
: edits ? plural(edits, "script edit", "script edits") : plural(notes, "note", "notes");
|
|
172
172
|
return {
|
|
173
|
-
area: "notes", kind: "notes-sent", merge: "count", count: Math.max(1, notes + edits), subject: tab, tab: batch.stage,
|
|
173
|
+
area: "notes", kind: "notes-sent", merge: "count", count: Math.max(1, notes + edits), subject: tab, tab: batch.stage, video,
|
|
174
174
|
text: `${what} sent from ${tab || "several tabs"}`,
|
|
175
175
|
many: (n, subject) => `${plural(n, "note", "notes")} sent from ${subject || "several tabs"}`,
|
|
176
176
|
};
|
|
@@ -191,12 +191,12 @@ function replyKey(ids) {
|
|
|
191
191
|
}
|
|
192
192
|
const doneIn = (text) => Number(/\((\d+) done\)/.exec(text)?.[1] ?? 0);
|
|
193
193
|
/** "Agent replied to 3 notes (2 done)"; replies in a burst are one line that counts every note (R4, final review I1). */
|
|
194
|
-
export function repliesEvent(notes) {
|
|
194
|
+
export function repliesEvent(notes, video = null) {
|
|
195
195
|
const said = (n, done) => `Agent replied to ${plural(n, "note", "notes")}${done ? ` (${done} done)` : ""}`;
|
|
196
196
|
const done = notes.filter((n) => n.status === "done").length;
|
|
197
197
|
const stages = new Set(notes.map((n) => n.stage));
|
|
198
198
|
return {
|
|
199
|
-
area: "notes", kind: "replies", merge: "count", count: Math.max(1, notes.length), tab: stages.size === 1 ? [...stages][0] : null,
|
|
199
|
+
area: "notes", kind: "replies", merge: "count", count: Math.max(1, notes.length), tab: stages.size === 1 ? [...stages][0] : null, video,
|
|
200
200
|
ref: replyKey(notes.map((n) => n.id)),
|
|
201
201
|
text: said(notes.length, done),
|
|
202
202
|
// The line says how many were done as it stood, so this call's are added to that.
|
package/dist/core/notes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NoteSchema, ReplySchema, } from "./schema.js";
|
|
2
2
|
import { InvalidError, NotFoundError, RushesError } from "./errors.js";
|
|
3
3
|
import { labelOfId, versionFormats } from "./formats.js";
|
|
4
|
+
import { noteOnFilm } from "./films.js";
|
|
4
5
|
import { newId } from "./ids.js";
|
|
5
6
|
import { noteState, setStatus } from "./noteState.js";
|
|
6
7
|
export function addNote(file, input, now = new Date()) {
|
|
@@ -168,10 +169,27 @@ export function onLabel(note, ctx) {
|
|
|
168
169
|
return withCue ? cueLabel(withCue.l, withCue.v, on) : null;
|
|
169
170
|
}
|
|
170
171
|
export function filterNotes(notes, f = {}) {
|
|
171
|
-
return notes.filter((n) => (f.
|
|
172
|
+
return notes.filter((n) => (f.video === undefined || noteOnFilm(n, f.video, f.videos ?? [])) &&
|
|
173
|
+
(f.stage === undefined || n.stage === f.stage) &&
|
|
172
174
|
(f.status === undefined || n.status === f.status) &&
|
|
173
175
|
(f.state === undefined || noteState(n) === f.state) &&
|
|
174
176
|
(f.batch === undefined || n.batch === f.batch) &&
|
|
175
177
|
(f.version === undefined || n.version === f.version) &&
|
|
176
178
|
(f.format === undefined || (n.stage === "picture" && (n.format === f.format || (!f.onlyThisFormat && n.format === null)))));
|
|
177
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* §30: the notes of a batch (or a reply), by the film each is on, so a line about them is written per film and Activity
|
|
182
|
+
* on one film never counts another's. A note on no film (and a batch's script edits) is under null. In first-seen order.
|
|
183
|
+
*/
|
|
184
|
+
export function byFilm(items, filmOf) {
|
|
185
|
+
const out = new Map();
|
|
186
|
+
for (const item of items) {
|
|
187
|
+
const film = filmOf(item) ?? null;
|
|
188
|
+
const group = out.get(film);
|
|
189
|
+
if (group)
|
|
190
|
+
group.push(item);
|
|
191
|
+
else
|
|
192
|
+
out.set(film, [item]);
|
|
193
|
+
}
|
|
194
|
+
return [...out];
|
|
195
|
+
}
|
package/dist/core/schema.js
CHANGED
|
@@ -161,9 +161,11 @@ export const SectionSchema = z
|
|
|
161
161
|
takes: z.array(TakeSchema).default([]),
|
|
162
162
|
})
|
|
163
163
|
.refine((s) => s.end > s.start, { message: "end must be after start", path: ["end"] });
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
/**
|
|
165
|
+
* §31.3: one film's script: its reading speed, its sections and the highest s<n> number it ever gave. A schema 1
|
|
166
|
+
* script.json is this, with `schema` and `rev`; a schema 2 one keeps one of these per film.
|
|
167
|
+
*/
|
|
168
|
+
export const FilmScriptSchema = fileObject({
|
|
167
169
|
wordsPerSecond: z.number().positive().default(2.6),
|
|
168
170
|
sections: z.array(SectionSchema).default([]),
|
|
169
171
|
// The highest s<n> number ever given to a section, so a removed section's id is never handed out
|
|
@@ -171,6 +173,25 @@ export const ScriptSchema = fileObject({
|
|
|
171
173
|
// the ids it can see.
|
|
172
174
|
sectionCounter: z.number().int().nonnegative().optional(),
|
|
173
175
|
});
|
|
176
|
+
/** script.json as written before §31: one script for the project. Still how a project with no film yet keeps it. */
|
|
177
|
+
export const ScriptV1Schema = fileObject({
|
|
178
|
+
schema: z.literal(1),
|
|
179
|
+
rev: z.number().int().nonnegative(),
|
|
180
|
+
wordsPerSecond: z.number().positive().default(2.6),
|
|
181
|
+
sections: z.array(SectionSchema).default([]),
|
|
182
|
+
sectionCounter: z.number().int().nonnegative().optional(),
|
|
183
|
+
});
|
|
184
|
+
/** §31.3: script.json schema 2, one script per film, keyed by video id. */
|
|
185
|
+
export const ScriptV2Schema = fileObject({
|
|
186
|
+
schema: z.literal(2),
|
|
187
|
+
rev: z.number().int().nonnegative(),
|
|
188
|
+
films: z.record(id, FilmScriptSchema).default({}),
|
|
189
|
+
});
|
|
190
|
+
/**
|
|
191
|
+
* script.json. A schema 1 file is the first film's script (or, with no film yet, the project's); it is written back
|
|
192
|
+
* as schema 2 by the first change made once there is a film (core/script.ts: filmScriptDraft).
|
|
193
|
+
*/
|
|
194
|
+
export const ScriptSchema = z.discriminatedUnion("schema", [ScriptV1Schema, ScriptV2Schema]);
|
|
174
195
|
export const BoxSchema = fileObject({
|
|
175
196
|
x: z.number().min(0).max(1),
|
|
176
197
|
y: z.number().min(0).max(1),
|
|
@@ -286,10 +307,10 @@ export const NotesFileSchema = fileObject({
|
|
|
286
307
|
rev: z.number().int().nonnegative(),
|
|
287
308
|
notes: z.array(NoteSchema).default([]),
|
|
288
309
|
});
|
|
289
|
-
// §19.6: a Mix lane's level, in dB. −24..
|
|
310
|
+
// §19.6: a Mix lane's level, in dB. −24..12 in 0.5 dB steps (§29: +12, so a quiet take can be brought up to the house balance); PUT /api/picks enforces the range and
|
|
290
311
|
// step (a value outside it, or off the step, is a 400), so the stored file is never checked again here.
|
|
291
312
|
export const LEVEL_MIN = -24;
|
|
292
|
-
export const LEVEL_MAX =
|
|
313
|
+
export const LEVEL_MAX = 12;
|
|
293
314
|
export const LEVEL_STEP = 0.5;
|
|
294
315
|
export const LevelsSchema = fileObject({ voice: z.number(), music: z.number(), sfx: z.number() }).partial().default({});
|
|
295
316
|
// What one film hears: its own pick per lane and its own Mix levels. Music, sound effects, the
|
|
@@ -301,10 +322,17 @@ export const LevelsSchema = fileObject({ voice: z.number(), music: z.number(), s
|
|
|
301
322
|
*/
|
|
302
323
|
export const UseSchema = fileObject({ lane: id, variant: id, at: z.string(), seen: z.record(z.string(), z.string()).default({}) });
|
|
303
324
|
export const InUseSchema = fileObject({ voice: UseSchema, music: UseSchema, sfx: UseSchema }).partial();
|
|
325
|
+
/**
|
|
326
|
+
* §29: the levels the last balance set, and when. While a film's levels still equal these (or none are set), its
|
|
327
|
+
* levels are the balance's own: a new take in use is balanced again. Once a fader is moved by hand they differ, and
|
|
328
|
+
* nothing moves it back until Balance is pressed.
|
|
329
|
+
*/
|
|
330
|
+
export const BalancedSchema = fileObject({ levels: LevelsSchema, at: z.string() });
|
|
304
331
|
export const VideoPicksSchema = fileObject({
|
|
305
332
|
lanes: z.record(z.string(), z.string()).default({}),
|
|
306
333
|
levels: LevelsSchema,
|
|
307
334
|
use: InUseSchema.optional(),
|
|
335
|
+
balanced: BalancedSchema.optional(),
|
|
308
336
|
});
|
|
309
337
|
export const PicksSchema = fileObject({
|
|
310
338
|
schema: z.literal(1),
|
|
@@ -318,6 +346,8 @@ export const PicksSchema = fileObject({
|
|
|
318
346
|
// §27.6: the take in use per sound. In this top-level place only for the picks of one film as
|
|
319
347
|
// picksForVideo hands them out (and a project from before picks were per film).
|
|
320
348
|
use: InUseSchema.optional(),
|
|
349
|
+
// §29: the project-wide set's last balance, for a project with no cut yet.
|
|
350
|
+
balanced: BalancedSchema.optional(),
|
|
321
351
|
// Each film's own picks and levels, keyed by video id. A film with no entry has picked nothing.
|
|
322
352
|
videos: z.record(z.string(), VideoPicksSchema).default({}),
|
|
323
353
|
});
|
|
@@ -326,27 +356,27 @@ export function picksForVideo(picks, videoId) {
|
|
|
326
356
|
if (!videoId)
|
|
327
357
|
return picks;
|
|
328
358
|
const own = picks.videos[videoId];
|
|
329
|
-
return { ...picks, lanes: { ...(own?.lanes ?? {}) }, levels: { ...(own?.levels ?? {}) }, use: { ...(own?.use ?? {}) }, sections: {}, videos: {} };
|
|
359
|
+
return { ...picks, lanes: { ...(own?.lanes ?? {}) }, levels: { ...(own?.levels ?? {}) }, use: { ...(own?.use ?? {}) }, balanced: own?.balanced, sections: {}, videos: {} };
|
|
330
360
|
}
|
|
331
361
|
/** The films a read, bed or pass is on: its `videos`, or an older project's one `video`, or none. */
|
|
332
362
|
export function variantFilms(v) {
|
|
333
363
|
return v.videos ?? (v.video === undefined ? [] : [v.video]);
|
|
334
364
|
}
|
|
335
365
|
/**
|
|
336
|
-
*
|
|
337
|
-
*
|
|
366
|
+
* §31.2.4: whether a read, bed or pass is on a film. One on no film is on the project's first film (`videos[0]`):
|
|
367
|
+
* nothing is on no film, and the one-time move (§31.4) writes that down.
|
|
338
368
|
*/
|
|
339
|
-
export function onFilm(v, videoId,
|
|
369
|
+
export function onFilm(v, videoId, videos) {
|
|
340
370
|
const films = variantFilms(v);
|
|
341
|
-
return films.length === 0 ?
|
|
371
|
+
return films.length === 0 ? videos.length === 0 || videos[0].id === videoId : films.includes(videoId);
|
|
342
372
|
}
|
|
343
373
|
/** The lanes one film hears: each keeps only the variants on that film (see onFilm), and a lane
|
|
344
374
|
* left with none is dropped. With no film named, every lane as it is. */
|
|
345
|
-
export function lanesForVideo(lanes, videoId,
|
|
375
|
+
export function lanesForVideo(lanes, videoId, videos) {
|
|
346
376
|
if (!videoId)
|
|
347
377
|
return lanes;
|
|
348
378
|
return lanes
|
|
349
|
-
.map((l) => ({ ...l, variants: l.variants.filter((v) => onFilm(v, videoId,
|
|
379
|
+
.map((l) => ({ ...l, variants: l.variants.filter((v) => onFilm(v, videoId, videos)) }))
|
|
350
380
|
.filter((l) => l.variants.length > 0);
|
|
351
381
|
}
|
|
352
382
|
export const BatchSchema = fileObject({
|
|
@@ -357,6 +387,12 @@ export const BatchSchema = fileObject({
|
|
|
357
387
|
sectionIds: z.array(z.string()).default([]),
|
|
358
388
|
sentAt: z.string(),
|
|
359
389
|
prompt: z.string(),
|
|
390
|
+
// §31.2.2: the film whose notes Send sent. Absent on a batch from before, and on one sent with no film yet.
|
|
391
|
+
video: z.string().nullable().optional(),
|
|
392
|
+
// I3: the hand-over was refused while Send to AI was on and nothing started (not signed in, not installed), so the
|
|
393
|
+
// notes still wait in this batch for Send again. Kept in the file, not the server's memory, so a restart can't strand
|
|
394
|
+
// them. Cleared when the batch is handed over again.
|
|
395
|
+
undelivered: z.object({ at: z.string(), why: z.string() }).nullable().optional(),
|
|
360
396
|
});
|
|
361
397
|
export const BatchesFileSchema = fileObject({
|
|
362
398
|
schema: z.literal(1),
|
|
@@ -473,6 +509,9 @@ export const BriefStateSchema = fileObject({
|
|
|
473
509
|
rev: z.number().int().nonnegative(),
|
|
474
510
|
baseline: z.string().max(1_000_000).default(""),
|
|
475
511
|
seen: z.string().max(64).default(""),
|
|
512
|
+
// §31.3: every other film's own baseline and hash, keyed by video id. The first film's are the top-level two, so a
|
|
513
|
+
// project with one film keeps the same file.
|
|
514
|
+
films: z.record(id, fileObject({ baseline: z.string().max(1_000_000).default(""), seen: z.string().max(64).default("") })).optional(),
|
|
476
515
|
});
|
|
477
516
|
// §25.3: a visual is one post: a still, or a carousel of pages. A version holds every page it shows, the ones it
|
|
478
517
|
// inherited from the version before included, so nothing downstream has to work inheritance out.
|
|
@@ -510,8 +549,15 @@ export const VisualsFileSchema = fileObject({
|
|
|
510
549
|
// session to resume. What the agent may do unasked (AgentRules) is kept outside the project (R10), where the agent
|
|
511
550
|
// can't change it.
|
|
512
551
|
export const AGENTS = ["claude", "codex"];
|
|
513
|
-
/**
|
|
514
|
-
|
|
552
|
+
/**
|
|
553
|
+
* What the agent may do without asking (§33), one menu row each. The first two ids are kept from before §33, so older
|
|
554
|
+
* rules files still read: "ask-all" is Manual (every action asks Rushes) and "project-edits" is Accept edits (the
|
|
555
|
+
* default: edits in the project go through, commands ask, Always rules apply). "auto" hands each decision to the
|
|
556
|
+
* agent's own safety reviewer and "bypass" checks nothing. Only the user picks those two, from the menu or the first-Send
|
|
557
|
+
* sheet; nothing in a project can set them (R10).
|
|
558
|
+
*/
|
|
559
|
+
export const AGENT_PERMISSIONS = ["ask-all", "project-edits", "auto", "bypass"];
|
|
560
|
+
export const AgentPermissionsSchema = z.enum(AGENT_PERMISSIONS);
|
|
515
561
|
export const AlwaysRuleSchema = z.object({ kind: z.string().max(32), command: z.string().max(200).nullable() });
|
|
516
562
|
/** At most this many Always rules are kept; a longer list read from disk keeps its newest ones. */
|
|
517
563
|
export const ALWAYS_KEPT = 50;
|
|
@@ -551,6 +597,15 @@ export const AgentRulesReadSchema = z.object({
|
|
|
551
597
|
setUp: z.boolean().default(false),
|
|
552
598
|
agent: z.enum(AGENTS).nullable().default(null),
|
|
553
599
|
});
|
|
600
|
+
/**
|
|
601
|
+
* §32: Send to AI's Mac-wide default, kept beside the per-project rules (server/agent/rules.ts), outside every project:
|
|
602
|
+
* the agent the user last chose (null after Copy a prompt) and what it may do. A project with no rules file yet starts
|
|
603
|
+
* from it, so Send to AI is set up once per Mac, not once per project. Always rules stay per project.
|
|
604
|
+
*/
|
|
605
|
+
export const AgentDefaultsSchema = z.object({
|
|
606
|
+
agent: z.enum(AGENTS).nullable().default(null),
|
|
607
|
+
permissions: AgentPermissionsSchema.default("project-edits"),
|
|
608
|
+
});
|
|
554
609
|
export const FILES = {
|
|
555
610
|
project: { name: "project.json", schema: ProjectSchema },
|
|
556
611
|
script: { name: "script.json", schema: ScriptSchema },
|
package/dist/core/script.js
CHANGED
|
@@ -129,3 +129,70 @@ export function addTake(script, sectionId, input) {
|
|
|
129
129
|
s.takes.push(take);
|
|
130
130
|
return take;
|
|
131
131
|
}
|
|
132
|
+
// ---- §31.3: one script per film ----
|
|
133
|
+
const WPS = 2.6;
|
|
134
|
+
/** A film with no script yet: nothing in it, at the usual reading speed. */
|
|
135
|
+
export const emptyScript = () => ({ wordsPerSecond: WPS, sections: [] });
|
|
136
|
+
/**
|
|
137
|
+
* The film whose script a schema 1 file is: the project's first film, or none while there is no film (§31.3: a
|
|
138
|
+
* project with no film yet keeps its plan files as they are, and they become the first film's when it is made).
|
|
139
|
+
*/
|
|
140
|
+
const firstFilmId = (project) => project.videos[0]?.id ?? null;
|
|
141
|
+
/**
|
|
142
|
+
* One film's script, read from script.json. With no film named (a project with no film yet, or a caller that doesn't
|
|
143
|
+
* know one) it is the first film's. A schema 1 file is the first film's script; any other film has none until one is
|
|
144
|
+
* set. What comes back is the file's own object where there is one, so a caller inside a store update may change it;
|
|
145
|
+
* use filmScriptDraft to change a film's script, since it also makes the room.
|
|
146
|
+
*/
|
|
147
|
+
export function filmScript(file, project, video) {
|
|
148
|
+
const first = firstFilmId(project);
|
|
149
|
+
const film = video ?? first;
|
|
150
|
+
if (file.schema === 1)
|
|
151
|
+
return film === null || film === first ? file : emptyScript();
|
|
152
|
+
if (film === null)
|
|
153
|
+
return emptyScript();
|
|
154
|
+
return file.films[film] ?? emptyScript();
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The script to change for a film, inside a store update of script.json. A schema 1 file becomes schema 2 here, its
|
|
158
|
+
* script kept as the first film's, once the project has a second film to tell it from (§31.3). With no film yet, or
|
|
159
|
+
* one film, it is changed as it is, so a one-film project keeps the very file it had (§31.7). A film with no script
|
|
160
|
+
* gets an empty one.
|
|
161
|
+
*/
|
|
162
|
+
export function filmScriptDraft(file, project, video) {
|
|
163
|
+
const first = firstFilmId(project);
|
|
164
|
+
const film = video ?? first;
|
|
165
|
+
if (file.schema === 1) {
|
|
166
|
+
if (first === null || (film === first && project.videos.length < 2))
|
|
167
|
+
return file;
|
|
168
|
+
toSchema2(file, first);
|
|
169
|
+
}
|
|
170
|
+
const v2 = file;
|
|
171
|
+
if (film === null)
|
|
172
|
+
throw new InvalidError("Name the film this script is for");
|
|
173
|
+
return (v2.films[film] ??= emptyScript());
|
|
174
|
+
}
|
|
175
|
+
/** Rewrites a schema 1 draft in place as schema 2, its script the first film's. */
|
|
176
|
+
export function toSchema2(file, first) {
|
|
177
|
+
if (file.schema !== 1)
|
|
178
|
+
return;
|
|
179
|
+
const { wordsPerSecond, sections, sectionCounter } = file;
|
|
180
|
+
const loose = file;
|
|
181
|
+
delete loose.wordsPerSecond;
|
|
182
|
+
delete loose.sections;
|
|
183
|
+
delete loose.sectionCounter;
|
|
184
|
+
loose.schema = 2;
|
|
185
|
+
loose.films = { [first]: { wordsPerSecond, sections, ...(sectionCounter === undefined ? {} : { sectionCounter }) } };
|
|
186
|
+
}
|
|
187
|
+
/** Every film's scripts, for what has to know every take whichever film it belongs to (media, the Assets list, the log). */
|
|
188
|
+
export function scriptsOf(file) {
|
|
189
|
+
return file.schema === 1 ? [{ video: null, script: file }] : Object.entries(file.films).map(([video, script]) => ({ video, script }));
|
|
190
|
+
}
|
|
191
|
+
/** The sections of one film's script, or of every film's when given the whole file. */
|
|
192
|
+
export function sectionsOf(script) {
|
|
193
|
+
return "sections" in script ? script.sections : allSections(script);
|
|
194
|
+
}
|
|
195
|
+
/** Every film's sections in one list (ids may repeat across films: each film numbers its own). */
|
|
196
|
+
export function allSections(file) {
|
|
197
|
+
return scriptsOf(file).flatMap((s) => s.script.sections);
|
|
198
|
+
}
|
package/dist/core/tabs.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { STAGES } from "./schema.js";
|
|
1
|
+
import { STAGES, lanesForVideo } from "./schema.js";
|
|
2
|
+
import { noteOnFilm } from "./films.js";
|
|
2
3
|
import { noteInPlay } from "./project.js";
|
|
3
4
|
import { noteState } from "./noteState.js";
|
|
4
5
|
import { isChanged } from "./script.js";
|
|
5
6
|
function laneHasVariants(p, stage) {
|
|
6
7
|
return p.lanes.some((l) => l.stage === stage && l.variants.length > 0);
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Each tab: unlocked or not, and its open items. §31.5: with a film, that film's (its cuts, the takes on it, its
|
|
11
|
+
* script, its notes and the shared visuals' notes); with none, the whole project's (a project with no film yet). `s`
|
|
12
|
+
* is the script that goes with it: that film's.
|
|
13
|
+
*/
|
|
14
|
+
export function tabStates(p, s, n, v = { visuals: [] }, film) {
|
|
15
|
+
const own = film ? p.videos.find((x) => x.id === film) : undefined;
|
|
16
|
+
const picture = own ? own.versions.length > 0 : p.videos.some((v) => v.versions.length > 0);
|
|
17
|
+
const heard = { lanes: lanesForVideo(p.lanes, own?.id, p.videos) };
|
|
18
|
+
const voice = laneHasVariants(heard, "voice");
|
|
19
|
+
const music = laneHasVariants(heard, "music");
|
|
20
|
+
const sfx = laneHasVariants(heard, "sfx");
|
|
13
21
|
const unlocked = {
|
|
14
22
|
script: s.sections.length > 0,
|
|
15
23
|
picture,
|
|
@@ -22,7 +30,7 @@ export function tabStates(p, s, n, v = { visuals: [] }) {
|
|
|
22
30
|
};
|
|
23
31
|
return STAGES.map((stage) => {
|
|
24
32
|
// §26: a shelved film's open notes are kept but do not count.
|
|
25
|
-
const open = n.notes.filter((x) => x.stage === stage && x.status === "todo" && noteInPlay(x, p));
|
|
33
|
+
const open = n.notes.filter((x) => x.stage === stage && x.status === "todo" && noteInPlay(x, p) && noteOnFilm(x, own?.id, p.videos));
|
|
26
34
|
const rows = stage === "script" ? s.sections.filter((x) => isChanged(x) || x.status === "flagged").length : 0;
|
|
27
35
|
return { stage, unlocked: unlocked[stage], todo: open.length + rows, sent: open.filter((x) => noteState(x) === "sent").length };
|
|
28
36
|
});
|
package/dist/core/takes.js
CHANGED
|
@@ -48,7 +48,7 @@ export function takeState(variant, lane, use) {
|
|
|
48
48
|
const SOUNDS = ["voice", "music", "sfx"];
|
|
49
49
|
/** Every take one film hears (no film: the whole project), per sound, newest round first, with its state. */
|
|
50
50
|
export function filmTakes(project, picks, videoId) {
|
|
51
|
-
const lanes = lanesForVideo(project.lanes, videoId, project.videos
|
|
51
|
+
const lanes = lanesForVideo(project.lanes, videoId, project.videos);
|
|
52
52
|
const use = inUse({ lanes }, picksForVideo(picks, videoId));
|
|
53
53
|
const video = videoId ? project.videos.find((v) => v.id === videoId) : undefined;
|
|
54
54
|
const out = { voice: [], music: [], sfx: [] };
|