rushes 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +36 -8
- package/README.md +75 -4
- package/dist/cli/doctor.js +35 -10
- package/dist/cli/main.js +200 -18
- package/dist/core/batches.js +35 -3
- package/dist/core/exportNotes.js +9 -5
- package/dist/core/formats.js +159 -0
- package/dist/core/found.js +333 -0
- package/dist/core/labels.js +192 -0
- package/dist/core/log.js +190 -0
- package/dist/core/logEvents.js +193 -0
- package/dist/core/logText.js +122 -0
- package/dist/core/media.js +119 -13
- package/dist/core/notes.js +35 -4
- package/dist/core/project.js +69 -1
- package/dist/core/schema.js +147 -1
- package/dist/core/store.js +19 -3
- package/dist/mcp/client.js +13 -1
- package/dist/mcp/tools.js +181 -11
- package/dist/server/app.js +495 -38
- package/dist/server/assets.js +19 -7
- package/dist/server/files.js +61 -4
- package/dist/server/found.js +1216 -0
- package/dist/server/logbook.js +208 -0
- package/dist/server/loudness.js +7 -3
- package/dist/server/peaks.js +3 -2
- package/dist/server/proxy.js +16 -4
- package/dist/server/start.js +15 -2
- package/package.json +1 -1
- package/skills/rushes/SKILL.md +9 -4
- package/web-dist/assets/index-BDMm5p1-.css +1 -0
- package/web-dist/assets/index-C9dBtlRy.js +3 -0
- package/web-dist/index.html +2 -2
- package/web-dist/assets/index-ChXjhVC5.js +0 -3
- package/web-dist/assets/index-Cj_tr1I-.css +0 -1
package/dist/server/assets.js
CHANGED
|
@@ -3,26 +3,28 @@ import { basename, extname, join } from "node:path";
|
|
|
3
3
|
import { fromManifestPath } from "../core/paths.js";
|
|
4
4
|
import { GRAB_PATH, SCREENSHOT_PATH, registeredMedia } from "./files.js";
|
|
5
5
|
import { PROXY_PATH } from "./proxy.js";
|
|
6
|
+
import { chipOrder, labelOfId, versionFormats } from "../core/formats.js";
|
|
6
7
|
/**
|
|
7
8
|
* "hero-60s_v3_00m12.10s_f726.png": the time is frame/fps, rounded to hundredths before
|
|
8
9
|
* splitting into minutes and seconds -- the same rule fmt() uses, so 59.999s carries into the
|
|
9
10
|
* next minute rather than printing 00m60.00s.
|
|
10
11
|
*/
|
|
11
|
-
export function screenshotName(video, version, frame, fps) {
|
|
12
|
+
export function screenshotName(video, version, frame, fps, format = null) {
|
|
12
13
|
const t = frame / fps;
|
|
13
14
|
const cs = Math.round(Math.max(0, t) * 100);
|
|
14
15
|
const m = Math.floor(cs / 6000);
|
|
15
16
|
const s = ((cs - m * 6000) / 100).toFixed(2).padStart(5, "0");
|
|
16
17
|
const mm = String(m).padStart(2, "0");
|
|
17
|
-
|
|
18
|
+
// §21.5: a grab of a cut with formats carries the ratio it shows ("hero_v1_9x16_00m01.00s_f30.png").
|
|
19
|
+
return `${video}_${version}${format ? `_${format}` : ""}_${mm}m${s}s_f${frame}.png`;
|
|
18
20
|
}
|
|
19
21
|
/** The fps to use for a grab or screenshot: the version's own, falling back to the project's. */
|
|
20
22
|
export function fpsFor(project, video, version) {
|
|
21
23
|
const v = project.videos.find((x) => x.id === video)?.versions.find((x) => x.id === version);
|
|
22
24
|
return v?.fps ?? project.fps;
|
|
23
25
|
}
|
|
24
|
-
// Parses a name screenshotName() itself produced.
|
|
25
|
-
const NEW_NAME = /^([a-z0-9][a-z0-9-]*)_(v\d+)_(\d{2})m(\d{2}\.\d{2})s_f(\d+)\.png$/;
|
|
26
|
+
// Parses a name screenshotName() itself produced, with or without a format's ratio (§21.5).
|
|
27
|
+
const NEW_NAME = /^([a-z0-9][a-z0-9-]*)_(v\d+)(?:_(\d+(?:\.\d+)?x\d+(?:\.\d+)?))?_(\d{2})m(\d{2}\.\d{2})s_f(\d+)\.png$/;
|
|
26
28
|
// Parses a Plan 1-2 grab name: {video}_{version}_f{frame}.png.
|
|
27
29
|
const OLD_NAME = /^([a-z0-9][a-z0-9-]*)_(v\d+)_f(\d+)\.png$/;
|
|
28
30
|
async function statInfo(abs) {
|
|
@@ -68,8 +70,12 @@ async function scanScreenshotDir(store, names, manifestPrefix, safe, project) {
|
|
|
68
70
|
if (newMatch) {
|
|
69
71
|
asset.video = newMatch[1];
|
|
70
72
|
asset.version = newMatch[2];
|
|
71
|
-
asset.frame = Number(newMatch[
|
|
73
|
+
asset.frame = Number(newMatch[6]);
|
|
72
74
|
asset.t = asset.frame / fpsFor(project, asset.video, asset.version);
|
|
75
|
+
if (newMatch[3]) {
|
|
76
|
+
asset.format = newMatch[3];
|
|
77
|
+
asset.formatLabel = labelOfId(newMatch[3]);
|
|
78
|
+
}
|
|
73
79
|
}
|
|
74
80
|
else if (oldMatch) {
|
|
75
81
|
asset.video = oldMatch[1];
|
|
@@ -183,7 +189,13 @@ function variantEntries(project, stage) {
|
|
|
183
189
|
* in parallel within each group, so a large project doesn't pay for it one file at a time.
|
|
184
190
|
*/
|
|
185
191
|
export async function listAssets(store, project, script) {
|
|
186
|
-
const cutEntries = project.videos.flatMap((video) => [...video.versions].reverse().
|
|
192
|
+
const cutEntries = project.videos.flatMap((video) => [...video.versions].reverse().flatMap((version) => {
|
|
193
|
+
const views = versionFormats(version);
|
|
194
|
+
const primary = views.find((f) => f.primary);
|
|
195
|
+
const own = { video: video.id, version: version.id, file: version.file, ...(version.formats.length > 0 && primary ? { formatLabel: primary.label } : {}) };
|
|
196
|
+
const subs = chipOrder(version.formats).map((f) => ({ video: video.id, version: version.id, file: f.file, format: f.id, formatLabel: labelOfId(f.id), width: f.width, height: f.height }));
|
|
197
|
+
return [own, ...subs];
|
|
198
|
+
}));
|
|
187
199
|
const proxyEntries = project.videos.flatMap((video) =>
|
|
188
200
|
// Only a file this server would have written into proxies/: a hand-edited record pointing
|
|
189
201
|
// anywhere else (the original, say) is never offered for deletion as a proxy.
|
|
@@ -194,7 +206,7 @@ export async function listAssets(store, project, script) {
|
|
|
194
206
|
const takeEntries = script.sections.flatMap((section) => section.takes.map((take, i) => ({ section: section.id, file: take.file, label: `Take ${i + 1}` })));
|
|
195
207
|
const [[freshNames, oldNames], cuts, proxies, takes, voice, music, sfx] = await Promise.all([
|
|
196
208
|
Promise.all([pngNames(store, SCREENSHOT_DIRS[0][0]), pngNames(store, SCREENSHOT_DIRS[1][0])]),
|
|
197
|
-
Promise.all(cutEntries.map((e) => fileAsset(store, "cut", e.file, { video: e.video, version: e.version }))),
|
|
209
|
+
Promise.all(cutEntries.map((e) => fileAsset(store, "cut", e.file, { video: e.video, version: e.version, format: e.format, formatLabel: e.formatLabel, width: e.width, height: e.height }))),
|
|
198
210
|
Promise.all(proxyEntries.map((e) => fileAsset(store, "proxy", e.proxy.file, { video: e.video, version: e.version, width: e.proxy.width, height: e.proxy.height }))),
|
|
199
211
|
Promise.all(takeEntries.map((e) => fileAsset(store, "take", e.file, { section: e.section, label: e.label }))),
|
|
200
212
|
Promise.all(variantEntries(project, "voice").map((e) => fileAsset(store, "voice", e.file, { lane: e.lane, laneName: e.laneName, variant: e.variant, label: e.label, meta: e.meta }))),
|
package/dist/server/files.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createReadStream } from "node:fs";
|
|
2
|
-
import { realpath, stat } from "node:fs/promises";
|
|
3
|
-
import { extname, join, normalize, sep } from "node:path";
|
|
2
|
+
import { lstat, realpath, stat } from "node:fs/promises";
|
|
3
|
+
import { extname, isAbsolute, join, normalize, sep } from "node:path";
|
|
4
4
|
import { Readable } from "node:stream";
|
|
5
|
+
import { VIDEO_EXT } from "../core/media.js";
|
|
5
6
|
import { PROXY_PATH } from "./proxy.js";
|
|
6
7
|
export const CONTENT_TYPES = {
|
|
7
8
|
".mp4": "video/mp4",
|
|
@@ -73,6 +74,9 @@ export function registeredMedia(project, script) {
|
|
|
73
74
|
// server would write, so a hand-edited record can't open up any other file.
|
|
74
75
|
if (ver.proxy && PROXY_PATH.test(ver.proxy.file))
|
|
75
76
|
files.add(ver.proxy.file);
|
|
77
|
+
// §21: a cut's other formats play in Picture like the cut itself, under the same §15.5 rules.
|
|
78
|
+
for (const f of ver.formats)
|
|
79
|
+
files.add(f.file);
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
for (const l of project.lanes)
|
|
@@ -85,11 +89,64 @@ export function registeredMedia(project, script) {
|
|
|
85
89
|
files.add(f.file);
|
|
86
90
|
return files;
|
|
87
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* §15.5 and §20.5: the file on disk for a found candidate `rel` (a manifest path the scan recorded), or null
|
|
94
|
+
* when it may not be served. It must be a plain relative path (no absolute path, no `.` or `..`
|
|
95
|
+
* segment, no backslash), a plain file and not a symlink, and its real path must be exactly the
|
|
96
|
+
* root's real path plus `rel`: so no folder on the way has been swapped for a symlink since the
|
|
97
|
+
* scan, and nothing outside the project folder is ever reached.
|
|
98
|
+
*/
|
|
99
|
+
export async function foundMediaFile(root, rel) {
|
|
100
|
+
if (rel === "" || rel.includes("\\") || rel.includes("\0") || isAbsolute(rel) || /^[A-Za-z]:/.test(rel))
|
|
101
|
+
return null;
|
|
102
|
+
const parts = rel.split("/");
|
|
103
|
+
if (parts.some((p) => p === "" || p === "." || p === ".."))
|
|
104
|
+
return null;
|
|
105
|
+
try {
|
|
106
|
+
const realRoot = await realpath(root);
|
|
107
|
+
const abs = join(realRoot, ...parts);
|
|
108
|
+
const info = await lstat(abs);
|
|
109
|
+
if (!info.isFile() || info.isSymbolicLink())
|
|
110
|
+
return null;
|
|
111
|
+
if ((await realpath(abs)) !== abs)
|
|
112
|
+
return null;
|
|
113
|
+
return abs;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
88
119
|
/** §15.5: the only kinds of file /media serves when its real path lies outside the project (footage on another drive, say). */
|
|
89
120
|
export const OUTSIDE_MEDIA_EXT = new Set([
|
|
90
121
|
"wav", "mp3", "m4a", "aac", "aif", "aiff", "flac", "ogg", "opus", "mp4", "mov", "m4v", "webm", "mkv",
|
|
91
122
|
"png", "jpg", "jpeg", "gif", "webp", "pdf", "md", "txt", "srt", "vtt",
|
|
92
123
|
]);
|
|
124
|
+
/**
|
|
125
|
+
* Final review M2: a cut or a format whose real file lies outside the project is served only as
|
|
126
|
+
* video (the dashboard's VIDEO_EXT) or as the audio §15.5 already serves; never as text, an image
|
|
127
|
+
* or a PDF, which the library's other files may be. Inside the project nothing changes.
|
|
128
|
+
*/
|
|
129
|
+
export const OUTSIDE_CUT_EXT = new Set([...VIDEO_EXT, "wav", "mp3", "m4a", "aac", "aif", "aiff", "flac", "ogg", "opus"]);
|
|
130
|
+
/** Every path registered as a cut or a cut's format, and as nothing else (a library file keeps its own rules). */
|
|
131
|
+
export function cutOnlyFiles(project, script) {
|
|
132
|
+
const other = new Set();
|
|
133
|
+
for (const l of project.lanes)
|
|
134
|
+
for (const variant of l.variants)
|
|
135
|
+
other.add(variant.file);
|
|
136
|
+
for (const s of script.sections)
|
|
137
|
+
for (const t of s.takes)
|
|
138
|
+
other.add(t.file);
|
|
139
|
+
for (const f of project.files)
|
|
140
|
+
other.add(f.file);
|
|
141
|
+
const cuts = new Set();
|
|
142
|
+
for (const v of project.videos) {
|
|
143
|
+
for (const ver of v.versions)
|
|
144
|
+
for (const file of [ver.file, ...ver.formats.map((f) => f.file)])
|
|
145
|
+
if (!other.has(file))
|
|
146
|
+
cuts.add(file);
|
|
147
|
+
}
|
|
148
|
+
return cuts;
|
|
149
|
+
}
|
|
93
150
|
/**
|
|
94
151
|
* The file /media sends for a path it has already accepted: its real path, every symlink
|
|
95
152
|
* resolved. A real path inside the project is served whatever it is, as before. Policy (§15.5):
|
|
@@ -97,7 +154,7 @@ export const OUTSIDE_MEDIA_EXT = new Set([
|
|
|
97
154
|
* (`OUTSIDE_MEDIA_EXT`), so a take swapped for a link to a key file is never served. Null means
|
|
98
155
|
* refuse. A file that isn't there gives back the plain path, so the send reports it missing.
|
|
99
156
|
*/
|
|
100
|
-
export async function servableFile(root, abs) {
|
|
157
|
+
export async function servableFile(root, abs, outsideExt = OUTSIDE_MEDIA_EXT) {
|
|
101
158
|
let real;
|
|
102
159
|
try {
|
|
103
160
|
real = await realpath(abs);
|
|
@@ -115,7 +172,7 @@ export async function servableFile(root, abs) {
|
|
|
115
172
|
if (real === realRoot || real.startsWith(realRoot.endsWith(sep) ? realRoot : realRoot + sep))
|
|
116
173
|
return real;
|
|
117
174
|
const ext = extname(real).toLowerCase().replace(/^\./, "");
|
|
118
|
-
return
|
|
175
|
+
return outsideExt.has(ext) ? real : null;
|
|
119
176
|
}
|
|
120
177
|
/** Parse a single "bytes=a-b" range against a file size. Returns null for a missing or unusable range. */
|
|
121
178
|
export function parseRange(header, size) {
|