rushes 0.3.0 → 0.5.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 +43 -4
- package/README.md +158 -14
- package/dist/cli/doctor.js +5 -2
- package/dist/cli/main.js +46 -11
- package/dist/cli/new.js +84 -0
- package/dist/core/brief.js +81 -0
- package/dist/core/cues.js +39 -0
- package/dist/core/notes.js +6 -1
- package/dist/core/plan.js +22 -0
- package/dist/core/project.js +9 -4
- package/dist/core/schema.js +56 -23
- package/dist/core/script.js +19 -5
- package/dist/core/store.js +9 -3
- package/dist/core/storyboard.js +105 -0
- package/dist/mcp/stdio.js +12 -3
- package/dist/mcp/tools.js +15 -3
- package/dist/server/app.js +92 -15
- package/dist/server/assets.js +6 -5
- package/dist/server/brief.js +63 -0
- package/dist/server/files.js +4 -0
- package/dist/server/found.js +5 -1
- package/dist/server/lock.js +51 -6
- package/dist/server/record.js +114 -0
- package/dist/server/start.js +9 -1
- package/dist/server/storyboard.js +109 -0
- package/dist/setup/harnesses.js +62 -0
- package/package.json +21 -1
- package/skills/rushes/SKILL.md +42 -2
- package/web-dist/assets/{index-BDMm5p1-.css → index-C-0jcf9a.css} +1 -1
- package/web-dist/assets/index-CCD0ugOe.js +3 -0
- package/web-dist/index.html +2 -2
- package/web-dist/assets/index-C9dBtlRy.js +0 -3
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
// §24 step 2: brief.md is the file of record for a film's brief. These are pure functions over its
|
|
3
|
+
// text: parse it into sections, replace one section's body, set the Status line. Everything else in
|
|
4
|
+
// the file (the preamble, other sections, the user's own formatting) is left exactly as it was.
|
|
5
|
+
/** The brief's file name, in the project folder's root. */
|
|
6
|
+
export const BRIEF_FILE = "brief.md";
|
|
7
|
+
const STATUS_LINE = /^Status:[ \t]*(draft|approved)[ \t]*$/i;
|
|
8
|
+
/** A short fingerprint of the file's text: what a page sends back to prove it saw the current file. */
|
|
9
|
+
export function hashText(text) {
|
|
10
|
+
return createHash("sha1").update(text).digest("hex").slice(0, 12);
|
|
11
|
+
}
|
|
12
|
+
/** The file's own line ending: CRLF when its first line break is one, else LF. */
|
|
13
|
+
const eolOf = (text) => (/\r?\n/.exec(text)?.[0] === "\r\n" ? "\r\n" : "\n");
|
|
14
|
+
/** Lines of `text` (either line ending), and the "## " headings in them. A "## " inside a fenced code block is not a heading. */
|
|
15
|
+
function scan(text) {
|
|
16
|
+
const lines = text.split(/\r?\n/);
|
|
17
|
+
const spans = [];
|
|
18
|
+
let fenced = false;
|
|
19
|
+
lines.forEach((line, i) => {
|
|
20
|
+
if (/^(```|~~~)/.test(line))
|
|
21
|
+
fenced = !fenced;
|
|
22
|
+
const m = !fenced && /^## +(.+?) *$/.exec(line);
|
|
23
|
+
if (m) {
|
|
24
|
+
if (spans.length)
|
|
25
|
+
spans[spans.length - 1].end = i;
|
|
26
|
+
spans.push({ heading: m[1], at: i, end: lines.length });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return { lines, spans };
|
|
30
|
+
}
|
|
31
|
+
const trimBlank = (ls) => {
|
|
32
|
+
let a = 0;
|
|
33
|
+
let b = ls.length;
|
|
34
|
+
while (a < b && ls[a].trim() === "")
|
|
35
|
+
a++;
|
|
36
|
+
while (b > a && ls[b - 1].trim() === "")
|
|
37
|
+
b--;
|
|
38
|
+
return ls.slice(a, b);
|
|
39
|
+
};
|
|
40
|
+
export function parseBrief(text) {
|
|
41
|
+
const { lines, spans } = scan(text);
|
|
42
|
+
const preamble = lines.slice(0, spans.length ? spans[0].at : lines.length);
|
|
43
|
+
const titleLine = preamble.map((l) => /^# +(.+?) *$/.exec(l)).find(Boolean);
|
|
44
|
+
const title = titleLine ? titleLine[1].replace(/^Brief:[ \t]*/i, "") : "";
|
|
45
|
+
const statusMatch = preamble.map((l) => STATUS_LINE.exec(l)).find(Boolean);
|
|
46
|
+
const status = statusMatch ? statusMatch[1].toLowerCase() : null;
|
|
47
|
+
const sections = spans.map((s) => ({ heading: s.heading, body: trimBlank(lines.slice(s.at + 1, s.end)).join("\n") }));
|
|
48
|
+
return { title, status, sections };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* `text` with the body of the section at `index` replaced by `body`. `heading` must be that section's
|
|
52
|
+
* heading (so a file that was reordered under you is refused, not edited in the wrong place).
|
|
53
|
+
* Spacing is kept: one blank line before the next heading, and a single newline at the end of the file.
|
|
54
|
+
*/
|
|
55
|
+
export function setSectionBody(text, index, heading, body) {
|
|
56
|
+
const { lines, spans } = scan(text);
|
|
57
|
+
const span = spans[index];
|
|
58
|
+
if (!span || span.heading !== heading)
|
|
59
|
+
throw new Error(`No section "${heading}" at position ${index + 1}`);
|
|
60
|
+
const next = trimBlank(body.replace(/\r\n/g, "\n").split("\n"));
|
|
61
|
+
const isLast = index === spans.length - 1;
|
|
62
|
+
const replacement = [...next, ...(isLast ? [] : [""])];
|
|
63
|
+
const out = [...lines.slice(0, span.at + 1), ...replacement, ...lines.slice(span.end)];
|
|
64
|
+
const eol = eolOf(text);
|
|
65
|
+
return out.join(eol).replace(/(\r?\n)*$/, eol);
|
|
66
|
+
}
|
|
67
|
+
/** `text` with its `Status:` line set. With no such line, one is added under the title (or at the top). */
|
|
68
|
+
export function setStatus(text, status) {
|
|
69
|
+
const { lines, spans } = scan(text);
|
|
70
|
+
const limit = spans.length ? spans[0].at : lines.length;
|
|
71
|
+
const at = lines.slice(0, limit).findIndex((l) => STATUS_LINE.test(l));
|
|
72
|
+
if (at >= 0) {
|
|
73
|
+
const out = [...lines];
|
|
74
|
+
out[at] = `Status: ${status}`;
|
|
75
|
+
return out.join(eolOf(text));
|
|
76
|
+
}
|
|
77
|
+
const title = lines.slice(0, limit).findIndex((l) => /^# /.test(l));
|
|
78
|
+
const insertAt = title >= 0 ? title + 1 : 0;
|
|
79
|
+
const out = [...lines.slice(0, insertAt), "", `Status: ${status}`, ...(title >= 0 ? [] : [""]), ...lines.slice(insertAt)];
|
|
80
|
+
return out.join(eolOf(text));
|
|
81
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// §23: a cue's optional source file -- the sample an agent placed at that cue. Checked where it
|
|
2
|
+
// comes in (an audio file, at most 1024 characters, so it can never open the allow-list to
|
|
3
|
+
// anything else) and served by /media only because it is registered (§15.5 applies unchanged).
|
|
4
|
+
import { InvalidError } from "./errors.js";
|
|
5
|
+
export const CUE_FILE_MAX = 1024;
|
|
6
|
+
/** The sample types a cue may name: the audio half of §15.5's outside-the-project list. */
|
|
7
|
+
export const CUE_FILE_EXT = new Set(["wav", "mp3", "m4a", "aac", "aif", "aiff", "flac", "ogg", "opus"]);
|
|
8
|
+
function extOf(file) {
|
|
9
|
+
const base = file.slice(Math.max(file.lastIndexOf("/"), file.lastIndexOf("\\")) + 1);
|
|
10
|
+
const dot = base.lastIndexOf(".");
|
|
11
|
+
return dot > 0 ? base.slice(dot + 1).toLowerCase() : "";
|
|
12
|
+
}
|
|
13
|
+
/** Whether `file` may be a cue's source: not empty, at most 1024 characters, no NUL, an audio extension. */
|
|
14
|
+
export function isCueFile(file) {
|
|
15
|
+
return file.length > 0 && file.length <= CUE_FILE_MAX && !file.includes("\0") && CUE_FILE_EXT.has(extOf(file));
|
|
16
|
+
}
|
|
17
|
+
/** `file` when it may be a cue's source; otherwise an InvalidError (400) naming the cue. */
|
|
18
|
+
export function checkCueFile(cueName, file) {
|
|
19
|
+
if (file.length > CUE_FILE_MAX)
|
|
20
|
+
throw new InvalidError(`Cue "${cueName}": its file path is over ${CUE_FILE_MAX} characters`);
|
|
21
|
+
if (!isCueFile(file)) {
|
|
22
|
+
throw new InvalidError(`Cue "${cueName}": "${file}" isn't an audio file. Send a .wav, .mp3, .m4a, .aac, .aif, .aiff, .flac, .ogg or .opus.`);
|
|
23
|
+
}
|
|
24
|
+
return file;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Every cue file the project names, once each, in manifest order. A stored one that isn't an
|
|
28
|
+
* audio file (a hand edit) is left out, so it is never served.
|
|
29
|
+
*/
|
|
30
|
+
export function cueFiles(project) {
|
|
31
|
+
const out = new Set();
|
|
32
|
+
for (const l of project.lanes) {
|
|
33
|
+
for (const v of l.variants)
|
|
34
|
+
for (const c of v.cues)
|
|
35
|
+
if (c.file !== undefined && isCueFile(c.file))
|
|
36
|
+
out.add(c.file);
|
|
37
|
+
}
|
|
38
|
+
return [...out];
|
|
39
|
+
}
|
package/dist/core/notes.js
CHANGED
|
@@ -3,7 +3,12 @@ import { InvalidError, NotFoundError, RushesError } from "./errors.js";
|
|
|
3
3
|
import { labelOfId, versionFormats } from "./formats.js";
|
|
4
4
|
import { newId } from "./ids.js";
|
|
5
5
|
export function addNote(file, input, now = new Date()) {
|
|
6
|
-
|
|
6
|
+
// Ids are short and random (24 bits), so a long file can draw one a note already has, and a reply
|
|
7
|
+
// for one note would then land on the other. Draw again, as the log does.
|
|
8
|
+
let id = newId("n");
|
|
9
|
+
while (file.notes.some((n) => n.id === id))
|
|
10
|
+
id = newId("n");
|
|
11
|
+
const parsed = NoteSchema.safeParse({ ...input, id, createdAt: now.toISOString() });
|
|
7
12
|
if (!parsed.success)
|
|
8
13
|
throw new InvalidError("Note is invalid", parsed.error.issues);
|
|
9
14
|
file.notes.push(parsed.data);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// §24.12: is the plan approved? The brief, every script section and every storyboard shot, in that order.
|
|
2
|
+
// A film with no script (an instrumental one) is not waiting on one.
|
|
3
|
+
export function buildState(i) {
|
|
4
|
+
const waitingOn = [];
|
|
5
|
+
if (!(i.brief.exists && i.brief.status === "approved"))
|
|
6
|
+
waitingOn.push("brief");
|
|
7
|
+
if (!i.script.every((s) => s.status === "approved"))
|
|
8
|
+
waitingOn.push("script");
|
|
9
|
+
if (!(i.storyboard.exists && i.storyboard.total > 0 && i.storyboard.approved === i.storyboard.total))
|
|
10
|
+
waitingOn.push("storyboard");
|
|
11
|
+
const started = (i.brief.exists && i.brief.status !== null) || (i.storyboard.exists && i.storyboard.total > 0);
|
|
12
|
+
return { started, ready: started && waitingOn.length === 0, waitingOn };
|
|
13
|
+
}
|
|
14
|
+
/** The words a cut registered before the plan is approved comes back with, or null when there is nothing to say. */
|
|
15
|
+
export function planWarning(b) {
|
|
16
|
+
if (!b.started || b.ready)
|
|
17
|
+
return null;
|
|
18
|
+
const names = { brief: "the brief", script: "the script", storyboard: "the storyboard" };
|
|
19
|
+
const list = b.waitingOn.map((p) => names[p]);
|
|
20
|
+
const text = list.length > 1 ? `${list.slice(0, -1).join(", ")} and ${list[list.length - 1]}` : list[0];
|
|
21
|
+
return `The plan isn't approved yet: still waiting on ${text}.`;
|
|
22
|
+
}
|
package/dist/core/project.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { basename } from "node:path";
|
|
2
2
|
import { newProjectId, slugify, uniqueId } from "./ids.js";
|
|
3
3
|
import { InvalidError, NotFoundError, RushesError } from "./errors.js";
|
|
4
|
+
import { checkCueFile } from "./cues.js";
|
|
4
5
|
import { MAX_FORMATS, durationWarning, ratioId, sameShape, settleLabel, versionFormats } from "./formats.js";
|
|
5
6
|
import { oneLineOf } from "./labels.js";
|
|
6
7
|
/** Sets `p.id` when missing. Returns whether it changed anything. */
|
|
@@ -81,6 +82,14 @@ function resolveVersion(video, versionId) {
|
|
|
81
82
|
}
|
|
82
83
|
const LANE_NAMES = { voice: "Voiceover", music: "Music", sfx: "Sound effects" };
|
|
83
84
|
export function addVariant(p, input) {
|
|
85
|
+
// §23: the cues first, so a cue refused for its file leaves the project untouched.
|
|
86
|
+
const cues = [];
|
|
87
|
+
for (const c of input.cues ?? []) {
|
|
88
|
+
const cue = { id: uniqueId(slugify(c.name), cues.map((x) => x.id)), name: c.name, t: c.t };
|
|
89
|
+
if (c.file !== undefined)
|
|
90
|
+
cue.file = checkCueFile(c.name, c.file);
|
|
91
|
+
cues.push(cue);
|
|
92
|
+
}
|
|
84
93
|
// Lane ids are capped at 64 by the schema; a slug can outgrow its source (NFKD splits ligatures).
|
|
85
94
|
const laneId = slugify(input.lane ?? input.round ?? input.stage).slice(0, 64).replace(/-+$/, "");
|
|
86
95
|
let lane = p.lanes.find((l) => l.id === laneId);
|
|
@@ -90,10 +99,6 @@ export function addVariant(p, input) {
|
|
|
90
99
|
lane = { id: laneId, stage: input.stage, name: input.round ?? input.lane ?? LANE_NAMES[input.stage], variants: [] };
|
|
91
100
|
p.lanes.push(lane);
|
|
92
101
|
}
|
|
93
|
-
const cues = [];
|
|
94
|
-
for (const c of input.cues ?? []) {
|
|
95
|
-
cues.push({ id: uniqueId(slugify(c.name), cues.map((x) => x.id)), name: c.name, t: c.t });
|
|
96
|
-
}
|
|
97
102
|
const variant = {
|
|
98
103
|
id: uniqueId(slugify(input.name), lane.variants.map((v) => v.id)),
|
|
99
104
|
name: input.name,
|
package/dist/core/schema.js
CHANGED
|
@@ -2,19 +2,29 @@ import { z } from "zod";
|
|
|
2
2
|
import { FORMAT_ID_RE, isPictureSize, labelOfId, ratioId, ratioLabel } from "./formats.js";
|
|
3
3
|
import { oneLineOf } from "./labels.js";
|
|
4
4
|
import { LOG_AREAS, LOG_BY, LOG_KINDS, LOG_MAX, LOG_TEXT_MAX } from "./logText.js";
|
|
5
|
+
/**
|
|
6
|
+
* An object in one of the project's files. Every write parses the whole file through its schema,
|
|
7
|
+
* and a plain z.object drops the fields it doesn't know, so an older Rushes saving a file that a
|
|
8
|
+
* newer one wrote would quietly delete what the newer one added. This keeps them, at every depth.
|
|
9
|
+
* The type stays the plain shape on purpose: the code reads only the fields it declares, and an
|
|
10
|
+
* index signature on every type would ripple through the whole dashboard.
|
|
11
|
+
*/
|
|
12
|
+
function fileObject(shape) {
|
|
13
|
+
return z.looseObject(shape);
|
|
14
|
+
}
|
|
5
15
|
export const STAGES = ["script", "picture", "voice", "music", "sfx", "mix"];
|
|
6
16
|
export const StageSchema = z.enum(STAGES);
|
|
7
17
|
export const LaneStageSchema = z.enum(["voice", "music", "sfx"]);
|
|
8
18
|
const id = z.string().min(1).max(64);
|
|
9
19
|
const seconds = z.number().nonnegative();
|
|
10
20
|
export const ProjectIdSchema = z.string().regex(/^[abcdefghjkmnpqrstuvwxyz23456789]{8}$/);
|
|
11
|
-
export const ShotSchema =
|
|
21
|
+
export const ShotSchema = fileObject({
|
|
12
22
|
n: z.number().int().positive(),
|
|
13
23
|
name: z.string().trim().min(1).max(80),
|
|
14
24
|
start: z.number().nonnegative(),
|
|
15
25
|
tag: z.string().trim().max(24).default(""),
|
|
16
26
|
});
|
|
17
|
-
export const ProxySchema =
|
|
27
|
+
export const ProxySchema = fileObject({
|
|
18
28
|
/** Manifest path, always "proxies/<film-slug>_<version>_proxy.mp4". */
|
|
19
29
|
file: z.string().min(1),
|
|
20
30
|
width: z.number().int().positive(),
|
|
@@ -23,7 +33,7 @@ export const ProxySchema = z.object({
|
|
|
23
33
|
createdAt: z.string(),
|
|
24
34
|
});
|
|
25
35
|
// §21.3: another render of the same cut at another aspect ratio. Its id is its label with ":" as "x".
|
|
26
|
-
export const FormatSchema =
|
|
36
|
+
export const FormatSchema = fileObject({
|
|
27
37
|
id: z.string().max(16).regex(FORMAT_ID_RE),
|
|
28
38
|
label: z.string().min(3).max(16),
|
|
29
39
|
file: z.string().min(1),
|
|
@@ -69,28 +79,35 @@ export const VersionSchema = z
|
|
|
69
79
|
seen.add(f.id);
|
|
70
80
|
});
|
|
71
81
|
});
|
|
72
|
-
export const VideoSchema =
|
|
82
|
+
export const VideoSchema = fileObject({
|
|
73
83
|
id,
|
|
74
84
|
name: z.string().min(1),
|
|
75
85
|
versions: z.array(VersionSchema).default([]),
|
|
76
86
|
lockedVersion: z.string().nullable().default(null),
|
|
77
87
|
});
|
|
78
|
-
export const CueSchema =
|
|
79
|
-
|
|
88
|
+
export const CueSchema = fileObject({
|
|
89
|
+
id,
|
|
90
|
+
name: z.string().min(1),
|
|
91
|
+
t: seconds,
|
|
92
|
+
// §23: the sample placed at this cue, as a manifest path (CUE_FILE_MAX in cues.ts). Optional and
|
|
93
|
+
// absent on every older cue, so a 0.2.x project loads and writes back unchanged.
|
|
94
|
+
file: z.string().min(1).max(1024).optional(),
|
|
95
|
+
});
|
|
96
|
+
export const VariantSchema = fileObject({
|
|
80
97
|
id,
|
|
81
98
|
name: z.string().min(1),
|
|
82
99
|
file: z.string().min(1),
|
|
83
100
|
meta: z.record(z.string(), z.union([z.string(), z.number()])).default({}),
|
|
84
101
|
cues: z.array(CueSchema).default([]),
|
|
85
102
|
});
|
|
86
|
-
export const LaneSchema =
|
|
103
|
+
export const LaneSchema = fileObject({
|
|
87
104
|
id,
|
|
88
105
|
stage: LaneStageSchema,
|
|
89
106
|
name: z.string().min(1),
|
|
90
107
|
variants: z.array(VariantSchema).default([]),
|
|
91
108
|
});
|
|
92
109
|
export const FileKindSchema = z.enum(["doc", "image", "caption", "export", "delivery", "edit"]);
|
|
93
|
-
export const FileEntrySchema =
|
|
110
|
+
export const FileEntrySchema = fileObject({
|
|
94
111
|
id,
|
|
95
112
|
kind: FileKindSchema,
|
|
96
113
|
file: z.string().min(1),
|
|
@@ -99,7 +116,7 @@ export const FileEntrySchema = z.object({
|
|
|
99
116
|
video: z.string().nullable().default(null),
|
|
100
117
|
addedAt: z.string(),
|
|
101
118
|
});
|
|
102
|
-
export const ProjectSchema =
|
|
119
|
+
export const ProjectSchema = fileObject({
|
|
103
120
|
schema: z.literal(1),
|
|
104
121
|
rev: z.number().int().nonnegative(),
|
|
105
122
|
id: ProjectIdSchema.optional(),
|
|
@@ -111,7 +128,7 @@ export const ProjectSchema = z.object({
|
|
|
111
128
|
// §19.5: start a proxy straight away for a new cut that meets the criteria. Off by default.
|
|
112
129
|
autoProxy: z.boolean().default(false),
|
|
113
130
|
});
|
|
114
|
-
export const TakeSchema =
|
|
131
|
+
export const TakeSchema = fileObject({
|
|
115
132
|
id,
|
|
116
133
|
file: z.string().min(1),
|
|
117
134
|
duration: seconds.nullable().default(null),
|
|
@@ -130,13 +147,17 @@ export const SectionSchema = z
|
|
|
130
147
|
takes: z.array(TakeSchema).default([]),
|
|
131
148
|
})
|
|
132
149
|
.refine((s) => s.end > s.start, { message: "end must be after start", path: ["end"] });
|
|
133
|
-
export const ScriptSchema =
|
|
150
|
+
export const ScriptSchema = fileObject({
|
|
134
151
|
schema: z.literal(1),
|
|
135
152
|
rev: z.number().int().nonnegative(),
|
|
136
153
|
wordsPerSecond: z.number().positive().default(2.6),
|
|
137
154
|
sections: z.array(SectionSchema).default([]),
|
|
155
|
+
// The highest s<n> number ever given to a section, so a removed section's id is never handed out
|
|
156
|
+
// again for new words. Absent on a script saved before this; setSections then works it out from
|
|
157
|
+
// the ids it can see.
|
|
158
|
+
sectionCounter: z.number().int().nonnegative().optional(),
|
|
138
159
|
});
|
|
139
|
-
export const BoxSchema =
|
|
160
|
+
export const BoxSchema = fileObject({
|
|
140
161
|
x: z.number().min(0).max(1),
|
|
141
162
|
y: z.number().min(0).max(1),
|
|
142
163
|
w: z.number().min(0).max(1),
|
|
@@ -146,7 +167,7 @@ export const BoxSchema = z.object({
|
|
|
146
167
|
// need a dB amount (chosen from 1, 2, 3, 6 or 9 in the UI, 3 the default); rise/fall never carry
|
|
147
168
|
// one. Both rules, plus "no duplicate kinds" and "only on audio-ish stages", are enforced on the
|
|
148
169
|
// note as a whole below, since they depend on more than one mark (or on the note's stage).
|
|
149
|
-
export const MarkSchema =
|
|
170
|
+
export const MarkSchema = fileObject({
|
|
150
171
|
kind: z.enum(["rise", "fall", "louder", "quieter"]),
|
|
151
172
|
db: z.number().min(0.5).max(24).optional(),
|
|
152
173
|
});
|
|
@@ -179,7 +200,7 @@ export const NoteSchema = z
|
|
|
179
200
|
text: z.string().trim().min(1).max(4000),
|
|
180
201
|
box: BoxSchema.nullable().default(null),
|
|
181
202
|
grab: z.string().nullable().default(null),
|
|
182
|
-
shot:
|
|
203
|
+
shot: fileObject({ n: z.number().int().positive(), name: z.string() }).nullable().default(null),
|
|
183
204
|
marks: z.array(MarkSchema).max(4).default([]),
|
|
184
205
|
// §21.3: the format this note belongs to (a Format id such as "9x16"), or null for every format:
|
|
185
206
|
// the default, and every note from before formats. The server checks it against the note's version.
|
|
@@ -221,7 +242,7 @@ export const NoteSchema = z
|
|
|
221
242
|
seenKinds.add(m.kind);
|
|
222
243
|
}
|
|
223
244
|
});
|
|
224
|
-
export const NotesFileSchema =
|
|
245
|
+
export const NotesFileSchema = fileObject({
|
|
225
246
|
schema: z.literal(1),
|
|
226
247
|
rev: z.number().int().nonnegative(),
|
|
227
248
|
notes: z.array(NoteSchema).default([]),
|
|
@@ -231,8 +252,8 @@ export const NotesFileSchema = z.object({
|
|
|
231
252
|
export const LEVEL_MIN = -24;
|
|
232
253
|
export const LEVEL_MAX = 6;
|
|
233
254
|
export const LEVEL_STEP = 0.5;
|
|
234
|
-
export const LevelsSchema =
|
|
235
|
-
export const PicksSchema =
|
|
255
|
+
export const LevelsSchema = fileObject({ voice: z.number(), music: z.number(), sfx: z.number() }).partial().default({});
|
|
256
|
+
export const PicksSchema = fileObject({
|
|
236
257
|
schema: z.literal(1),
|
|
237
258
|
rev: z.number().int().nonnegative(),
|
|
238
259
|
lanes: z.record(z.string(), z.string()).default({}),
|
|
@@ -240,7 +261,7 @@ export const PicksSchema = z.object({
|
|
|
240
261
|
// §19.6: each Mix lane's level in dB, defaulting to 0 (absent). Keyed the same as LaneStage.
|
|
241
262
|
levels: LevelsSchema,
|
|
242
263
|
});
|
|
243
|
-
export const BatchSchema =
|
|
264
|
+
export const BatchSchema = fileObject({
|
|
244
265
|
id,
|
|
245
266
|
stage: StageSchema,
|
|
246
267
|
noteIds: z.array(z.string()).default([]),
|
|
@@ -248,14 +269,14 @@ export const BatchSchema = z.object({
|
|
|
248
269
|
sentAt: z.string(),
|
|
249
270
|
prompt: z.string(),
|
|
250
271
|
});
|
|
251
|
-
export const BatchesFileSchema =
|
|
272
|
+
export const BatchesFileSchema = fileObject({
|
|
252
273
|
schema: z.literal(1),
|
|
253
274
|
rev: z.number().int().nonnegative(),
|
|
254
275
|
batches: z.array(BatchSchema).default([]),
|
|
255
276
|
});
|
|
256
277
|
// §20.6: the found files the user dismissed ("Not these"), as manifest paths. The candidates
|
|
257
278
|
// themselves live in the server's memory; only this list is kept. Created on its first write.
|
|
258
|
-
export const FoundFileSchema =
|
|
279
|
+
export const FoundFileSchema = fileObject({
|
|
259
280
|
schema: z.literal(1),
|
|
260
281
|
rev: z.number().int().nonnegative(),
|
|
261
282
|
dismissed: z.array(z.string().max(1024)).max(10000).default([]),
|
|
@@ -263,7 +284,7 @@ export const FoundFileSchema = z.object({
|
|
|
263
284
|
// ids), so the scoring never also adds a file of that kind for that cut, on any later scan,
|
|
264
285
|
// start-up or restart. Files from before this field read as empty.
|
|
265
286
|
settled: z
|
|
266
|
-
.array(
|
|
287
|
+
.array(fileObject({
|
|
267
288
|
video: z.string().max(200),
|
|
268
289
|
version: z.string().max(200),
|
|
269
290
|
kinds: z.array(z.enum(["voice", "music", "sfx", "cut", "other"])).max(5),
|
|
@@ -273,7 +294,7 @@ export const FoundFileSchema = z.object({
|
|
|
273
294
|
});
|
|
274
295
|
// §22.3: the Change Log, .rushes/log.json, oldest first on disk. Written by the server as things
|
|
275
296
|
// happen, created on its first write. Every field is new, so nothing older reads differently.
|
|
276
|
-
export const LogEntrySchema =
|
|
297
|
+
export const LogEntrySchema = fileObject({
|
|
277
298
|
id,
|
|
278
299
|
at: z.string(),
|
|
279
300
|
area: z.enum(LOG_AREAS),
|
|
@@ -289,7 +310,7 @@ export const LogEntrySchema = z.object({
|
|
|
289
310
|
n: z.number().int().positive().default(1),
|
|
290
311
|
subject: z.string().max(200).default(""),
|
|
291
312
|
});
|
|
292
|
-
export const LogFileSchema =
|
|
313
|
+
export const LogFileSchema = fileObject({
|
|
293
314
|
schema: z.literal(1),
|
|
294
315
|
rev: z.number().int().nonnegative(),
|
|
295
316
|
// §22.6: set once the dated history has been read in, so it never happens twice.
|
|
@@ -355,6 +376,15 @@ function cleanLine(item) {
|
|
|
355
376
|
}
|
|
356
377
|
/** How log.json is read (see tolerantLog); the store writes it against LogFileSchema. */
|
|
357
378
|
export const LogFileReadSchema = z.preprocess(tolerantLog, LogFileSchema);
|
|
379
|
+
// §24 step 2: what Rushes remembers about brief.md, which is itself the file of record. `baseline` is the
|
|
380
|
+
// text the last time someone other than the dashboard wrote it (the agent's version: the "Current" column),
|
|
381
|
+
// and `seen` is the hash of the text Rushes last looked at, so a change made behind its back is noticed.
|
|
382
|
+
export const BriefStateSchema = fileObject({
|
|
383
|
+
schema: z.literal(1),
|
|
384
|
+
rev: z.number().int().nonnegative(),
|
|
385
|
+
baseline: z.string().max(1_000_000).default(""),
|
|
386
|
+
seen: z.string().max(64).default(""),
|
|
387
|
+
});
|
|
358
388
|
export const FILES = {
|
|
359
389
|
project: { name: "project.json", schema: ProjectSchema },
|
|
360
390
|
script: { name: "script.json", schema: ScriptSchema },
|
|
@@ -363,4 +393,7 @@ export const FILES = {
|
|
|
363
393
|
batches: { name: "batches.json", schema: BatchesFileSchema },
|
|
364
394
|
found: { name: "found.json", schema: FoundFileSchema },
|
|
365
395
|
log: { name: "log.json", schema: LogFileSchema, read: LogFileReadSchema },
|
|
396
|
+
brief: { name: "brief.json", schema: BriefStateSchema },
|
|
397
|
+
// §24.12: the storyboard is kept the same way as the brief: its file, plus the agent's last text and the hash last seen.
|
|
398
|
+
storyboard: { name: "storyboard.json", schema: BriefStateSchema },
|
|
366
399
|
};
|
package/dist/core/script.js
CHANGED
|
@@ -26,8 +26,14 @@ export function isTakeStale(take, s) {
|
|
|
26
26
|
*
|
|
27
27
|
* Either way, a section that keeps its id keeps the user's proposed text,
|
|
28
28
|
* direction, status and takes. A proposal the agent adopts as the current line
|
|
29
|
-
* is cleared because it has landed
|
|
30
|
-
*
|
|
29
|
+
* is cleared because it has landed. A section whose line the agent changed goes
|
|
30
|
+
* back to draft, whatever its status: a flag has been acted on, and an approval
|
|
31
|
+
* was for the words the user read, not the new ones. Re-sending the same words
|
|
32
|
+
* (spacing aside) leaves the status alone.
|
|
33
|
+
*
|
|
34
|
+
* A section sent without an id is given the next s<n> number that has never been
|
|
35
|
+
* used in this script, so a replace with no ids carries on from where the old
|
|
36
|
+
* numbers stopped instead of starting again at s1.
|
|
31
37
|
*/
|
|
32
38
|
export function setSections(script, input, { replace = false } = {}) {
|
|
33
39
|
const seen = new Set();
|
|
@@ -53,7 +59,7 @@ export function setSections(script, input, { replace = false } = {}) {
|
|
|
53
59
|
const prev = s.id === undefined ? undefined : old.get(s.id);
|
|
54
60
|
const landed = prev?.proposed != null && prev.proposed.trim() === s.current.trim();
|
|
55
61
|
const reworked = prev !== undefined && prev.current.trim() !== s.current.trim();
|
|
56
|
-
const status = !prev || landed ||
|
|
62
|
+
const status = !prev || landed || reworked ? "draft" : prev.status;
|
|
57
63
|
return {
|
|
58
64
|
id: s.id ?? null,
|
|
59
65
|
start: s.start,
|
|
@@ -70,18 +76,26 @@ export function setSections(script, input, { replace = false } = {}) {
|
|
|
70
76
|
if (sorted[i].start < sorted[i - 1].end)
|
|
71
77
|
throw new InvalidError(`Sections overlap at ${sorted[i].start}s`);
|
|
72
78
|
}
|
|
73
|
-
// New sections without an id get s<n>, starting from their position, skipping ids already taken
|
|
79
|
+
// New sections without an id get s<n>, starting from their position, skipping ids already taken
|
|
80
|
+
// and every number that was ever handed out: notes and picks name a section by id, so a removed
|
|
81
|
+
// section's id must not come back for new words. `top` is the highest number seen, whether it is
|
|
82
|
+
// in the script now, was in it before this call, or was recorded when it was given out.
|
|
74
83
|
const taken = new Set(sorted.flatMap((s) => (s.id === null ? [] : [s.id])));
|
|
84
|
+
let top = script.sectionCounter ?? 0;
|
|
85
|
+
for (const id of [...taken, ...existing])
|
|
86
|
+
top = Math.max(top, Number(/^s(\d+)$/.exec(id)?.[1] ?? 0));
|
|
75
87
|
const next = sorted.map((s, i) => {
|
|
76
88
|
if (s.id !== null)
|
|
77
89
|
return s;
|
|
78
|
-
let n = i + 1;
|
|
90
|
+
let n = Math.max(i + 1, top + 1);
|
|
79
91
|
while (taken.has(`s${n}`))
|
|
80
92
|
n++;
|
|
81
93
|
taken.add(`s${n}`);
|
|
94
|
+
top = n;
|
|
82
95
|
return { ...s, id: `s${n}` };
|
|
83
96
|
});
|
|
84
97
|
script.sections = next;
|
|
98
|
+
script.sectionCounter = top;
|
|
85
99
|
return next;
|
|
86
100
|
}
|
|
87
101
|
export function findSection(script, id) {
|
package/dist/core/store.js
CHANGED
|
@@ -21,13 +21,16 @@ function defaults(key, name) {
|
|
|
21
21
|
return { schema: 1, rev: 0, dismissed: [], settled: [] };
|
|
22
22
|
case "log":
|
|
23
23
|
return { schema: 1, rev: 0, backfilled: false, undated: [], dropped: 0, entries: [] };
|
|
24
|
+
case "brief":
|
|
25
|
+
case "storyboard":
|
|
26
|
+
return { schema: 1, rev: 0, baseline: "", seen: "" };
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
27
|
-
* Files `init` doesn't write (found.json, log.json). Each is created by its first write, and reads
|
|
30
|
+
* Files `init` doesn't write (found.json, log.json, brief.json, storyboard.json). Each is created by its first write, and reads
|
|
28
31
|
* as its default until then, so a project made before the file existed needs nothing done to it.
|
|
29
32
|
*/
|
|
30
|
-
const CREATED_ON_WRITE = new Set(["found", "log"]);
|
|
33
|
+
const CREATED_ON_WRITE = new Set(["found", "log", "brief", "storyboard"]);
|
|
31
34
|
/**
|
|
32
35
|
* The only writer of a project's .rushes folder. Every write is validated,
|
|
33
36
|
* serialised per file, written atomically (tmp + rename) and announced with
|
|
@@ -133,8 +136,11 @@ export class Store extends EventEmitter {
|
|
|
133
136
|
export function serialise(data) {
|
|
134
137
|
return JSON.stringify(data, null, 2) + "\n";
|
|
135
138
|
}
|
|
139
|
+
// Counts every atomic write in this process. Two Store objects on one project don't see each other's
|
|
140
|
+
// writes, so pid + millisecond alone can repeat and send both to the same temp file.
|
|
141
|
+
let writes = 0;
|
|
136
142
|
async function atomicWrite(path, text) {
|
|
137
|
-
const tmp = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
143
|
+
const tmp = `${path}.${process.pid}.${Date.now()}.${++writes}.tmp`;
|
|
138
144
|
await writeFile(tmp, text, "utf8");
|
|
139
145
|
await rename(tmp, path);
|
|
140
146
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { parseBrief, setSectionBody } from "./brief.js";
|
|
2
|
+
// §24.12: storyboard.md is the file of record for the shots, as brief.md is for the brief. One section per
|
|
3
|
+
// shot ("## Shot 02 · Drop a folder"). Its facts are the lines above the first blank line (Tag, Length, Still,
|
|
4
|
+
// Status, Direction); what follows is what happens. These are pure functions over the text: everything the
|
|
5
|
+
// page does not touch (the title, other sections, the user's formatting) is left exactly as it was.
|
|
6
|
+
/** The storyboard's file name, in the project folder's root. */
|
|
7
|
+
export const STORYBOARD_FILE = "storyboard.md";
|
|
8
|
+
const HEADING = /^Shot\s+(\d+)\s*[·:–—-]\s*(.+?)\s*$/i;
|
|
9
|
+
const META = /^(Tag|Length|Still|Status|Direction):[ \t]*(.*?)[ \t]*$/i;
|
|
10
|
+
/** What a still may be: pictures a browser shows inline. */
|
|
11
|
+
const IMAGE = /\.(png|jpe?g|webp|gif|avif)$/i;
|
|
12
|
+
/** A still's path as the page may use it: relative, inside the project, a picture. Anything else is no still. */
|
|
13
|
+
export function stillPath(raw) {
|
|
14
|
+
const p = raw.trim().replace(/^\.\//, "");
|
|
15
|
+
if (!p || p.startsWith("/") || p.startsWith("~") || /^[a-z]:/i.test(p) || p.includes("\\") || p.includes("\0"))
|
|
16
|
+
return null;
|
|
17
|
+
if (p.split("/").some((seg) => seg === ".." || seg === "" || seg === "."))
|
|
18
|
+
return null;
|
|
19
|
+
return IMAGE.test(p) ? p : null;
|
|
20
|
+
}
|
|
21
|
+
/** A shot section's body split into its fact lines and what happens. */
|
|
22
|
+
function split(body) {
|
|
23
|
+
const lines = body.split("\n");
|
|
24
|
+
let i = 0;
|
|
25
|
+
while (i < lines.length && META.test(lines[i]))
|
|
26
|
+
i++;
|
|
27
|
+
const meta = lines.slice(0, i);
|
|
28
|
+
if (i < lines.length && lines[i].trim() === "")
|
|
29
|
+
i++;
|
|
30
|
+
return { meta, description: lines.slice(i).join("\n").replace(/\s+$/, "") };
|
|
31
|
+
}
|
|
32
|
+
const metaOf = (meta, key) => {
|
|
33
|
+
for (const l of meta) {
|
|
34
|
+
const m = META.exec(l);
|
|
35
|
+
if (m && m[1].toLowerCase() === key.toLowerCase())
|
|
36
|
+
return m[2];
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
};
|
|
40
|
+
export function parseStoryboard(text) {
|
|
41
|
+
const brief = parseBrief(text);
|
|
42
|
+
const shots = [];
|
|
43
|
+
brief.sections.forEach((s, index) => {
|
|
44
|
+
const h = HEADING.exec(s.heading);
|
|
45
|
+
if (!h)
|
|
46
|
+
return;
|
|
47
|
+
const { meta, description } = split(s.body);
|
|
48
|
+
const length = Number(metaOf(meta, "Length"));
|
|
49
|
+
shots.push({
|
|
50
|
+
index,
|
|
51
|
+
heading: s.heading,
|
|
52
|
+
n: Number(h[1]),
|
|
53
|
+
name: h[2],
|
|
54
|
+
tag: metaOf(meta, "Tag") ?? "",
|
|
55
|
+
length: Number.isFinite(length) && length > 0 ? length : null,
|
|
56
|
+
still: stillPath(metaOf(meta, "Still") ?? ""),
|
|
57
|
+
status: (metaOf(meta, "Status") ?? "").toLowerCase() === "approved" ? "approved" : "draft",
|
|
58
|
+
direction: metaOf(meta, "Direction") ?? "",
|
|
59
|
+
description,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
return { title: brief.title.replace(/^Storyboard:[ \t]*/i, ""), shots };
|
|
63
|
+
}
|
|
64
|
+
/** The section's body rebuilt from its fact lines and its description. */
|
|
65
|
+
function join(meta, description) {
|
|
66
|
+
const d = description.replace(/\r\n/g, "\n").replace(/^\s*\n+/, "").replace(/\s+$/, "");
|
|
67
|
+
return d ? [...meta, "", d].join("\n") : meta.join("\n");
|
|
68
|
+
}
|
|
69
|
+
function withMeta(meta, key, value) {
|
|
70
|
+
const at = meta.findIndex((l) => META.exec(l)?.[1].toLowerCase() === key.toLowerCase());
|
|
71
|
+
if (at >= 0) {
|
|
72
|
+
const name = META.exec(meta[at])[1];
|
|
73
|
+
return meta.map((l, i) => (i === at ? `${name}: ${value}`.trimEnd() : l));
|
|
74
|
+
}
|
|
75
|
+
return [...meta, `${key}: ${value}`.trimEnd()];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* `text` with one shot changed. `heading` must be the heading at `index` (a file that was reordered under you
|
|
79
|
+
* is refused, not edited in the wrong place). Only the fields given change; a missing fact line is added.
|
|
80
|
+
*/
|
|
81
|
+
export function editShot(text, index, heading, edit) {
|
|
82
|
+
const section = parseBrief(text).sections[index];
|
|
83
|
+
if (!section || section.heading !== heading || !HEADING.test(heading))
|
|
84
|
+
throw new Error(`No shot "${heading}" at position ${index + 1}`);
|
|
85
|
+
const parts = split(section.body);
|
|
86
|
+
let meta = parts.meta;
|
|
87
|
+
if (edit.direction !== undefined)
|
|
88
|
+
meta = withMeta(meta, "Direction", edit.direction.replace(/\s*\r?\n\s*/g, " ").trim());
|
|
89
|
+
if (edit.status !== undefined)
|
|
90
|
+
meta = withMeta(meta, "Status", edit.status);
|
|
91
|
+
const description = edit.description !== undefined ? edit.description : parts.description;
|
|
92
|
+
return setSectionBody(text, index, heading, join(meta, description));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The shots as a cut's shot list: each `start` is the running total of the lengths before it. A shot with
|
|
96
|
+
* no usable Length counts as one second, so two shots never start together.
|
|
97
|
+
*/
|
|
98
|
+
export function cutShots(shots) {
|
|
99
|
+
let start = 0;
|
|
100
|
+
return shots.map((s) => {
|
|
101
|
+
const out = { name: s.name.slice(0, 80), start: Math.round(start * 1000) / 1000, tag: s.tag.slice(0, 24) };
|
|
102
|
+
start += s.length ?? 1;
|
|
103
|
+
return out;
|
|
104
|
+
});
|
|
105
|
+
}
|
package/dist/mcp/stdio.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
|
-
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
5
|
import { createMcpServer } from "./tools.js";
|
|
6
6
|
import { ensureServer } from "./ensure.js";
|
|
@@ -17,7 +17,7 @@ export function openBrowser(url) {
|
|
|
17
17
|
* project, so those throw and ask the agent to name one.
|
|
18
18
|
*/
|
|
19
19
|
export function resolveProjectRoot(defaultRoot, project) {
|
|
20
|
-
const root =
|
|
20
|
+
const root = projectPath(defaultRoot, project);
|
|
21
21
|
if (dirname(root) === root || root === resolve(homedir())) {
|
|
22
22
|
throw new Error('Tell me which project folder to use: pass "project" (e.g. "/Users/you/Videos/launch-film").');
|
|
23
23
|
}
|
|
@@ -30,7 +30,16 @@ export function resolveProjectRoot(defaultRoot, project) {
|
|
|
30
30
|
* folder" there, same as any other folder with no .rushes.
|
|
31
31
|
*/
|
|
32
32
|
export function resolveDoctorRoot(defaultRoot, project) {
|
|
33
|
-
return
|
|
33
|
+
return projectPath(defaultRoot, project);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* `project` against the launch folder. A leading "~" or "~/" is the home folder, as a shell would
|
|
37
|
+
* read it: agents write paths that way, and resolve() alone would make a folder called "~" in the
|
|
38
|
+
* working directory.
|
|
39
|
+
*/
|
|
40
|
+
function projectPath(defaultRoot, project = ".") {
|
|
41
|
+
const fromHome = project === "~" || /^~[\\/]/.test(project);
|
|
42
|
+
return resolve(defaultRoot, fromHome ? join(homedir(), project.slice(2)) : project);
|
|
34
43
|
}
|
|
35
44
|
/** The tool context runStdio uses. */
|
|
36
45
|
export function stdioContext(defaultRoot, ensure) {
|