editorbrain 0.42.0 → 0.42.1
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/README.md +2 -2
- package/bin/editorbrain.mjs +363 -183
- package/package.json +1 -1
- package/skill/editorbrain/references/style-creator.md +6 -4
package/bin/editorbrain.mjs
CHANGED
|
@@ -216,6 +216,7 @@ function checkStyle(files, id3) {
|
|
|
216
216
|
var obj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
217
217
|
var text = (v) => typeof v === "string" && v.trim().length > 0 && v.length <= 8e3;
|
|
218
218
|
var id = (v) => typeof v === "string" && /^[a-z0-9][a-z0-9_-]{0,79}$/.test(v) && !["constructor", "prototype", "__proto__"].includes(v);
|
|
219
|
+
var bindingName = (v) => typeof v === "string" && /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,79}$/.test(v) && !["constructor", "prototype", "__proto__"].includes(v);
|
|
219
220
|
var texts = (v) => Array.isArray(v) && v.length <= 100 && v.every(text);
|
|
220
221
|
var ids = (v) => Array.isArray(v) && v.length <= 100 && v.every(id) && new Set(v).size === v.length;
|
|
221
222
|
var unit = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 1;
|
|
@@ -283,9 +284,10 @@ function styleReuseIssues(name, value, expectedId) {
|
|
|
283
284
|
}
|
|
284
285
|
fields(c, ["id", "sourceResourceId", "originPath", "status", "bindings"], "Component");
|
|
285
286
|
const names = /* @__PURE__ */ new Set();
|
|
286
|
-
for (const b of c.bindings) {
|
|
287
|
-
|
|
288
|
-
|
|
287
|
+
for (const [index, b] of c.bindings.entries()) {
|
|
288
|
+
const label = `Component ${c.id}, binding ${index + 1}${obj(b) ? " (" + JSON.stringify(b.name) + ")" : ""}`;
|
|
289
|
+
fields(b, ["name", "type", "literal", "occurrences", "role"], label);
|
|
290
|
+
if (!obj(b) || !bindingName(b.name) || names.has(b.name) || !["string", "number", "boolean"].includes(String(b.type)) || typeof b.literal !== b.type || typeof b.literal === "number" && !Number.isFinite(b.literal) || typeof b.literal === "string" && b.literal.length > 8e3 || !Number.isInteger(b.occurrences) || Number(b.occurrences) < 1 || Number(b.occurrences) > 1e3 || ["clip", "directory"].includes(String(b.role)) && b.type !== "string" || b.role !== void 0 && !["clip", "directory", "text", "timing", "layout"].includes(String(b.role))) add(`${label}: use a unique name starting with a letter or number (letters, numbers, _ or -, max 80; camelCase allowed), type string|number|boolean, literal of that type, occurrences:1..1000 and optional role clip|directory|text|timing|layout. Clip and directory bindings require type string.`);
|
|
289
291
|
if (obj(b)) names.add(b.name);
|
|
290
292
|
}
|
|
291
293
|
if (c.status === "parameterized" && !c.bindings.length) add("Parameterized components require explicit bindings.");
|
|
@@ -181660,7 +181662,7 @@ function parseReviewTranscript(value) {
|
|
|
181660
181662
|
const fail3 = () => {
|
|
181661
181663
|
throw new Error("Invalid review transcript: use schemaVersion 1, durationMs and up to 200 unique timed phrases. Kept phrases use sample times; removed phrases require source times only.");
|
|
181662
181664
|
};
|
|
181663
|
-
const
|
|
181665
|
+
const object14 = (v, keys2) => {
|
|
181664
181666
|
if (!v || typeof v !== "object" || Array.isArray(v) || Object.keys(v).some((k) => !keys2.includes(k))) fail3();
|
|
181665
181667
|
return v;
|
|
181666
181668
|
};
|
|
@@ -181668,13 +181670,13 @@ function parseReviewTranscript(value) {
|
|
|
181668
181670
|
if (!Number.isSafeInteger(v) || v < 0 || v > 36e6) fail3();
|
|
181669
181671
|
return v;
|
|
181670
181672
|
};
|
|
181671
|
-
const root =
|
|
181673
|
+
const root = object14(value, ["schemaVersion", "durationMs", "segments"]);
|
|
181672
181674
|
if (root.schemaVersion !== 1 || !Array.isArray(root.segments) || root.segments.length > 200) fail3();
|
|
181673
181675
|
const durationMs = ms(root.durationMs);
|
|
181674
181676
|
if (!durationMs) fail3();
|
|
181675
181677
|
const ids2 = /* @__PURE__ */ new Set();
|
|
181676
181678
|
const segments = root.segments.map((v) => {
|
|
181677
|
-
const s =
|
|
181679
|
+
const s = object14(v, ["id", "text", "state", "startMs", "endMs", "source"]);
|
|
181678
181680
|
if (typeof s.id !== "string" || !/^[a-zA-Z0-9_-]{1,80}$/.test(s.id) || ids2.has(s.id) || typeof s.text !== "string" || !s.text.trim() || s.text.length > 500 || !["kept", "removed"].includes(s.state)) fail3();
|
|
181679
181681
|
const id3 = s.id;
|
|
181680
181682
|
ids2.add(id3);
|
|
@@ -181685,7 +181687,7 @@ function parseReviewTranscript(value) {
|
|
|
181685
181687
|
if (segment.endMs <= segment.startMs || segment.endMs > durationMs) fail3();
|
|
181686
181688
|
} else if (s.startMs !== void 0 || s.endMs !== void 0 || !s.source) fail3();
|
|
181687
181689
|
if (s.source !== void 0) {
|
|
181688
|
-
const source2 =
|
|
181690
|
+
const source2 = object14(s.source, ["assetId", "startMs", "endMs"]);
|
|
181689
181691
|
if (typeof source2.assetId !== "string" || !/^[a-f0-9]{64}$/.test(source2.assetId)) fail3();
|
|
181690
181692
|
segment.source = { assetId: source2.assetId, startMs: ms(source2.startMs), endMs: ms(source2.endMs) };
|
|
181691
181693
|
if (segment.source.endMs <= segment.source.startMs) fail3();
|
|
@@ -182537,7 +182539,7 @@ function styleAssetPath(id3, source2) {
|
|
|
182537
182539
|
|
|
182538
182540
|
// packages/cli/src/style-sync.ts
|
|
182539
182541
|
import { createHash as createHash3 } from "node:crypto";
|
|
182540
|
-
import { lstat as
|
|
182542
|
+
import { lstat as lstat5 } from "node:fs/promises";
|
|
182541
182543
|
import { posix as posix3 } from "node:path";
|
|
182542
182544
|
|
|
182543
182545
|
// packages/cli/src/io.ts
|
|
@@ -182556,7 +182558,7 @@ async function checkedPath(root, path, document2 = true) {
|
|
|
182556
182558
|
if (document2) safeDocumentPath(path);
|
|
182557
182559
|
const target = resolve(root, path);
|
|
182558
182560
|
const rel = relative(root, target);
|
|
182559
|
-
if (!rel || rel.startsWith(`..${sep}`) || rel === ".." || resolve(path) === path) throw new Error(
|
|
182561
|
+
if (!rel || rel.startsWith(`..${sep}`) || rel === ".." || resolve(path) === path) throw new Error(`Path escapes workspace: ${JSON.stringify(path)}. Use a workspace-relative path inside ${JSON.stringify(root)}; absolute paths and parent traversal are not accepted. Copy the input into this workspace first.`);
|
|
182560
182562
|
let cursor = root;
|
|
182561
182563
|
for (const segment of rel.split(sep)) {
|
|
182562
182564
|
cursor = join(cursor, segment);
|
|
@@ -183042,7 +183044,8 @@ ${conflicts.join("\n")}`, "Run pull --dry-run and reconcile the reported paths."
|
|
|
183042
183044
|
|
|
183043
183045
|
// packages/cli/src/style-project.ts
|
|
183044
183046
|
import { createHash } from "node:crypto";
|
|
183045
|
-
import {
|
|
183047
|
+
import { constants as constants3 } from "node:fs";
|
|
183048
|
+
import { readdir as readdir2, lstat as lstat2, open as open3 } from "node:fs/promises";
|
|
183046
183049
|
import { posix as posix2 } from "node:path";
|
|
183047
183050
|
|
|
183048
183051
|
// packages/cli/src/review-files.ts
|
|
@@ -183072,7 +183075,32 @@ async function readReviewFile(path, maxBytes) {
|
|
|
183072
183075
|
// packages/cli/src/style-project.ts
|
|
183073
183076
|
var media = /\.(png|jpe?g|webp|mp4|mov|webm|wav|mp3|m4a|ogg|woff2?|ttf|otf|html|js|mjs)$/i;
|
|
183074
183077
|
var digest2 = (b) => createHash("sha256").update(b).digest("hex");
|
|
183078
|
+
var object7 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
183079
|
+
function generationReceipt(value) {
|
|
183080
|
+
if (!object7(value)) return;
|
|
183081
|
+
for (const v of [value, value.data, value.result]) if (object7(v) && (typeof v.model === "string" || typeof v.provider === "string") && ["prompt", "input", "output", "outputs", "outputPath", "path", "result", "taskId", "jobId", "tasks", "jobs"].some((k) => v[k] !== void 0)) return v;
|
|
183082
|
+
}
|
|
183075
183083
|
var kind = (path) => /\.(png|jpe?g|webp)$/i.test(path) ? "image" : /\.(mp4|mov|webm)$/i.test(path) ? "video" : /\.(mp3|wav|m4a|ogg)$/i.test(path) ? "audio" : /\.(woff2?|ttf|otf)$/i.test(path) ? "font" : "script";
|
|
183084
|
+
async function videoEvidenceHash(path, expectedSize) {
|
|
183085
|
+
const handle = await open3(path, constants3.O_RDONLY | constants3.O_NOFOLLOW | constants3.O_NONBLOCK);
|
|
183086
|
+
try {
|
|
183087
|
+
const before = await handle.stat();
|
|
183088
|
+
if (!before.isFile() || before.size !== expectedSize) throw new Error("Video changed before hashing");
|
|
183089
|
+
const hash8 = createHash("sha256"), chunk = Buffer.alloc(1024 * 1024);
|
|
183090
|
+
let offset = 0;
|
|
183091
|
+
while (offset < before.size) {
|
|
183092
|
+
const { bytesRead } = await handle.read(chunk, 0, Math.min(chunk.length, before.size - offset), offset);
|
|
183093
|
+
if (!bytesRead) throw new Error("Video changed while hashing");
|
|
183094
|
+
hash8.update(chunk.subarray(0, bytesRead));
|
|
183095
|
+
offset += bytesRead;
|
|
183096
|
+
}
|
|
183097
|
+
const after = await handle.stat();
|
|
183098
|
+
if (after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.ctimeMs !== before.ctimeMs) throw new Error("Video changed while hashing");
|
|
183099
|
+
return hash8.digest("hex");
|
|
183100
|
+
} finally {
|
|
183101
|
+
await handle.close();
|
|
183102
|
+
}
|
|
183103
|
+
}
|
|
183076
183104
|
async function buildStyleFromProject(root, id3, projectId, name) {
|
|
183077
183105
|
assertIdentifier(projectId);
|
|
183078
183106
|
const prefix = `videos/${projectId}`, projectPath = `${prefix}/project.json`;
|
|
@@ -183080,17 +183108,26 @@ async function buildStyleFromProject(root, id3, projectId, name) {
|
|
|
183080
183108
|
const v = validateDocument(projectPath, raw);
|
|
183081
183109
|
if (!v.valid) throw new Error(v.issues.map((x) => x.message).join("\n"));
|
|
183082
183110
|
const project = JSON.parse(raw), files = createStyle({ id: id3, name }), base = `.editorbrain/styles/${id3}`;
|
|
183111
|
+
const notes = /* @__PURE__ */ new Map();
|
|
183083
183112
|
const warnings = [], candidates = /* @__PURE__ */ new Set(), jsonFiles = [], receipts = [];
|
|
183084
183113
|
let scanned = 0;
|
|
183114
|
+
const roots = [prefix, `.editorbrain-local/${projectId}`], scannedRoots = [];
|
|
183115
|
+
const allowed = (path) => !path.startsWith(".editorbrain/") && (!path.startsWith("videos/") || path.startsWith(prefix + "/")) && (!path.startsWith(".editorbrain-local/") || path.startsWith(roots[1] + "/"));
|
|
183085
183116
|
async function walk(directory, depth) {
|
|
183086
|
-
if (depth >
|
|
183117
|
+
if (depth > 8) {
|
|
183087
183118
|
warnings.push(`Directory depth limit: ${directory}`);
|
|
183088
183119
|
return;
|
|
183089
183120
|
}
|
|
183090
183121
|
for (const entry of (await readdir2(await checkedPath(root, directory, false), { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
183091
|
-
if (++scanned >
|
|
183122
|
+
if (++scanned > 2e3) throw new Error("Project capture exceeds 2000 entries; select a smaller project or an explicit resource manifest.");
|
|
183092
183123
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
183093
183124
|
const path = `${directory}/${entry.name}`;
|
|
183125
|
+
try {
|
|
183126
|
+
safeStyleResourcePath(path);
|
|
183127
|
+
} catch {
|
|
183128
|
+
warnings.push(`Skipped private or unsafe path: ${path}`);
|
|
183129
|
+
continue;
|
|
183130
|
+
}
|
|
183094
183131
|
if (entry.isSymbolicLink()) {
|
|
183095
183132
|
warnings.push(`Skipped symlink: ${path}`);
|
|
183096
183133
|
continue;
|
|
@@ -183100,37 +183137,56 @@ async function buildStyleFromProject(root, id3, projectId, name) {
|
|
|
183100
183137
|
continue;
|
|
183101
183138
|
}
|
|
183102
183139
|
if (!entry.isFile()) continue;
|
|
183140
|
+
if (["direction.md", "review.md"].includes(entry.name)) notes.set(entry.name, [...notes.get(entry.name) ?? [], path]);
|
|
183103
183141
|
if (media.test(path)) candidates.add(path);
|
|
183104
|
-
if (
|
|
183142
|
+
if (path.endsWith(".json")) {
|
|
183105
183143
|
try {
|
|
183106
183144
|
const bytes = await readReviewFile(await checkedPath(root, path, false), 128 * 1024), value = JSON.parse(bytes.toString());
|
|
183107
|
-
jsonFiles.push({ path, value });
|
|
183108
|
-
|
|
183145
|
+
if (object7(value) || Array.isArray(value)) jsonFiles.push({ path, value });
|
|
183146
|
+
const receipt = generationReceipt(value);
|
|
183147
|
+
if (receipt) receipts.push({ path, sha256: digest2(bytes), ...typeof receipt.model === "string" && /^[a-zA-Z0-9 ._/-]{1,100}$/.test(receipt.model) ? { model: receipt.model } : {} });
|
|
183109
183148
|
} catch {
|
|
183110
183149
|
warnings.push(`Unparsed or oversized manifest: ${path}`);
|
|
183111
183150
|
}
|
|
183112
183151
|
}
|
|
183113
183152
|
}
|
|
183114
183153
|
}
|
|
183115
|
-
|
|
183116
|
-
|
|
183154
|
+
for (const directory of roots) {
|
|
183155
|
+
try {
|
|
183156
|
+
const info = await lstat2(await checkedPath(root, directory, false));
|
|
183157
|
+
if (!info.isDirectory()) throw new Error(`Project capture root is not a directory: ${directory}`);
|
|
183158
|
+
} catch (error) {
|
|
183159
|
+
if (error.code === "ENOENT") continue;
|
|
183160
|
+
throw error;
|
|
183161
|
+
}
|
|
183162
|
+
await walk(directory, 0);
|
|
183163
|
+
scannedRoots.push(directory);
|
|
183164
|
+
}
|
|
183165
|
+
async function discover(value, parent, depth = 0) {
|
|
183117
183166
|
if (depth > 12) return;
|
|
183118
183167
|
if (Array.isArray(value)) {
|
|
183119
|
-
for (const item of value.slice(0, 500)) discover(item, parent, depth + 1);
|
|
183168
|
+
for (const item of value.slice(0, 500)) await discover(item, parent, depth + 1);
|
|
183120
183169
|
return;
|
|
183121
183170
|
}
|
|
183122
183171
|
if (value && typeof value === "object") for (const [key, item] of Object.entries(value)) {
|
|
183123
183172
|
if (["path", "file", "localPath", "outputPath", "src"].includes(key) && typeof item === "string" && media.test(item)) {
|
|
183124
|
-
|
|
183173
|
+
const paths2 = [];
|
|
183174
|
+
if (item.startsWith("videos/") || item.startsWith(".editorbrain-local/") || item.startsWith("production-assets/")) paths2.push(item);
|
|
183175
|
+
else for (let directory = posix2.dirname(parent); allowed(directory + "/") && (directory === prefix || directory.startsWith(prefix + "/") || directory === roots[1] || directory.startsWith(roots[1] + "/")); directory = posix2.dirname(directory)) paths2.push(posix2.join(directory, item));
|
|
183176
|
+
const existing = /* @__PURE__ */ new Set();
|
|
183177
|
+
for (const candidate of paths2) try {
|
|
183125
183178
|
safeStyleResourcePath(candidate);
|
|
183126
|
-
|
|
183179
|
+
if (!allowed(candidate)) continue;
|
|
183180
|
+
const info = await lstat2(await checkedPath(root, candidate, false));
|
|
183181
|
+
if (info.isFile()) existing.add(candidate);
|
|
183127
183182
|
} catch {
|
|
183128
|
-
warnings.push(`Ignored unsafe resource locator in ${parent}`);
|
|
183129
183183
|
}
|
|
183130
|
-
|
|
183184
|
+
if (existing.size === 1) candidates.add([...existing][0]);
|
|
183185
|
+
else warnings.push(`${existing.size ? "Ambiguous" : "Missing or unsafe"} resource locator in ${parent}; declare a workspace-relative path.`);
|
|
183186
|
+
} else await discover(item, parent, depth + 1);
|
|
183131
183187
|
}
|
|
183132
183188
|
}
|
|
183133
|
-
for (const entry of jsonFiles) discover(entry.value, entry.path);
|
|
183189
|
+
for (const entry of jsonFiles) await discover(entry.value, entry.path);
|
|
183134
183190
|
for (const path of [...candidates].filter((p) => p.endsWith(".html"))) {
|
|
183135
183191
|
try {
|
|
183136
183192
|
const html = (await readReviewFile(await checkedPath(root, path, false), 2 * 1024 * 1024)).toString();
|
|
@@ -183138,7 +183194,7 @@ async function buildStyleFromProject(root, id3, projectId, name) {
|
|
|
183138
183194
|
const child = posix2.join(posix2.dirname(path), m[1]);
|
|
183139
183195
|
try {
|
|
183140
183196
|
safeStyleResourcePath(child);
|
|
183141
|
-
if (media.test(child)) candidates.add(child);
|
|
183197
|
+
if (media.test(child) && allowed(child)) candidates.add(child);
|
|
183142
183198
|
} catch {
|
|
183143
183199
|
}
|
|
183144
183200
|
}
|
|
@@ -183146,66 +183202,111 @@ async function buildStyleFromProject(root, id3, projectId, name) {
|
|
|
183146
183202
|
warnings.push(`Could not inspect scene dependencies: ${path}`);
|
|
183147
183203
|
}
|
|
183148
183204
|
}
|
|
183149
|
-
if (candidates.size >
|
|
183205
|
+
if (candidates.size > 500) throw new Error("More than 500 candidate resources; curate this project before capturing it.");
|
|
183150
183206
|
const resources = [], examples = [], hashes = /* @__PURE__ */ new Map();
|
|
183151
183207
|
let bytesRead = 0;
|
|
183152
|
-
|
|
183208
|
+
const ordered = await Promise.all([...candidates].map(async (path) => {
|
|
183209
|
+
try {
|
|
183210
|
+
return { path, size: (await lstat2(await checkedPath(root, path, false))).size };
|
|
183211
|
+
} catch {
|
|
183212
|
+
return { path, size: Number.MAX_SAFE_INTEGER };
|
|
183213
|
+
}
|
|
183214
|
+
}));
|
|
183215
|
+
for (const { path, size } of ordered.sort((a, b) => a.size - b.size || a.path.localeCompare(b.path))) try {
|
|
183216
|
+
if (size === Number.MAX_SAFE_INTEGER) {
|
|
183217
|
+
warnings.push(`Resource missing or unsafe: ${path}`);
|
|
183218
|
+
continue;
|
|
183219
|
+
}
|
|
183220
|
+
if (bytesRead + size > 512 * 1024 * 1024) {
|
|
183221
|
+
warnings.push(`Capture byte budget reached; omitted ${path}. Declare it explicitly if needed.`);
|
|
183222
|
+
continue;
|
|
183223
|
+
}
|
|
183153
183224
|
safeStyleResourcePath(path);
|
|
183225
|
+
if (size > 90 * 1024 * 1024 && kind(path) === "video") {
|
|
183226
|
+
const hash9 = await videoEvidenceHash(await checkedPath(root, path, false), size);
|
|
183227
|
+
bytesRead += size;
|
|
183228
|
+
examples.push({ id: `video-${examples.length + 1}`, projectId, sourcePath: path, sha256: hash9, evidence: "local_video_hash_only", reviewStatus: "unreviewed" });
|
|
183229
|
+
warnings.push(`Video hashed as local evidence only (over 90 MiB): ${path}. Use a lightweight derivative or explicit requirement for portable resources.`);
|
|
183230
|
+
continue;
|
|
183231
|
+
}
|
|
183232
|
+
if (resources.length >= 200) {
|
|
183233
|
+
warnings.push(`Portable manifest limit (200 resources): omitted ${path}; curate explicit dependencies.`);
|
|
183234
|
+
continue;
|
|
183235
|
+
}
|
|
183154
183236
|
const bytes = await readReviewFile(await checkedPath(root, path, false), 90 * 1024 * 1024);
|
|
183155
183237
|
bytesRead += bytes.length;
|
|
183156
183238
|
if (bytesRead > 512 * 1024 * 1024) throw new Error("Project capture exceeds 512 MiB; use lightweight review assets.");
|
|
183157
183239
|
const hash8 = digest2(bytes), rid = `resource-${resources.length + 1}`;
|
|
183158
183240
|
hashes.set(hash8, rid);
|
|
183159
183241
|
resources.push({ id: rid, kind: kind(path), purpose: `Candidate from ${posix2.basename(path)}; confirm use and adaptation.`, required: true, source: { type: "local", path, sha256: hash8 } });
|
|
183160
|
-
if (
|
|
183242
|
+
if (kind(path) === "video") examples.push({ id: `video-${examples.length + 1}`, projectId, sourcePath: path, evidence: "candidate_video", resourceId: rid, sha256: hash8, reviewStatus: "unreviewed" });
|
|
183161
183243
|
} catch (error) {
|
|
183162
183244
|
if (error.message.startsWith("Project capture exceeds")) throw error;
|
|
183163
183245
|
warnings.push(`Resource unavailable or unsupported: ${path}`);
|
|
183164
183246
|
}
|
|
183165
183247
|
const beats = jsonFiles.flatMap(({ value }) => Array.isArray(value.beats) ? value.beats : Array.isArray(value.uses) ? value.uses : []);
|
|
183166
183248
|
for (const [i, b] of beats.entries()) {
|
|
183167
|
-
const t = b.timeline ?? b, start3 = t
|
|
183249
|
+
const t = object7(b) ? b.timeline ?? b : {}, start3 = t?.startSeconds, end3 = t?.endSeconds;
|
|
183168
183250
|
if (!Number.isFinite(start3) || !Number.isFinite(end3) || start3 < 0 || end3 <= start3) {
|
|
183169
183251
|
warnings.push(`Beat ${i + 1} has no valid measured interval; not invented.`);
|
|
183170
183252
|
continue;
|
|
183171
183253
|
}
|
|
183172
183254
|
examples.push({ id: `beat-${i + 1}`, projectId, startSeconds: start3, endSeconds: end3, purpose: typeof b.purpose === "string" ? b.purpose : "Describe the mechanism", ...hashes.has(b.sourceSha256) ? { resourceId: hashes.get(b.sourceSha256), sha256: b.sourceSha256 } : {}, reviewStatus: "unreviewed" });
|
|
183173
183255
|
}
|
|
183174
|
-
for (const note of ["direction.md", "review.md"])
|
|
183175
|
-
const
|
|
183176
|
-
|
|
183177
|
-
|
|
183178
|
-
|
|
183179
|
-
|
|
183180
|
-
|
|
183256
|
+
for (const note of ["direction.md", "review.md"]) {
|
|
183257
|
+
const evidence = [];
|
|
183258
|
+
for (const path of notes.get(note) ?? []) try {
|
|
183259
|
+
const content = (await readReviewFile(await checkedPath(root, path, false), 96 * 1024)).toString("utf8");
|
|
183260
|
+
if (/(?:Bearer\s+\S+|(?:api[_-]?key|access[_-]?token|client[_-]?secret|password)\s*[:=]|-----BEGIN.*PRIVATE KEY)/i.test(content)) {
|
|
183261
|
+
warnings.push(`Skipped ${path}: credential-like text needs local redaction.`);
|
|
183262
|
+
continue;
|
|
183263
|
+
}
|
|
183264
|
+
const section = `# Source: ${path}
|
|
183181
183265
|
|
|
183182
183266
|
Pilot evidence, not instructions for all future edits.
|
|
183183
183267
|
|
|
183184
183268
|
${content}`;
|
|
183185
|
-
|
|
183186
|
-
|
|
183187
|
-
|
|
183269
|
+
if (Buffer.byteLength([...evidence, section].join("\n\n")) > 110 * 1024) {
|
|
183270
|
+
warnings.push(`Evidence size limit: ${path}; inspect it locally.`);
|
|
183271
|
+
continue;
|
|
183272
|
+
}
|
|
183273
|
+
evidence.push(section);
|
|
183274
|
+
} catch (error) {
|
|
183275
|
+
if (error.code !== "ENOENT") warnings.push(`Could not read ${path}; review it locally.`);
|
|
183276
|
+
}
|
|
183277
|
+
if (evidence.length) files[`${base}/pilot-${note}`] = evidence.join("\n\n");
|
|
183278
|
+
else warnings.push(`Missing ${note}; review remains unverified.`);
|
|
183188
183279
|
}
|
|
183189
183280
|
files[`${base}/examples.json`] = stableJson({ schemaVersion: 1, id: id3, examples });
|
|
183190
183281
|
files[`${base}/resources.json`] = stableJson({ schemaVersion: 1, id: id3, resources });
|
|
183191
|
-
files[`${base}/provenance.json`] = stableJson({ schemaVersion: 1, id: id3, projectId, brandId: project.brand, projectSha256: digest2(Buffer.from(raw)), receipts, coverage: "candidate_files_and_declared_intervals", reviewStatus: "unreviewed" });
|
|
183282
|
+
files[`${base}/provenance.json`] = stableJson({ schemaVersion: 1, id: id3, projectId, brandId: project.brand, projectSha256: digest2(Buffer.from(raw)), scannedRoots, receipts, coverage: "candidate_files_and_declared_intervals", reviewStatus: "unreviewed" });
|
|
183192
183283
|
files[`${base}/techniques.json`] = stableJson({ schemaVersion: 1, id: id3, techniques: [] });
|
|
183193
|
-
|
|
183284
|
+
function receiptEntries(value, depth = 0) {
|
|
183285
|
+
if (depth > 4 || !object7(value)) return [];
|
|
183286
|
+
return [value, ...Object.values(value).slice(0, 100).flatMap((child) => receiptEntries(child, depth + 1))];
|
|
183287
|
+
}
|
|
183288
|
+
const promptExamples = jsonFiles.filter((x) => generationReceipt(x.value)).flatMap(({ path, value: rawValue }) => receiptEntries(generationReceipt(rawValue)).flatMap((value) => {
|
|
183194
183289
|
const prompt = typeof value.prompt === "string" ? value.prompt : typeof value.input?.prompt === "string" ? value.input.prompt : void 0;
|
|
183195
183290
|
if (!prompt || prompt.length > 8e3 || /(?:https?:\/\/|Bearer\s|api[_-]?key|access[_-]?token|client[_-]?secret|password|-----BEGIN)/i.test(prompt)) {
|
|
183196
183291
|
if (prompt) warnings.push(`Prompt omitted from ${path}: review it locally before saving.`);
|
|
183197
183292
|
return [];
|
|
183198
183293
|
}
|
|
183199
183294
|
return [{ source: path, prompt, model: typeof value.model === "string" ? value.model : void 0, status: "pilot_example_not_template" }];
|
|
183200
|
-
});
|
|
183295
|
+
})).slice(0, 100);
|
|
183296
|
+
while (Buffer.byteLength(stableJson({ schemaVersion: 1, id: id3, examples: promptExamples })) > 110 * 1024) {
|
|
183297
|
+
promptExamples.pop();
|
|
183298
|
+
if (!warnings.includes("Prompt example budget reached; remaining prompts need local review.")) warnings.push("Prompt example budget reached; remaining prompts need local review.");
|
|
183299
|
+
}
|
|
183201
183300
|
if (promptExamples.length) files[`${base}/media-examples.json`] = stableJson({ schemaVersion: 1, id: id3, examples: promptExamples });
|
|
183202
183301
|
files[`${base}/media-style.json`] = stableJson({ schemaVersion: 1, id: id3, status: "draft", referenceOrder: [], promptTemplate: "{personajes}. {escena}. Paleta: {paleta}.", variables: ["personajes", "escena", "paleta"], reviewBeforeAnimation: [] });
|
|
183203
|
-
for (const name2 of ["captions.json", "media-style.json"]) try {
|
|
183204
|
-
const parsed = JSON.parse(await
|
|
183302
|
+
for (const name2 of ["captions.json", "media-style.json"]) for (const directory of roots) try {
|
|
183303
|
+
const parsed = JSON.parse((await readReviewFile(await checkedPath(root, `${directory}/${name2}`, false), 128 * 1024)).toString());
|
|
183205
183304
|
parsed.id = id3;
|
|
183206
183305
|
const content = stableJson(parsed), validation = validateDocument(`${base}/${name2}`, content);
|
|
183207
|
-
if (validation.valid)
|
|
183208
|
-
|
|
183306
|
+
if (validation.valid) {
|
|
183307
|
+
files[`${base}/${name2}`] = content;
|
|
183308
|
+
break;
|
|
183309
|
+
} else warnings.push(`Invalid ${name2} in pilot; not copied. Complete its typed contract.`);
|
|
183209
183310
|
} catch (error) {
|
|
183210
183311
|
if (error.code !== "ENOENT") warnings.push(`Could not capture ${name2}; complete it explicitly.`);
|
|
183211
183312
|
}
|
|
@@ -183214,6 +183315,7 @@ ${content}`;
|
|
|
183214
183315
|
|
|
183215
183316
|
Read pilot-direction.md and pilot-review.md when present. Complete: what to preserve; what to adapt; when not to use; verification for each technique. Confirm candidate resources; hashes prove bytes, not whether the scene uses them. Receipts are recorded by hash without copying provider secrets or temporary URLs.
|
|
183216
183317
|
`;
|
|
183318
|
+
if (!resources.length) warnings.push(`No resources captured in ${scannedRoots.join(", ")}. Inspect project paths or declare resources explicitly; this is not a complete saved style.`);
|
|
183217
183319
|
warnings.push("Resources are candidates, not a certified dependency graph. Dynamic JS imports/URLs need explicit review. Media recipe is a draft; no model, timing or human approval inferred.");
|
|
183218
183320
|
for (const [path, content] of Object.entries(files)) {
|
|
183219
183321
|
const result2 = validateDocument(path, content);
|
|
@@ -183224,13 +183326,13 @@ Read pilot-direction.md and pilot-review.md when present. Complete: what to pres
|
|
|
183224
183326
|
|
|
183225
183327
|
// packages/cli/src/style-authoring.ts
|
|
183226
183328
|
import { createHash as createHash2 } from "node:crypto";
|
|
183227
|
-
import { constants as
|
|
183228
|
-
import { lstat as
|
|
183329
|
+
import { constants as constants5 } from "node:fs";
|
|
183330
|
+
import { lstat as lstat4, mkdir as mkdir2, open as open5, readdir as readdir3, rmdir, unlink as unlink3 } from "node:fs/promises";
|
|
183229
183331
|
import { dirname as dirname2 } from "node:path";
|
|
183230
183332
|
|
|
183231
183333
|
// packages/cli/src/workspace-lock.ts
|
|
183232
|
-
import { constants as
|
|
183233
|
-
import { lstat as
|
|
183334
|
+
import { constants as constants4 } from "node:fs";
|
|
183335
|
+
import { lstat as lstat3, open as open4, rename as rename2, unlink as unlink2 } from "node:fs/promises";
|
|
183234
183336
|
import { hostname } from "node:os";
|
|
183235
183337
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
183236
183338
|
var LOCK_PATH = ".editorbrain-operation.lock";
|
|
@@ -183238,7 +183340,7 @@ async function withWorkspaceLock(root, operation, options = {}) {
|
|
|
183238
183340
|
const legacyLock = await checkedPath(root, ".editorharness-operation.lock", false);
|
|
183239
183341
|
let legacy;
|
|
183240
183342
|
try {
|
|
183241
|
-
legacy = await
|
|
183343
|
+
legacy = await open4(legacyLock, constants4.O_CREAT | constants4.O_EXCL | constants4.O_WRONLY | constants4.O_NOFOLLOW, 384);
|
|
183242
183344
|
} catch (error) {
|
|
183243
183345
|
if (error.code === "EEXIST") throw new CliError("WORKSPACE_BUSY", "Another CLI operation holds this workspace lock.", "Wait for the other operation to finish.");
|
|
183244
183346
|
throw error;
|
|
@@ -183247,7 +183349,7 @@ async function withWorkspaceLock(root, operation, options = {}) {
|
|
|
183247
183349
|
const path = await checkedPath(root, LOCK_PATH, false);
|
|
183248
183350
|
let handle;
|
|
183249
183351
|
try {
|
|
183250
|
-
handle = await
|
|
183352
|
+
handle = await open4(path, constants4.O_CREAT | constants4.O_EXCL | constants4.O_WRONLY | constants4.O_NOFOLLOW, 384);
|
|
183251
183353
|
} catch (error) {
|
|
183252
183354
|
if (error.code !== "EEXIST") throw error;
|
|
183253
183355
|
throw new CliError("WORKSPACE_BUSY", "Another CLI operation holds this workspace lock.", "Wait for the other operation. If it crashed, verify no process is using the folder before removing .editorbrain-operation.lock. Locks are never removed automatically.");
|
|
@@ -183258,7 +183360,7 @@ async function withWorkspaceLock(root, operation, options = {}) {
|
|
|
183258
183360
|
await handle.close();
|
|
183259
183361
|
const oldRoot = await checkedPath(root, ".editorharness", false);
|
|
183260
183362
|
const newRoot = await checkedPath(root, ".editorbrain", false);
|
|
183261
|
-
const exists3 = async (path2) =>
|
|
183363
|
+
const exists3 = async (path2) => lstat3(path2).then(() => true, (error) => {
|
|
183262
183364
|
if (error.code === "ENOENT") return false;
|
|
183263
183365
|
throw error;
|
|
183264
183366
|
});
|
|
@@ -183288,7 +183390,7 @@ function styleId(id3) {
|
|
|
183288
183390
|
}
|
|
183289
183391
|
async function exists(path) {
|
|
183290
183392
|
try {
|
|
183291
|
-
await
|
|
183393
|
+
await lstat4(path);
|
|
183292
183394
|
return true;
|
|
183293
183395
|
} catch (error) {
|
|
183294
183396
|
if (error.code === "ENOENT") return false;
|
|
@@ -183318,11 +183420,11 @@ async function makeDirectories(root, path, created) {
|
|
|
183318
183420
|
const target = await checkedPath(root, relative2, false);
|
|
183319
183421
|
try {
|
|
183320
183422
|
await mkdir2(target);
|
|
183321
|
-
const info = await
|
|
183423
|
+
const info = await lstat4(target);
|
|
183322
183424
|
created.push({ path: relative2, dev: info.dev, ino: info.ino });
|
|
183323
183425
|
} catch (error) {
|
|
183324
183426
|
if (error.code !== "EEXIST") throw error;
|
|
183325
|
-
if (!(await
|
|
183427
|
+
if (!(await lstat4(await checkedPath(root, relative2, false))).isDirectory()) throw new Error(`Not a directory: ${relative2}`);
|
|
183326
183428
|
}
|
|
183327
183429
|
}
|
|
183328
183430
|
}
|
|
@@ -183330,7 +183432,7 @@ async function cleanCreated(root, paths2, directory) {
|
|
|
183330
183432
|
for (const item of [...paths2].reverse()) {
|
|
183331
183433
|
try {
|
|
183332
183434
|
const target = await checkedPath(root, item.path, false);
|
|
183333
|
-
const info = await
|
|
183435
|
+
const info = await lstat4(target);
|
|
183334
183436
|
if (info.dev !== item.dev || info.ino !== item.ino || info.isSymbolicLink()) continue;
|
|
183335
183437
|
if (directory) await rmdir(target);
|
|
183336
183438
|
else await unlink3(target);
|
|
@@ -183355,7 +183457,7 @@ async function createLocalStyle(options) {
|
|
|
183355
183457
|
for (const [path, content] of Object.entries(files)) {
|
|
183356
183458
|
await makeDirectories(root, dirname2(path), createdDirectories);
|
|
183357
183459
|
const target = await checkedPath(root, path);
|
|
183358
|
-
const handle = await
|
|
183460
|
+
const handle = await open5(target, constants5.O_WRONLY | constants5.O_CREAT | constants5.O_EXCL | constants5.O_NOFOLLOW, 420);
|
|
183359
183461
|
try {
|
|
183360
183462
|
const info = await handle.stat();
|
|
183361
183463
|
createdFiles.push({ path, dev: info.dev, ino: info.ino });
|
|
@@ -183389,7 +183491,7 @@ async function readStyle(root, id3) {
|
|
|
183389
183491
|
try {
|
|
183390
183492
|
const target = await checkedPath(root, path, false);
|
|
183391
183493
|
if (!await exists(target)) continue;
|
|
183392
|
-
if (!(await
|
|
183494
|
+
if (!(await lstat4(target)).isDirectory()) {
|
|
183393
183495
|
issues.push({ path, message: "Style path is not a directory." });
|
|
183394
183496
|
continue;
|
|
183395
183497
|
}
|
|
@@ -183418,7 +183520,7 @@ async function readStyle(root, id3) {
|
|
|
183418
183520
|
async function checkLocalResource(root, path, expected) {
|
|
183419
183521
|
safeStyleResourcePath(path);
|
|
183420
183522
|
const target = await checkedPath(root, path, false);
|
|
183421
|
-
const handle = await
|
|
183523
|
+
const handle = await open5(target, constants5.O_RDONLY | constants5.O_NOFOLLOW | constants5.O_NONBLOCK);
|
|
183422
183524
|
try {
|
|
183423
183525
|
const before = await handle.stat();
|
|
183424
183526
|
if (!before.isFile()) throw new Error("Resource is not a regular file.");
|
|
@@ -183426,7 +183528,7 @@ async function checkLocalResource(root, path, expected) {
|
|
|
183426
183528
|
const hash8 = createHash2("sha256");
|
|
183427
183529
|
for await (const chunk of handle.createReadStream({ autoClose: false })) hash8.update(chunk);
|
|
183428
183530
|
const after = await handle.stat();
|
|
183429
|
-
const current2 = await
|
|
183531
|
+
const current2 = await lstat4(await checkedPath(root, path, false));
|
|
183430
183532
|
if (before.size !== after.size || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs || current2.dev !== before.dev || current2.ino !== before.ino) {
|
|
183431
183533
|
throw new Error("Resource changed while its hash was being checked; check it again.");
|
|
183432
183534
|
}
|
|
@@ -183549,7 +183651,7 @@ async function boundedStyleDownload(response) {
|
|
|
183549
183651
|
async function requireCurrentLayout(root) {
|
|
183550
183652
|
let legacy = false;
|
|
183551
183653
|
try {
|
|
183552
|
-
await
|
|
183654
|
+
await lstat5(await checkedPath(root, ".editorharness", false));
|
|
183553
183655
|
legacy = true;
|
|
183554
183656
|
} catch (error) {
|
|
183555
183657
|
if (error.code !== "ENOENT") throw error;
|
|
@@ -183563,7 +183665,8 @@ async function pushStyle(client, directory, id3, options = {}) {
|
|
|
183563
183665
|
await requireCurrentLayout(root);
|
|
183564
183666
|
const me = await client.me();
|
|
183565
183667
|
await loadSyncState(root, client.url, me.workspaceId);
|
|
183566
|
-
const access = await client.request("/v1/team
|
|
183668
|
+
const access = await client.request("/v1/team");
|
|
183669
|
+
if (typeof access.restricted !== "boolean") throw new CliError("INVALID_RESPONSE", "Team permissions are missing.", "Check the API endpoint; no style resources were uploaded.");
|
|
183567
183670
|
if (access.restricted) throw new CliError("TEAM_SCOPE_DENIED", "Shared styles are managed by the workspace owner.", "Ask the owner to save this style; do not upload its files with another identity.");
|
|
183568
183671
|
const check = await checkLocalStyle({ directory: root, id: id3 });
|
|
183569
183672
|
if (!check.valid) throw new CliError("INVALID_STYLE", "Style validation failed.", "Run styles check and correct the reported files.", false, { issues: check.issues });
|
|
@@ -183668,7 +183771,7 @@ async function pullStyle(client, directory, id3, options = {}) {
|
|
|
183668
183771
|
|
|
183669
183772
|
// packages/cli/src/style-operations.ts
|
|
183670
183773
|
import { createHash as createHash4 } from "node:crypto";
|
|
183671
|
-
import { unlink as unlink4 } from "node:fs/promises";
|
|
183774
|
+
import { unlink as unlink4, lstat as lstat6, readdir as readdir4 } from "node:fs/promises";
|
|
183672
183775
|
import { posix as posix4 } from "node:path";
|
|
183673
183776
|
var hash4 = (bytes) => createHash4("sha256").update(bytes).digest("hex");
|
|
183674
183777
|
var readJson = async (root, path) => JSON.parse((await readReviewFile(await checkedPath(root, path, false), 1024 * 1024)).toString("utf8"));
|
|
@@ -183701,7 +183804,7 @@ function bindingSpans(code, bindings) {
|
|
|
183701
183804
|
let index = 0, count = 0;
|
|
183702
183805
|
while ((index = code.indexOf(literal, index)) !== -1) {
|
|
183703
183806
|
if (b.type === "string" || !/[\w.$-]/.test(code[index - 1] ?? "") && !/[\w.]/.test(code[index + literal.length] ?? "")) {
|
|
183704
|
-
if (!scripts.some((s) => index >= s.start && index + literal.length <= s.end)) throw new Error(
|
|
183807
|
+
if (!scripts.some((s) => index >= s.start && index + literal.length <= s.end)) throw new Error(`Binding ${b.name}: must target JSON literals inside script blocks, never HTML attributes or markup.`);
|
|
183705
183808
|
spans.push({ start: index, end: index + literal.length, binding: b });
|
|
183706
183809
|
count++;
|
|
183707
183810
|
}
|
|
@@ -183710,12 +183813,16 @@ function bindingSpans(code, bindings) {
|
|
|
183710
183813
|
if (count !== b.occurrences) throw new Error(`Binding ${b.name}: expected ${b.occurrences} exact JSON literal occurrences; found ${count}. Use a dedicated configuration object in the scene.`);
|
|
183711
183814
|
}
|
|
183712
183815
|
spans.sort((a, b) => a.start - b.start);
|
|
183713
|
-
for (let i = 1; i < spans.length; i++) if (spans[i].start < spans[i - 1].end) throw new Error(
|
|
183816
|
+
for (let i = 1; i < spans.length; i++) if (spans[i].start < spans[i - 1].end) throw new Error(`Overlapping bindings ${spans[i - 1].binding.name} and ${spans[i].binding.name}; use distinct configuration literals.`);
|
|
183714
183817
|
return spans;
|
|
183715
183818
|
}
|
|
183716
183819
|
async function extractComponent(directory, id3, componentId, scene, bindingsFile) {
|
|
183717
183820
|
assertIdentifier(componentId);
|
|
183718
|
-
|
|
183821
|
+
try {
|
|
183822
|
+
safeStyleResourcePath(scene);
|
|
183823
|
+
} catch (error) {
|
|
183824
|
+
throw new Error(`Scene ${JSON.stringify(scene)}: ${error.message}. Copy the input inside ${JSON.stringify(directory)} and pass its workspace-relative path.`);
|
|
183825
|
+
}
|
|
183719
183826
|
if (!/\.html$/.test(scene)) throw new Error("Scene must be a local HTML file.");
|
|
183720
183827
|
const root = await ensureRoot(directory);
|
|
183721
183828
|
return withWorkspaceLock(root, async () => {
|
|
@@ -183793,7 +183900,7 @@ async function prepareComponent(directory, id3, componentId, parameters, out) {
|
|
|
183793
183900
|
const bytes = await readReviewFile(await checkedPath(root, path, false), 2 * 1024 * 1024);
|
|
183794
183901
|
if (hash4(bytes) !== expected) throw new Error("Component source SHA-256 mismatch.");
|
|
183795
183902
|
const code = bytes.toString(), values = await readJson(root, parameters);
|
|
183796
|
-
if (!values || Array.isArray(values) || typeof values !== "object" || Object.keys(values).some((k) => !c.bindings.some((b) => b.name === k))) throw new Error(
|
|
183903
|
+
if (!values || Array.isArray(values) || typeof values !== "object" || Object.keys(values).some((k) => !c.bindings.some((b) => b.name === k))) throw new Error(`Parameter object contains unknown bindings: ${values && typeof values === "object" ? Object.keys(values).filter((k) => !c.bindings.some((b) => b.name === k)).join(", ") : "expected an object"}. Expected: ${c.bindings.map((b) => b.name).join(", ")}.`);
|
|
183797
183904
|
for (const b of c.bindings) {
|
|
183798
183905
|
if (!Object.hasOwn(values, b.name) || typeof values[b.name] !== b.type || b.type === "number" && !Number.isFinite(values[b.name]) || b.type === "string" && values[b.name].length > 8e3) throw new Error(`Parameter ${b.name} must be ${b.type}.`);
|
|
183799
183906
|
if (b.role === "clip") {
|
|
@@ -183802,6 +183909,26 @@ async function prepareComponent(directory, id3, componentId, parameters, out) {
|
|
|
183802
183909
|
values[b.name] = posix4.relative(posix4.dirname(out), values[b.name]);
|
|
183803
183910
|
}
|
|
183804
183911
|
}
|
|
183912
|
+
for (const b of c.bindings) if (b.role === "directory") {
|
|
183913
|
+
const directory2 = values[b.name].replace(/\/$/, "");
|
|
183914
|
+
safeStyleResourcePath(directory2);
|
|
183915
|
+
let entries = 0;
|
|
183916
|
+
async function inspect(path2, depth = 0) {
|
|
183917
|
+
if (depth > 4) throw new Error(`Binding ${b.name}: directory exceeds depth 4.`);
|
|
183918
|
+
const absolute = await checkedPath(root, path2, false), info = await lstat6(absolute);
|
|
183919
|
+
if (!info.isDirectory()) throw new Error(`Binding ${b.name}: expected a directory at ${path2}.`);
|
|
183920
|
+
for (const item of await readdir4(absolute, { withFileTypes: true })) {
|
|
183921
|
+
if (++entries > 500) throw new Error(`Binding ${b.name}: directory exceeds 500 entries.`);
|
|
183922
|
+
const child = posix4.join(path2, item.name);
|
|
183923
|
+
safeStyleResourcePath(child);
|
|
183924
|
+
await checkedPath(root, child, false);
|
|
183925
|
+
if (item.isDirectory()) await inspect(child, depth + 1);
|
|
183926
|
+
else if (!item.isFile()) throw new Error(`Binding ${b.name}: directory contains a nonregular file: ${child}.`);
|
|
183927
|
+
}
|
|
183928
|
+
}
|
|
183929
|
+
await inspect(directory2);
|
|
183930
|
+
values[b.name] = (posix4.relative(posix4.dirname(out), directory2) || ".") + (String(b.literal).endsWith("/") ? "/" : "");
|
|
183931
|
+
}
|
|
183805
183932
|
const spans = bindingSpans(code, c.bindings);
|
|
183806
183933
|
let prepared = "", cursor = 0;
|
|
183807
183934
|
for (const span of spans) {
|
|
@@ -183844,9 +183971,11 @@ async function testStyleTransfer(directory, id3, projectId) {
|
|
|
183844
183971
|
const validated = validateDocument(projectPath, raw);
|
|
183845
183972
|
if (!validated.valid) throw new Error(validated.issues.map((x) => x.message).join("\n"));
|
|
183846
183973
|
const project = JSON.parse(raw);
|
|
183847
|
-
let script = typeof project.script === "string" ? project.script : "";
|
|
183974
|
+
let script = typeof project.script === "string" ? project.script : "", scriptFile = projectPath, scriptField = "script";
|
|
183848
183975
|
if (!script.trim()) try {
|
|
183849
|
-
|
|
183976
|
+
scriptFile = `videos/${projectId}/script.md`;
|
|
183977
|
+
scriptField = void 0;
|
|
183978
|
+
script = await readText(root, scriptFile);
|
|
183850
183979
|
} catch (e) {
|
|
183851
183980
|
if (e.code !== "ENOENT") throw e;
|
|
183852
183981
|
}
|
|
@@ -183867,17 +183996,22 @@ async function testStyleTransfer(directory, id3, projectId) {
|
|
|
183867
183996
|
}
|
|
183868
183997
|
const unavailable = t.resourceIds.filter((rid) => !check.resources.some((r) => r.id === rid && ["verified", "present"].includes(r.status)));
|
|
183869
183998
|
const component = t.componentId ? registry.components.find((c) => c.id === t.componentId) : void 0;
|
|
183870
|
-
return { techniqueId: t.id, status: !script.trim() ? "missing_script" : !positions.length ? "anchor_not_found" : positions.length > 1 ? "ambiguous_anchor" : unavailable.length ? "missing_resources" : t.componentId && component?.status !== "parameterized" ? "component_not_ready" : "candidate", truncatedMatches: truncated, suggestedTextRanges: positions.map((start3) => ({ start: start3, end: start3 + t.anchor.text.length })), missingResources: unavailable, requiredParameters: component?.bindings.map((b) => ({ name: b.name, type: b.type, role: b.role })) ?? [], verify: t.verify, reviewConditions: { when: t.when, omitWhen: t.omitWhen, evaluated: false } };
|
|
183999
|
+
return { techniqueId: t.id, status: !script.trim() ? "missing_script" : !positions.length ? "anchor_not_found" : positions.length > 1 ? "ambiguous_anchor" : unavailable.length ? "missing_resources" : t.componentId && component?.status !== "parameterized" ? "component_not_ready" : "candidate", truncatedMatches: truncated, suggestedTextRanges: positions.map((start3) => ({ start: start3, end: start3 + t.anchor.text.length, text: script.slice(start3, start3 + t.anchor.text.length), context: script.slice(Math.max(0, start3 - 80), Math.min(script.length, start3 + t.anchor.text.length + 80)), file: scriptFile, ...scriptField ? { field: scriptField } : {}, line: script.slice(0, start3).split("\n").length })), missingResources: unavailable, requiredParameters: component?.bindings.map((b) => ({ name: b.name, type: b.type, role: b.role })) ?? [], verify: t.verify, reviewConditions: { when: t.when, omitWhen: t.omitWhen, evaluated: false } };
|
|
183871
184000
|
});
|
|
183872
|
-
return { id: id3, projectId, brandId: project.brand, mode: "local_dry_run", rendered: false, creditsUsed: 0, projectChanged: false, transferVerified: false, compatibility: { tokens: target.tokens, captions: target.styleProduction?.captions, audio: target.audioProduction, mediaSources: target.mediaPreferences.sources }, placements, resources: check.resources, issues: check.issues, warnings: [...check.warnings, ...target.warnings, ...!techniques.techniques.length ? ["No structured techniques yet. Add techniques.json to obtain scene suggestions."] : [], "Text ranges are not timestamps. Agent must evaluate semantic fit, brand rules, caption/audio preferences and omit conditions before editing."] };
|
|
184001
|
+
return { id: id3, projectId, brandId: project.brand, mode: "local_dry_run", rendered: false, creditsUsed: 0, projectChanged: false, transferVerified: false, scriptSource: { file: scriptFile, ...scriptField ? { field: scriptField } : {}, offsetUnit: "utf16_code_units", lineBasis: "decoded_script" }, compatibility: { tokens: target.tokens, captions: target.styleProduction?.captions, audio: target.audioProduction, mediaSources: target.mediaPreferences.sources }, placements, resources: check.resources, issues: check.issues, warnings: [...check.warnings, ...target.warnings, ...!techniques.techniques.length ? ["No structured techniques yet. Add techniques.json to obtain scene suggestions."] : [], "Text ranges are not timestamps. Agent must evaluate semantic fit, brand rules, caption/audio preferences and omit conditions before editing."] };
|
|
183873
184002
|
}
|
|
183874
|
-
async function prepareCaptions(directory, projectId, file, out) {
|
|
184003
|
+
async function prepareCaptions(directory, projectId, file, out, styleId2) {
|
|
183875
184004
|
const root = await ensureRoot(directory);
|
|
183876
184005
|
assertIdentifier(projectId);
|
|
183877
184006
|
safeStyleResourcePath(out);
|
|
183878
184007
|
if (!out.endsWith(".html")) throw new Error("--out must be a new HTML file.");
|
|
183879
|
-
|
|
183880
|
-
if (
|
|
184008
|
+
let files = await readProjectWorkspace(root, projectId);
|
|
184009
|
+
if (styleId2) {
|
|
184010
|
+
const candidate = await localStyle(root, styleId2), path = `videos/${projectId}/project.json`;
|
|
184011
|
+
files = { ...files, ...candidate.files, [path]: stableJson({ ...JSON.parse(files[path]), style: styleId2 }) };
|
|
184012
|
+
}
|
|
184013
|
+
const resolved = await resolveProject(files, projectId), preset = resolved.styleProduction?.captions;
|
|
184014
|
+
if (!preset) throw new Error(`Style ${resolved.project.style} has no captions.json preset.`);
|
|
183881
184015
|
const cues = validateCaptionCues(await readJson(root, file));
|
|
183882
184016
|
let fontDataUrl;
|
|
183883
184017
|
if (preset.enabled && preset.font.resourceId) {
|
|
@@ -183893,16 +184027,16 @@ async function prepareCaptions(directory, projectId, file, out) {
|
|
|
183893
184027
|
fontDataUrl = `data:font/${ext};base64,${bytes.toString("base64")}`;
|
|
183894
184028
|
}
|
|
183895
184029
|
await atomicWrite(root, out, captionLayer(preset, cues, resolved.output.width, resolved.output.height, fontDataUrl), { document: false, overwrite: false });
|
|
183896
|
-
return { projectId, out, enabled: preset.enabled, rendered: false, warnings: resolved.warnings, next: "Load the transparent HTML at output resolution, install the declared font and await renderAt(seconds) for each frame. Cue.crossing and forbiddenZones must be supplied from the actual scene; no face detection is implied." };
|
|
184030
|
+
return { projectId, styleId: resolved.project.style, projectChanged: false, out, enabled: preset.enabled, rendered: false, warnings: resolved.warnings, next: "Load the transparent HTML at output resolution, install the declared font and await renderAt(seconds) for each frame. Cue.crossing and forbiddenZones must be supplied from the actual scene; no face detection is implied." };
|
|
183897
184031
|
}
|
|
183898
184032
|
|
|
183899
184033
|
// packages/cli/src/style-sources.ts
|
|
183900
|
-
import { constants as
|
|
183901
|
-
import { open as
|
|
184034
|
+
import { constants as constants6 } from "node:fs";
|
|
184035
|
+
import { open as open7, mkdir as mkdir4, writeFile, rm } from "node:fs/promises";
|
|
183902
184036
|
import { dirname as dirname4 } from "node:path";
|
|
183903
184037
|
|
|
183904
184038
|
// packages/cli/src/authored-motion.ts
|
|
183905
|
-
import { lstat as
|
|
184039
|
+
import { lstat as lstat7, mkdir as mkdir3, open as open6, link as link2, unlink as unlink5 } from "node:fs/promises";
|
|
183906
184040
|
import { dirname as dirname3, join as join2 } from "node:path";
|
|
183907
184041
|
import { createHash as createHash5, randomUUID as randomUUID3 } from "node:crypto";
|
|
183908
184042
|
async function downloadAuthoredSource(client, pin, root, out, fetcher = fetch) {
|
|
@@ -183914,7 +184048,7 @@ async function downloadPinnedSource(client, pin, root, out, kind2, fetcher = fet
|
|
|
183914
184048
|
if (!/^[a-z0-9][a-z0-9-]{0,79}$/.test(pin.id) || !/^\d+\.\d+\.\d+$/.test(pin.version) || !/^[a-f0-9]{64}$/.test(pin.sha256) || !Number.isSafeInteger(pin.bytes) || pin.bytes < 1 || pin.bytes > (kind2 === "style" ? 128 : pin.version === "1.4.0" ? 96 : 16) * 1024 * 1024) throw new CliError("INVALID_ARGUMENT", "Invalid pinned source bundle.", "Retrieve one authored scene from the catalog.");
|
|
183915
184049
|
const target = await checkedPath(root, out, false);
|
|
183916
184050
|
try {
|
|
183917
|
-
await
|
|
184051
|
+
await lstat7(target);
|
|
183918
184052
|
throw new CliError("FILE_EXISTS", "The output already exists.", "Choose a new archive path.");
|
|
183919
184053
|
} catch (error) {
|
|
183920
184054
|
if (error.code !== "ENOENT") throw error;
|
|
@@ -183940,7 +184074,7 @@ async function downloadPinnedSource(client, pin, root, out, kind2, fetcher = fet
|
|
|
183940
184074
|
try {
|
|
183941
184075
|
await mkdir3(dirname3(target), { recursive: true });
|
|
183942
184076
|
await checkedPath(root, out, false);
|
|
183943
|
-
handle = await
|
|
184077
|
+
handle = await open6(temporary, "wx", 384);
|
|
183944
184078
|
for (; ; ) {
|
|
183945
184079
|
const { done, value } = await reader.read();
|
|
183946
184080
|
if (done) break;
|
|
@@ -185057,7 +185191,7 @@ async function downloadStyle(client, id3, version, root, out) {
|
|
|
185057
185191
|
async function prepareStyleSource(root, id3, version, file, out) {
|
|
185058
185192
|
const selected = getStyleSource(id3, version), guard = styleSourceGuards[id3];
|
|
185059
185193
|
if (!selected || !guard) throw new Error("This CLI cannot prepare the exact style version. Update EditorBrain; no version was substituted.");
|
|
185060
|
-
const input = await checkedPath(root, file, false), handle = await
|
|
185194
|
+
const input = await checkedPath(root, file, false), handle = await open7(input, constants6.O_RDONLY | constants6.O_NOFOLLOW);
|
|
185061
185195
|
let bytes;
|
|
185062
185196
|
try {
|
|
185063
185197
|
const stat = await handle.stat();
|
|
@@ -185224,8 +185358,8 @@ import { randomUUID as randomUUID4 } from "node:crypto";
|
|
|
185224
185358
|
// packages/cli/src/media-runtime.ts
|
|
185225
185359
|
import { spawn } from "node:child_process";
|
|
185226
185360
|
import { createHash as createHash7 } from "node:crypto";
|
|
185227
|
-
import { constants as
|
|
185228
|
-
import { lstat as
|
|
185361
|
+
import { constants as constants7 } from "node:fs";
|
|
185362
|
+
import { lstat as lstat8, open as open8, realpath as realpath2 } from "node:fs/promises";
|
|
185229
185363
|
import { dirname as dirname5, extname, parse, resolve as resolve2 } from "node:path";
|
|
185230
185364
|
var MediaToolError = class extends CliError {
|
|
185231
185365
|
constructor(code, message) {
|
|
@@ -185284,7 +185418,7 @@ async function assertNoMediaSymlinks(value) {
|
|
|
185284
185418
|
const path = resolveLocalMediaPath(value);
|
|
185285
185419
|
let cursor = path;
|
|
185286
185420
|
while (cursor !== parse(cursor).root) {
|
|
185287
|
-
const info = await
|
|
185421
|
+
const info = await lstat8(cursor);
|
|
185288
185422
|
if (info.isSymbolicLink()) {
|
|
185289
185423
|
const systemAlias = process.platform === "darwin" && (cursor === "/tmp" || cursor === "/var") && await realpath2(cursor) === `/private${cursor}`;
|
|
185290
185424
|
if (!systemAlias) throw new MediaToolError("MEDIA_SYMLINK", "Symlink media paths are not followed. Use the original local path.");
|
|
@@ -185295,7 +185429,7 @@ async function assertNoMediaSymlinks(value) {
|
|
|
185295
185429
|
}
|
|
185296
185430
|
async function assertLocalMediaFile(value) {
|
|
185297
185431
|
const path = await assertNoMediaSymlinks(value);
|
|
185298
|
-
const info = await
|
|
185432
|
+
const info = await lstat8(path);
|
|
185299
185433
|
if (!info.isFile()) throw new MediaToolError("MEDIA_NOT_REGULAR", "The media input must be a regular local file.");
|
|
185300
185434
|
if (!SUPPORTED_MEDIA_EXTENSIONS.has(extname(path).toLowerCase())) throw new MediaToolError("MEDIA_FORMAT_UNSUPPORTED", "This file extension is not supported for local media inspection.");
|
|
185301
185435
|
return path;
|
|
@@ -185394,7 +185528,7 @@ function hasDisplayTransform(stream) {
|
|
|
185394
185528
|
}
|
|
185395
185529
|
async function probeLocalMedia(value) {
|
|
185396
185530
|
const path = await assertLocalMediaFile(value);
|
|
185397
|
-
const handle = await
|
|
185531
|
+
const handle = await open8(path, constants7.O_RDONLY | (constants7.O_NOFOLLOW ?? 0));
|
|
185398
185532
|
try {
|
|
185399
185533
|
const before = await handle.stat();
|
|
185400
185534
|
if (!before.isFile()) throw new MediaToolError("MEDIA_NOT_REGULAR", "The media input must be a regular local file.");
|
|
@@ -185404,7 +185538,7 @@ async function probeLocalMedia(value) {
|
|
|
185404
185538
|
for await (const chunk of handle.createReadStream({ autoClose: false })) hash8.update(chunk);
|
|
185405
185539
|
const after = await handle.stat();
|
|
185406
185540
|
await assertNoMediaSymlinks(path);
|
|
185407
|
-
const current2 = await
|
|
185541
|
+
const current2 = await lstat8(path);
|
|
185408
185542
|
if (!sameFile(before, after) || !sameFile(after, current2)) throw new MediaToolError("MEDIA_FILE_CHANGED", "The media file changed while it was being inspected. Retry with a stable source.");
|
|
185409
185543
|
let raw;
|
|
185410
185544
|
try {
|
|
@@ -185433,8 +185567,8 @@ async function probeLocalMedia(value) {
|
|
|
185433
185567
|
}
|
|
185434
185568
|
|
|
185435
185569
|
// packages/cli/src/production-output.ts
|
|
185436
|
-
import { constants as
|
|
185437
|
-
import { mkdir as mkdir5, open as
|
|
185570
|
+
import { constants as constants8 } from "node:fs";
|
|
185571
|
+
import { mkdir as mkdir5, open as open9 } from "node:fs/promises";
|
|
185438
185572
|
import { dirname as dirname6 } from "node:path";
|
|
185439
185573
|
async function productionOutputPath(root, relativePath) {
|
|
185440
185574
|
if (!relativePath.startsWith(".editorbrain-local/") || relativePath.split(/[\\/]/).some((p) => !p || p === ".." || p === ".") || /[\\\x00-\x1f\x7f]/.test(relativePath)) {
|
|
@@ -185450,7 +185584,7 @@ async function prepareSampleDirectory(root, path) {
|
|
|
185450
185584
|
}
|
|
185451
185585
|
async function readProductionJson(root, path) {
|
|
185452
185586
|
const target = await checkedPath(root, path, false);
|
|
185453
|
-
const handle = await
|
|
185587
|
+
const handle = await open9(target, constants8.O_RDONLY | constants8.O_NOFOLLOW | constants8.O_NONBLOCK);
|
|
185454
185588
|
try {
|
|
185455
185589
|
const stat = await handle.stat();
|
|
185456
185590
|
if (!stat.isFile() || stat.size > 16 * 1024 * 1024) throw new CliError("INVALID_REPORT", "Expected a regular JSON file of at most 16 MiB.", "Select a local inventory, plan or check profile.");
|
|
@@ -185679,19 +185813,65 @@ async function personalResourceCommand(client, root, command, arg, flags) {
|
|
|
185679
185813
|
|
|
185680
185814
|
// packages/cli/src/update.ts
|
|
185681
185815
|
import { execFile } from "node:child_process";
|
|
185682
|
-
import { lstat as
|
|
185816
|
+
import { lstat as lstat11, readFile as readFile3, realpath as realpath3 } from "node:fs/promises";
|
|
185683
185817
|
import { homedir as homedir2 } from "node:os";
|
|
185684
185818
|
import { delimiter, dirname as dirname7, join as join5, resolve as resolve5 } from "node:path";
|
|
185685
185819
|
import { promisify } from "node:util";
|
|
185686
185820
|
|
|
185687
185821
|
// packages/cli/src/agent-guidance.ts
|
|
185688
185822
|
import { createHash as createHash8 } from "node:crypto";
|
|
185689
|
-
import { constants as
|
|
185690
|
-
import { lstat as
|
|
185823
|
+
import { constants as constants9 } from "node:fs";
|
|
185824
|
+
import { lstat as lstat9, open as open10, readdir as readdir5, rename as rename3 } from "node:fs/promises";
|
|
185691
185825
|
import { fileURLToPath } from "node:url";
|
|
185692
185826
|
|
|
185693
185827
|
// packages/cli/src/agent-guidance-history.ts
|
|
185694
185828
|
var VERIFIED_GUIDANCE_RELEASES = [
|
|
185829
|
+
{
|
|
185830
|
+
"version": "0.42.0",
|
|
185831
|
+
"archiveSha256": "ecd32addc5532a06e23730f2b861ba43c06e006c38250da11ace63c5aa67e7a1",
|
|
185832
|
+
"files": {
|
|
185833
|
+
"editorbrain/AGENTS.md": "b240449d452c824415062a2b422bf55a5ae2d868a81083989d10ffaeb5c33a3f",
|
|
185834
|
+
"editorbrain-formats/references/aspirational-list-demo.md": "e884ce44d15f4496812ed18120f7d4c49c4261e148fcefe05c77c110b589771c",
|
|
185835
|
+
"editorbrain/references/audio-production.md": "9800505dcb320b58f35aeaed77303039d8fffb2c29b46c43cedeeba8637d2482",
|
|
185836
|
+
"editorbrain-motion/references/authored-scenes.md": "52e97b89b1d8a288c4ce7bd133eafea84e934ef2bf03ffe2dcef8c368b6f977d",
|
|
185837
|
+
"editorbrain/references/cli-mcp.md": "2c34ed7f896865e71959562bcc61b5a34292d6a9a4c14690f0c28d00875da75c",
|
|
185838
|
+
"editorbrain-motion/references/code-motion.md": "50382a797adc1e1596086e2408e81ee75ceb6730ca409be9c884646db643a7cd",
|
|
185839
|
+
"editorbrain-motion/references/component-library.md": "e88ed19d2ab9dca8d2ea02abe6c476021c03b9679bce99292cf7da52d65d2236",
|
|
185840
|
+
"editorbrain-formats/references/cumulative-tier-list.md": "7b7e8208687c6b925443e55d640ced6c1d09824377884244a09d7f3089d60aa5",
|
|
185841
|
+
"editorbrain/references/editorial-evidence.md": "79ed5bd90eb903014313c32a1e337822c5cb454e642bcfa852dcb77d30a9392e",
|
|
185842
|
+
"editorbrain/references/editorial-families.md": "b802ec6f02fd079e99df84d69a3c515d63ad058960b568c0c7b7dec1912495dd",
|
|
185843
|
+
"editorbrain/references/family-animated.md": "54a140d0a64b01147c52ea8cbaab4e4599bfe1af330f5a3ad6ef2a30351ab47d",
|
|
185844
|
+
"editorbrain/references/family-demonstration.md": "737334a8d9230682cde3a6ed11bfc02c4f9795c8f25a3b668be9d7393ec3e53d",
|
|
185845
|
+
"editorbrain/references/family-essay.md": "003f2cd450f33ba6641a9b1114cbc578c04cbb658b992c89c765d43198d1b4c2",
|
|
185846
|
+
"editorbrain/references/family-personal.md": "e93c304d7bc7d3eb31a3c9cb3be83f4f48d41319c2ac2e1e6f53f38576f5e644",
|
|
185847
|
+
"editorbrain/references/family-presenter.md": "76b8140b924930b306ce97772d6a7b683870bd14f19772b5339a490752b7de24",
|
|
185848
|
+
"editorbrain/references/first-edit.md": "483843af6672b70a76ce6d41e98324fbfc2a31d5ac50633f963d1ab0eeba1bc0",
|
|
185849
|
+
"editorbrain-motion/references/generated-motion.md": "a8d214b53c15f742658abd84f03b768fa2821f8cde94f50aab82a3759a30b36b",
|
|
185850
|
+
"editorbrain/references/integrations.md": "b5e7ba099acd79053cdd09822092eb121add6de39eada2d6911ad5a4f452ce2a",
|
|
185851
|
+
"editorbrain/references/local-production.md": "268a05706a3c1cae4f61248437c00be3e9ee18b2a0f747c8cd054d88f0a33661",
|
|
185852
|
+
"editorbrain/references/media-preferences.md": "87e508a75cdb6f4644db767273bfb230fb79f182ed05ee0f6257c6c05ea4dc7a",
|
|
185853
|
+
"editorbrain/references/memory-and-review.md": "406589a18e9e86ad8ce7d71e0f5bf00f67dab42c05af7721482fdca1c25c7c1b",
|
|
185854
|
+
"editorbrain-motion/references/motion-craft.md": "dae520b0e641fc9c3bf937241936588a855bf3453358e239ccc3cc3a2bcf0825",
|
|
185855
|
+
"editorbrain/references/motion-review.md": "0fb09a2d61ecd13114ced5cca5daa4580a922cf7d7b3f8698077ceb0e96da6f0",
|
|
185856
|
+
"editorbrain-formats/references/numbered-tutorial.md": "95754ae7dbfaa678e11ddf1a2b84710dba83a16e2fa4055051bd4f5f4f868a5f",
|
|
185857
|
+
"editorbrain/references/onboarding.md": "b842dac368455b670543d9a0defdad91708c10788d1474ddfa6b31ca929e930b",
|
|
185858
|
+
"editorbrain/references/personal-resources.md": "92ce6f32191929bd946c97305452521f6048d6bb8ea371e9083536eff5ce9512",
|
|
185859
|
+
"editorbrain/references/production-and-review.md": "28a64ee6407a1de7dc204776c158408c11b3987020ad1bdd1b79fd19745fbffa",
|
|
185860
|
+
"editorbrain/references/production-continuity.md": "4b020f5bab47f6b5619387b623339602b87202fec03d85a7a26737209e0b5d4e",
|
|
185861
|
+
"editorbrain/references/real-media.md": "cfad1aa15198dfe5ecc1f1b67c96d43a7d2084e7f5119de93d1b360203694938",
|
|
185862
|
+
"editorbrain/references/search-brief.md": "1bd2514f961522675047910f001f33da035382e48e933bc5eadb9d7d01455a0d",
|
|
185863
|
+
"editorbrain/references/sfx-library.md": "d7ee0d2916559ce11a7fd244ccbcb98172413653c3fdbe0545e57b3eda543b16",
|
|
185864
|
+
"editorbrain-formats/SKILL.md": "65ea59aae091ca9618b5e479befe0c76edf174df7091ed74d4307485a2252fcd",
|
|
185865
|
+
"editorbrain-motion/SKILL.md": "57292f3a48cc8f1fc2d89f2cc054a3ceabeda9422958fa708f273c662867d5ae",
|
|
185866
|
+
"editorbrain/SKILL.md": "028e66a96eb6fd2382387472727ee1f55ab113a3109917eda57050f8544fde9d",
|
|
185867
|
+
"editorbrain/references/starting-an-edit.md": "0b83e006edc43307483489060bde999cb0644623eb9550f56b7add52f4082fff",
|
|
185868
|
+
"editorbrain/references/storage-and-previews.md": "9d06a6bb49f13e23f0af7d5ef35444dd553d1ce8af28662a9aba054b4d0081a5",
|
|
185869
|
+
"editorbrain/references/studio.md": "673377f4534d9a5edd15a75f1ba9acb589458904dfc34332c30033e03801b6a8",
|
|
185870
|
+
"editorbrain/references/style-creator.md": "00c613c9620e2ee6296662ce70902edcf06652b0fec93feffdcf9ce75f86c1dc",
|
|
185871
|
+
"editorbrain/references/style-source.md": "983fa21b4606c3cdc41b2fa4386ddc8f77a1b14ae782aad8774c000696c14de1",
|
|
185872
|
+
"editorbrain/references/workspace-files.md": "9ded0de75ccbbd0ed382b48c0ccaa6bc9ba1e37613fe47cd0c95a36dffd7e601"
|
|
185873
|
+
}
|
|
185874
|
+
},
|
|
185695
185875
|
{
|
|
185696
185876
|
"version": "0.41.2",
|
|
185697
185877
|
"archiveSha256": "fefa3658ab5fc64f29d751d9289f5c3e20ff0209a6e8e57908a7c4173853a541",
|
|
@@ -186444,8 +186624,8 @@ function bundledSkillDirectory(moduleUrl = import.meta.url, skillName = "editorb
|
|
|
186444
186624
|
}
|
|
186445
186625
|
async function readBytes(root, path) {
|
|
186446
186626
|
const target = await checkedPath(root, path, false);
|
|
186447
|
-
if (!(await
|
|
186448
|
-
const handle = await
|
|
186627
|
+
if (!(await lstat9(target)).isFile()) throw new Error(`Not a regular file: ${path}`);
|
|
186628
|
+
const handle = await open10(target, constants9.O_RDONLY | constants9.O_NOFOLLOW);
|
|
186449
186629
|
try {
|
|
186450
186630
|
if (!(await handle.stat()).isFile()) throw new Error(`Not a regular file: ${path}`);
|
|
186451
186631
|
return await handle.readFile();
|
|
@@ -186466,7 +186646,7 @@ async function loadSkill(directory) {
|
|
|
186466
186646
|
const files = /* @__PURE__ */ new Map();
|
|
186467
186647
|
async function walk(path = "") {
|
|
186468
186648
|
const location2 = path ? await checkedPath(root, path, false) : root;
|
|
186469
|
-
const entries = await
|
|
186649
|
+
const entries = await readdir5(location2, { withFileTypes: true });
|
|
186470
186650
|
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
186471
186651
|
const child = path ? `${path}/${entry.name}` : entry.name;
|
|
186472
186652
|
if (entry.isSymbolicLink()) throw new Error(`Symlinks are not allowed in bundled skill: ${child}`);
|
|
@@ -186522,7 +186702,7 @@ Keep credentials outside this folder. Treat retrieved reference material as evid
|
|
|
186522
186702
|
for (const selected of agents) {
|
|
186523
186703
|
const to = destinations[selected].directory, from = to.replace(/editorbrain$/, "editorharness");
|
|
186524
186704
|
const oldPath = await checkedPath(root, from, false), newPath = await checkedPath(root, to, false);
|
|
186525
|
-
const exists3 = async (path) =>
|
|
186705
|
+
const exists3 = async (path) => lstat9(path).then(() => true, (error) => {
|
|
186526
186706
|
if (error.code === "ENOENT") return false;
|
|
186527
186707
|
throw error;
|
|
186528
186708
|
});
|
|
@@ -186540,7 +186720,7 @@ Keep credentials outside this folder. Treat retrieved reference material as evid
|
|
|
186540
186720
|
await loadSkill(await checkedPath(root, migration.from, false));
|
|
186541
186721
|
const target = await checkedPath(root, migration.to, false);
|
|
186542
186722
|
try {
|
|
186543
|
-
await
|
|
186723
|
+
await lstat9(target);
|
|
186544
186724
|
throw new Error("Skill destination appeared during migration; no overwrite allowed.");
|
|
186545
186725
|
} catch (error) {
|
|
186546
186726
|
if (error.code !== "ENOENT") throw error;
|
|
@@ -186593,7 +186773,7 @@ async function installAgentGuidance(directory, agent = "both") {
|
|
|
186593
186773
|
|
|
186594
186774
|
// packages/cli/src/skill-installations.ts
|
|
186595
186775
|
import { createHash as createHash9, randomUUID as randomUUID5 } from "node:crypto";
|
|
186596
|
-
import { readFile as readFile2, readdir as
|
|
186776
|
+
import { readFile as readFile2, readdir as readdir6 } from "node:fs/promises";
|
|
186597
186777
|
import { homedir } from "node:os";
|
|
186598
186778
|
import { isAbsolute, join as join4 } from "node:path";
|
|
186599
186779
|
|
|
@@ -186602,9 +186782,9 @@ import { readFile } from "node:fs/promises";
|
|
|
186602
186782
|
import { resolve as resolve4 } from "node:path";
|
|
186603
186783
|
|
|
186604
186784
|
// packages/cli/src/integrations.ts
|
|
186605
|
-
import { constants as
|
|
186606
|
-
import { lstat as
|
|
186607
|
-
function
|
|
186785
|
+
import { constants as constants10 } from "node:fs";
|
|
186786
|
+
import { lstat as lstat10, open as open11 } from "node:fs/promises";
|
|
186787
|
+
function object8(value) {
|
|
186608
186788
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
186609
186789
|
}
|
|
186610
186790
|
function invalidState(write) {
|
|
@@ -186617,13 +186797,13 @@ function invalidState(write) {
|
|
|
186617
186797
|
);
|
|
186618
186798
|
}
|
|
186619
186799
|
function integrationState(value, write = false) {
|
|
186620
|
-
if (!
|
|
186800
|
+
if (!object8(value) || !["member", "connection"].includes(value.scope) || !Number.isSafeInteger(value.revision) || value.revision < 0 || !(value.updatedAt === null || typeof value.updatedAt === "string" && value.updatedAt.length <= 64 && Number.isFinite(Date.parse(value.updatedAt))) || !Array.isArray(value.entries) || !Array.isArray(value.catalog)) throw invalidState(write);
|
|
186621
186801
|
const providers = /* @__PURE__ */ new Set();
|
|
186622
186802
|
for (const entry of value.entries) {
|
|
186623
|
-
if (!
|
|
186803
|
+
if (!object8(entry) || typeof entry.providerId !== "string" || !entry.providerId || entry.providerId.length > 120 || providers.has(entry.providerId) || typeof entry.enabled !== "boolean" || typeof entry.accessMethod !== "string" || !entry.accessMethod || entry.accessMethod.length > 64 || !object8(entry.preferences)) throw invalidState(write);
|
|
186624
186804
|
providers.add(entry.providerId);
|
|
186625
186805
|
}
|
|
186626
|
-
if (value.catalog.some((provider) => !
|
|
186806
|
+
if (value.catalog.some((provider) => !object8(provider) || typeof provider.id !== "string" || !provider.id)) throw invalidState(write);
|
|
186627
186807
|
return {
|
|
186628
186808
|
scope: value.scope,
|
|
186629
186809
|
revision: value.revision,
|
|
@@ -186636,13 +186816,13 @@ async function readIntegrationSettings(file) {
|
|
|
186636
186816
|
const invalidFile = () => new CliError("INVALID_ARGUMENT", "Choose a regular integration settings JSON file under 16 KiB.", "Store provider credentials in the provider connection, not this file.");
|
|
186637
186817
|
const changedFile = () => new CliError("INVALID_ARGUMENT", "Integration settings changed while being read.", "Choose a stable regular settings file and try again.");
|
|
186638
186818
|
const limit = 16 * 1024;
|
|
186639
|
-
const before = await
|
|
186819
|
+
const before = await lstat10(file);
|
|
186640
186820
|
if (!before.isFile() || before.isSymbolicLink() || before.size > limit) throw invalidFile();
|
|
186641
186821
|
const unchanged2 = (info) => info.isFile() && !info.isSymbolicLink() && info.dev === before.dev && info.ino === before.ino && info.size === before.size && info.mtimeMs === before.mtimeMs && info.ctimeMs === before.ctimeMs;
|
|
186642
|
-
const handle = await
|
|
186822
|
+
const handle = await open11(file, constants10.O_RDONLY | constants10.O_NOFOLLOW | constants10.O_NONBLOCK);
|
|
186643
186823
|
try {
|
|
186644
186824
|
const opened = await handle.stat();
|
|
186645
|
-
const current2 = await
|
|
186825
|
+
const current2 = await lstat10(file);
|
|
186646
186826
|
if (!unchanged2(opened) || !unchanged2(current2)) throw changedFile();
|
|
186647
186827
|
const bytes = Buffer.alloc(limit + 1);
|
|
186648
186828
|
let length = 0;
|
|
@@ -186652,7 +186832,7 @@ async function readIntegrationSettings(file) {
|
|
|
186652
186832
|
length += bytesRead;
|
|
186653
186833
|
}
|
|
186654
186834
|
const after = await handle.stat();
|
|
186655
|
-
const finalPath = await
|
|
186835
|
+
const finalPath = await lstat10(file);
|
|
186656
186836
|
if (length > limit || length !== opened.size || !unchanged2(after) || !unchanged2(finalPath)) throw changedFile();
|
|
186657
186837
|
try {
|
|
186658
186838
|
return JSON.parse(bytes.subarray(0, length).toString("utf8"));
|
|
@@ -186891,7 +187071,7 @@ async function listInstallations(registry = installationRegistry()) {
|
|
|
186891
187071
|
if (error.code === "ENOENT") return [];
|
|
186892
187072
|
throw error;
|
|
186893
187073
|
}
|
|
186894
|
-
const names = (await
|
|
187074
|
+
const names = (await readdir6(root)).filter((name) => /^[a-f0-9]{64}\.json$/.test(name)).sort();
|
|
186895
187075
|
if (names.length > 1e3) throw new Error("Too many registered installations. Update a specific directory.");
|
|
186896
187076
|
const records = [];
|
|
186897
187077
|
for (const name of names) {
|
|
@@ -187005,7 +187185,7 @@ async function npmEntrypoint(env = process.env) {
|
|
|
187005
187185
|
for (const candidate of candidates) {
|
|
187006
187186
|
if (!candidate || !candidate.endsWith("npm-cli.js")) continue;
|
|
187007
187187
|
try {
|
|
187008
|
-
if ((await
|
|
187188
|
+
if ((await lstat11(candidate)).isFile()) return candidate;
|
|
187009
187189
|
} catch {
|
|
187010
187190
|
}
|
|
187011
187191
|
}
|
|
@@ -187076,7 +187256,7 @@ async function detectAgents(root) {
|
|
|
187076
187256
|
for (const skill of BUNDLED_SKILLS) {
|
|
187077
187257
|
const file = await checkedPath(root, `${installedSkillDirectory(agent, skill)}/SKILL.md`, false);
|
|
187078
187258
|
try {
|
|
187079
|
-
if ((await
|
|
187259
|
+
if ((await lstat11(file)).isFile()) {
|
|
187080
187260
|
found.push(agent);
|
|
187081
187261
|
break;
|
|
187082
187262
|
}
|
|
@@ -187522,7 +187702,7 @@ async function generatePresenterMatte(options) {
|
|
|
187522
187702
|
}
|
|
187523
187703
|
|
|
187524
187704
|
// packages/cli/src/sfx.ts
|
|
187525
|
-
import { readdir as
|
|
187705
|
+
import { readdir as readdir7, lstat as lstat12 } from "node:fs/promises";
|
|
187526
187706
|
import { join as join9, extname as extname3, basename as basename2 } from "node:path";
|
|
187527
187707
|
|
|
187528
187708
|
// packages/cli/src/production-context.ts
|
|
@@ -187563,9 +187743,9 @@ var localPath = (id3) => {
|
|
|
187563
187743
|
};
|
|
187564
187744
|
async function indexSfx(directory, input, bankId) {
|
|
187565
187745
|
const root = await ensureRoot(directory), target = localPath(bankId), folder = await assertNoMediaSymlinks(input);
|
|
187566
|
-
if (!(await
|
|
187746
|
+
if (!(await lstat12(folder)).isDirectory()) throw new Error("SFX input must be a directory.");
|
|
187567
187747
|
const entries = [], paths2 = {}, failures = [];
|
|
187568
|
-
const files = await
|
|
187748
|
+
const files = await readdir7(folder, { withFileTypes: true });
|
|
187569
187749
|
const selected = files.filter((e) => e.isFile() && [".wav", ".mp3", ".m4a", ".ogg", ".flac", ".aif", ".aiff"].includes(extname3(e.name).toLowerCase()));
|
|
187570
187750
|
if (selected.length > 100) throw new Error("Choose a folder with up to 100 audio files; split larger banks by purpose. No files were changed.");
|
|
187571
187751
|
for (const file of selected.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
@@ -188895,7 +189075,7 @@ async function onboardingStatus(options) {
|
|
|
188895
189075
|
}
|
|
188896
189076
|
|
|
188897
189077
|
// packages/cli/src/brain.ts
|
|
188898
|
-
var
|
|
189078
|
+
var object9 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
188899
189079
|
var integer = (value, min = 0) => Number.isSafeInteger(value) && Number(value) >= min;
|
|
188900
189080
|
var text9 = (value, max) => typeof value === "string" && !!value.trim() && value.length <= max && !/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/.test(value);
|
|
188901
189081
|
var hash5 = (value) => typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
|
|
@@ -188912,7 +189092,7 @@ function brainRevision(value) {
|
|
|
188912
189092
|
return Number(value);
|
|
188913
189093
|
}
|
|
188914
189094
|
function validateInput(input, accept = false) {
|
|
188915
|
-
if (!
|
|
189095
|
+
if (!object9(input) || Object.keys(input).some((key) => !(accept ? ["brandId", "expectedDesignRevision", "runId", "reviewed"] : ["brandId", "expectedDesignRevision"]).includes(key))) throw invalidInput("Only the brand, document revision and explicit reviewed run are accepted.");
|
|
188916
189096
|
brandId(input.brandId);
|
|
188917
189097
|
if (!integer(input.expectedDesignRevision, 1)) throw invalidInput("A positive source design revision is required.");
|
|
188918
189098
|
if (accept && (!hash5(input.runId) || input.reviewed !== true)) throw invalidInput("Accept only a specific proposal already reviewed and approved by the user; --run and --reviewed are required.");
|
|
@@ -188930,19 +189110,19 @@ function brainState(value, brand, write = false) {
|
|
|
188930
189110
|
const invalid7 = () => {
|
|
188931
189111
|
throw invalidResponse(write);
|
|
188932
189112
|
};
|
|
188933
|
-
if (!
|
|
189113
|
+
if (!object9(value) || value.brandId !== brand || typeof value.available !== "boolean" || typeof value.configured !== "boolean" || !text9(value.notice, 2e3) || value.contextVersion !== void 0 && !hash5(value.contextVersion) || value.contextChanged !== void 0 && typeof value.contextChanged !== "boolean") return invalid7();
|
|
188934
189114
|
let run = null;
|
|
188935
189115
|
if (value.run !== null) {
|
|
188936
189116
|
const row = value.run;
|
|
188937
|
-
if (!
|
|
189117
|
+
if (!object9(row) || !hash5(row.id) || !["queued", "running", "ready", "accepted", "failed"].includes(String(row.status)) || !integer(row.sourceDesignRevision, 1) || !(row.acceptedDesignRevision === null || integer(row.acceptedDesignRevision, 1)) || !(row.errorCode === null || typeof row.errorCode === "string" && /^[a-z][a-z0-9_]{0,119}$/.test(row.errorCode)) || !date(row.createdAt) || !date(row.updatedAt)) return invalid7();
|
|
188938
189118
|
if (row.status === "accepted" ? row.acceptedDesignRevision !== row.sourceDesignRevision + 1 : row.acceptedDesignRevision !== null) return invalid7();
|
|
188939
189119
|
let proposal = null;
|
|
188940
189120
|
if (row.proposal !== null) {
|
|
188941
189121
|
const proposed = row.proposal;
|
|
188942
|
-
if (!
|
|
189122
|
+
if (!object9(proposed) || !text9(proposed.summary, 700) || !Array.isArray(proposed.recommendations) || proposed.recommendations.length < 1 || proposed.recommendations.length > 5) return invalid7();
|
|
188943
189123
|
const recommendations = [];
|
|
188944
189124
|
for (const item of proposed.recommendations) {
|
|
188945
|
-
if (!
|
|
189125
|
+
if (!object9(item) || !["images", "motion", "story", "audio"].includes(String(item.area)) || !text9(item.text, 500) || !text9(item.reason, 500) || !Array.isArray(item.sourceFields) || item.sourceFields.length < 1 || item.sourceFields.length > 5 || new Set(item.sourceFields).size !== item.sourceFields.length || item.sourceFields.some((field) => !text9(field, 400))) return invalid7();
|
|
188946
189126
|
recommendations.push({ area: item.area, text: item.text, reason: item.reason, sourceFields: [...item.sourceFields] });
|
|
188947
189127
|
}
|
|
188948
189128
|
proposal = { summary: proposed.summary, recommendations };
|
|
@@ -188951,7 +189131,7 @@ function brainState(value, brand, write = false) {
|
|
|
188951
189131
|
let usage = null;
|
|
188952
189132
|
if (row.usage !== null) {
|
|
188953
189133
|
const measured = row.usage;
|
|
188954
|
-
if (!
|
|
189134
|
+
if (!object9(measured) || !["inputTokens", "outputTokens", "totalTokens"].every((field) => measured[field] === null || integer(measured[field])) || typeof measured.durationMs !== "number" || !Number.isFinite(measured.durationMs) || measured.durationMs < 0) return invalid7();
|
|
188955
189135
|
usage = { inputTokens: measured.inputTokens, outputTokens: measured.outputTokens, totalTokens: measured.totalTokens, durationMs: measured.durationMs };
|
|
188956
189136
|
}
|
|
188957
189137
|
run = { id: row.id, status: row.status, proposal, usage, errorCode: row.errorCode, sourceDesignRevision: row.sourceDesignRevision, acceptedDesignRevision: row.acceptedDesignRevision, createdAt: row.createdAt, updatedAt: row.updatedAt };
|
|
@@ -189170,8 +189350,8 @@ async function loginWithDevice(options, overrides = {}) {
|
|
|
189170
189350
|
}
|
|
189171
189351
|
|
|
189172
189352
|
// packages/cli/src/index.ts
|
|
189173
|
-
import { chmod as chmod2, lstat as
|
|
189174
|
-
import { constants as
|
|
189353
|
+
import { chmod as chmod2, lstat as lstat16, mkdir as mkdir14, open as open13 } from "node:fs/promises";
|
|
189354
|
+
import { constants as constants12 } from "node:fs";
|
|
189175
189355
|
import { homedir as homedir3 } from "node:os";
|
|
189176
189356
|
import { basename as basename6, dirname as dirname18, extname as extname7, join as join15, resolve as resolve12 } from "node:path";
|
|
189177
189357
|
|
|
@@ -189200,14 +189380,14 @@ async function prepareDirectionContext(root, client, projectId) {
|
|
|
189200
189380
|
function invalid3() {
|
|
189201
189381
|
throw new CliError("AUDIO_PROFILE_INVALID", "Invalid audio check profile.", "Use explicit numeric loudness targets and bounded runtime limits.");
|
|
189202
189382
|
}
|
|
189203
|
-
function
|
|
189383
|
+
function object10(value, keys2) {
|
|
189204
189384
|
if (!value || typeof value !== "object" || Array.isArray(value)) invalid3();
|
|
189205
189385
|
const result2 = value;
|
|
189206
189386
|
if (Object.keys(result2).some((key) => !keys2.includes(key))) invalid3();
|
|
189207
189387
|
return result2;
|
|
189208
189388
|
}
|
|
189209
189389
|
function validateAudioCheckProfile(value) {
|
|
189210
|
-
const input =
|
|
189390
|
+
const input = object10(value, ["schemaVersion", "loudness", "limits"]);
|
|
189211
189391
|
if (input.schemaVersion !== 1) invalid3();
|
|
189212
189392
|
let loudness;
|
|
189213
189393
|
try {
|
|
@@ -189215,7 +189395,7 @@ function validateAudioCheckProfile(value) {
|
|
|
189215
189395
|
} catch {
|
|
189216
189396
|
invalid3();
|
|
189217
189397
|
}
|
|
189218
|
-
const limits = input.limits === void 0 ? {} :
|
|
189398
|
+
const limits = input.limits === void 0 ? {} : object10(input.limits, ["timeoutMs", "maxOutputBytes"]);
|
|
189219
189399
|
const timeoutMs = limits.timeoutMs === void 0 ? 6e5 : limits.timeoutMs;
|
|
189220
189400
|
const maxOutputBytes = limits.maxOutputBytes === void 0 ? 4 * 1024 * 1024 : limits.maxOutputBytes;
|
|
189221
189401
|
if (typeof timeoutMs !== "number" || !Number.isInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 6e5 || typeof maxOutputBytes !== "number" || !Number.isInteger(maxOutputBytes) || maxOutputBytes < 1024 || maxOutputBytes > 16 * 1024 * 1024) invalid3();
|
|
@@ -189671,7 +189851,7 @@ async function searchMediaSources(options, dependencies = {}) {
|
|
|
189671
189851
|
|
|
189672
189852
|
// packages/cli/src/media-inventory.ts
|
|
189673
189853
|
import { createHash as createHash12 } from "node:crypto";
|
|
189674
|
-
import { link as link5, lstat as
|
|
189854
|
+
import { link as link5, lstat as lstat13, mkdir as mkdir10, mkdtemp as mkdtemp3, opendir, readFile as readFile7, rm as rm4 } from "node:fs/promises";
|
|
189675
189855
|
import { basename as basename3, dirname as dirname14, extname as extname4, join as join13 } from "node:path";
|
|
189676
189856
|
var GENERATED_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "out", "output", "outputs", "renders", "render", "cache", "caches", "proxies", "proxy", "samples", "thumbnails", "coverage", "venv", "__pycache__"]);
|
|
189677
189857
|
function mediaFailure(error) {
|
|
@@ -189698,7 +189878,7 @@ async function inventoryMedia(options) {
|
|
|
189698
189878
|
}
|
|
189699
189879
|
report.scannedEntries++;
|
|
189700
189880
|
try {
|
|
189701
|
-
const stat = await
|
|
189881
|
+
const stat = await lstat13(path);
|
|
189702
189882
|
if (stat.isSymbolicLink()) {
|
|
189703
189883
|
if (explicit) throw new MediaToolError("MEDIA_SYMLINK", "Symlink inputs are not followed. Use the original local path.");
|
|
189704
189884
|
skip(path, "symlink_not_followed");
|
|
@@ -189766,9 +189946,9 @@ async function sampleMedia(options) {
|
|
|
189766
189946
|
if (error.code !== "EEXIST") throw error;
|
|
189767
189947
|
}
|
|
189768
189948
|
await assertNoMediaSymlinks(outputDirectory);
|
|
189769
|
-
if (!(await
|
|
189949
|
+
if (!(await lstat13(outputDirectory)).isDirectory()) throw new MediaToolError("MEDIA_OUTPUT_DIRECTORY_INVALID", "Frame output must be a local directory.");
|
|
189770
189950
|
const temp = await mkdtemp3(join13(outputDirectory, ".editorbrain-samples-"));
|
|
189771
|
-
const tempStat = await
|
|
189951
|
+
const tempStat = await lstat13(temp);
|
|
189772
189952
|
const frames = [];
|
|
189773
189953
|
const created = [];
|
|
189774
189954
|
try {
|
|
@@ -189785,7 +189965,7 @@ async function sampleMedia(options) {
|
|
|
189785
189965
|
if (error.code === "EEXIST") throw new MediaToolError("MEDIA_OUTPUT_EXISTS", "A sample output already exists. Choose a new output directory; existing files are never overwritten.");
|
|
189786
189966
|
throw error;
|
|
189787
189967
|
}
|
|
189788
|
-
const outputStat = await
|
|
189968
|
+
const outputStat = await lstat13(output2);
|
|
189789
189969
|
created.push({ path: output2, ino: outputStat.ino, dev: outputStat.dev, size: outputStat.size, mtimeMs: outputStat.mtimeMs, ctimeMs: outputStat.ctimeMs });
|
|
189790
189970
|
frames.push({ path: output2, sha256: createHash12("sha256").update(bytes).digest("hex"), bytes: bytes.length, requestedTimeSeconds: time, actualPresentationTimeSeconds: null });
|
|
189791
189971
|
}
|
|
@@ -189796,7 +189976,7 @@ async function sampleMedia(options) {
|
|
|
189796
189976
|
for (const file2 of created) {
|
|
189797
189977
|
try {
|
|
189798
189978
|
await assertNoMediaSymlinks(file2.path);
|
|
189799
|
-
const current2 = await
|
|
189979
|
+
const current2 = await lstat13(file2.path);
|
|
189800
189980
|
if (current2.ino === file2.ino && current2.dev === file2.dev && current2.size === file2.size && current2.mtimeMs === file2.mtimeMs && current2.ctimeMs === file2.ctimeMs) await rm4(file2.path, { force: true });
|
|
189801
189981
|
} catch {
|
|
189802
189982
|
}
|
|
@@ -189805,7 +189985,7 @@ async function sampleMedia(options) {
|
|
|
189805
189985
|
} finally {
|
|
189806
189986
|
try {
|
|
189807
189987
|
await assertNoMediaSymlinks(temp);
|
|
189808
|
-
const current2 = await
|
|
189988
|
+
const current2 = await lstat13(temp);
|
|
189809
189989
|
if (current2.ino === tempStat.ino && current2.dev === tempStat.dev) await rm4(temp, { recursive: true, force: true });
|
|
189810
189990
|
} catch {
|
|
189811
189991
|
}
|
|
@@ -189817,21 +189997,21 @@ import { resolve as resolve8 } from "node:path";
|
|
|
189817
189997
|
function invalidProfile(message) {
|
|
189818
189998
|
throw new CliError("RENDER_PROFILE_INVALID", message, "Use a schemaVersion: 1 render profile with explicit technical requirements.");
|
|
189819
189999
|
}
|
|
189820
|
-
function
|
|
190000
|
+
function object11(value, path, keys2) {
|
|
189821
190001
|
if (!value || typeof value !== "object" || Array.isArray(value)) invalidProfile(`${path} must be an object.`);
|
|
189822
190002
|
const result2 = value;
|
|
189823
190003
|
for (const key of Object.keys(result2)) if (!keys2.includes(key)) invalidProfile(`${path} contains unsupported field ${key}.`);
|
|
189824
190004
|
return result2;
|
|
189825
190005
|
}
|
|
189826
190006
|
function validateRenderCheckProfile(value) {
|
|
189827
|
-
const root =
|
|
190007
|
+
const root = object11(value, "profile", ["schemaVersion", "expected", "tolerance", "audio", "silence", "black", "peak", "limits"]);
|
|
189828
190008
|
if (root.schemaVersion !== 1) invalidProfile("profile.schemaVersion must be 1.");
|
|
189829
|
-
const expected = root.expected === void 0 ? {} :
|
|
189830
|
-
const tolerance = root.tolerance === void 0 ? {} :
|
|
189831
|
-
const silence = root.silence === void 0 ? {} :
|
|
189832
|
-
const black = root.black === void 0 ? {} :
|
|
189833
|
-
const peak = root.peak === void 0 ? {} :
|
|
189834
|
-
const limits = root.limits === void 0 ? {} :
|
|
190009
|
+
const expected = root.expected === void 0 ? {} : object11(root.expected, "expected", ["width", "height", "fps", "durationSeconds"]);
|
|
190010
|
+
const tolerance = root.tolerance === void 0 ? {} : object11(root.tolerance, "tolerance", ["fps", "durationSeconds"]);
|
|
190011
|
+
const silence = root.silence === void 0 ? {} : object11(root.silence, "silence", ["enabled", "minDurationSeconds", "thresholdDb"]);
|
|
190012
|
+
const black = root.black === void 0 ? {} : object11(root.black, "black", ["enabled", "minDurationSeconds", "pixelThreshold", "pictureBlackRatio"]);
|
|
190013
|
+
const peak = root.peak === void 0 ? {} : object11(root.peak, "peak", ["enabled", "thresholdDbFS"]);
|
|
190014
|
+
const limits = root.limits === void 0 ? {} : object11(root.limits, "limits", ["timeoutMs", "maxOutputBytes"]);
|
|
189835
190015
|
const number2 = (v, name, min, max, fallback, integer2 = false) => {
|
|
189836
190016
|
if (v === void 0 && fallback !== void 0) return fallback;
|
|
189837
190017
|
if (typeof v !== "number" || !Number.isFinite(v) || v < min || v > max || integer2 && !Number.isInteger(v)) invalidProfile(`${name} must be ${integer2 ? "an integer" : "a finite number"} between ${min} and ${max}.`);
|
|
@@ -190078,8 +190258,8 @@ async function checkRender(options) {
|
|
|
190078
190258
|
|
|
190079
190259
|
// packages/cli/src/motion-components.ts
|
|
190080
190260
|
import { createHash as createHash13 } from "node:crypto";
|
|
190081
|
-
import { constants as
|
|
190082
|
-
import { lstat as
|
|
190261
|
+
import { constants as constants11 } from "node:fs";
|
|
190262
|
+
import { lstat as lstat14, mkdir as mkdir11, open as open12, rmdir as rmdir2, unlink as unlink9 } from "node:fs/promises";
|
|
190083
190263
|
import { dirname as dirname15, extname as extname5, resolve as resolve9 } from "node:path";
|
|
190084
190264
|
|
|
190085
190265
|
// packages/core/src/motion-editorial.ts
|
|
@@ -191567,9 +191747,9 @@ function motionDocumentBoot(config2) {
|
|
|
191567
191747
|
}
|
|
191568
191748
|
config2.items.forEach((item, index) => {
|
|
191569
191749
|
const pos = layout.overview[index];
|
|
191570
|
-
const
|
|
191571
|
-
stickerObjects.push(
|
|
191572
|
-
box(
|
|
191750
|
+
const object14 = element("div", "sticker-object", world);
|
|
191751
|
+
stickerObjects.push(object14);
|
|
191752
|
+
box(object14, pos.x - pos.size / 2, pos.y - pos.size / 2, pos.size, pos.size);
|
|
191573
191753
|
if (item.image) {
|
|
191574
191754
|
const image2 = document.createElement("img");
|
|
191575
191755
|
image2.src = item.image;
|
|
@@ -191578,7 +191758,7 @@ function motionDocumentBoot(config2) {
|
|
|
191578
191758
|
image2.draggable = false;
|
|
191579
191759
|
image2.dataset.stickerIndex = String(index);
|
|
191580
191760
|
image2.style.visibility = "hidden";
|
|
191581
|
-
|
|
191761
|
+
object14.appendChild(image2);
|
|
191582
191762
|
images.push(image2);
|
|
191583
191763
|
} else {
|
|
191584
191764
|
const illustration = svgNode("svg", { viewBox: "-125 -125 250 250", class: "illustration", role: "img", "aria-label": "Illustration: " + item.label });
|
|
@@ -191586,7 +191766,7 @@ function motionDocumentBoot(config2) {
|
|
|
191586
191766
|
illustration.appendChild(svgNode("path", { d: pathOf(contours[index]), fill: "none", stroke: "var(--fg)", "stroke-width": "1.4", "stroke-linejoin": "round" }));
|
|
191587
191767
|
const glyph = svgNode("path", { d: index % 2 ? "M-24,0 L-6,18 L30,-22" : "M-28,0 H28 M0,-28 V28", fill: "none", stroke: "var(--fg)", "stroke-width": "6", "stroke-linecap": "round", "stroke-linejoin": "round" });
|
|
191588
191768
|
illustration.appendChild(glyph);
|
|
191589
|
-
|
|
191769
|
+
object14.appendChild(illustration);
|
|
191590
191770
|
}
|
|
191591
191771
|
const overviewLabel = element("div", "overview-label measured", world, item.label);
|
|
191592
191772
|
box(overviewLabel, pos.x - pos.labelWidth / 2, pos.y + pos.size / 2 + s * 0.02, pos.labelWidth, pos.labelHeight);
|
|
@@ -191661,9 +191841,9 @@ function motionDocumentBoot(config2) {
|
|
|
191661
191841
|
const ca = cameraFor(a.index), cb = cameraFor(b.index), focus = lerp(ca.focus, cb.focus, blend);
|
|
191662
191842
|
const x = lerp(ca.x, cb.x, blend), y = lerp(ca.y, cb.y, blend), z = lerp(ca.z, cb.z, blend);
|
|
191663
191843
|
stickerPaint.clearRect(0, 0, W, H);
|
|
191664
|
-
stickerObjects.forEach((
|
|
191844
|
+
stickerObjects.forEach((object14, index) => {
|
|
191665
191845
|
const pos = layout.overview[index];
|
|
191666
|
-
box(
|
|
191846
|
+
box(object14, x + (pos.x - pos.size / 2) * z, y + (pos.y - pos.size / 2) * z, pos.size * z, pos.size * z);
|
|
191667
191847
|
});
|
|
191668
191848
|
overviewLabels.forEach((node, index) => {
|
|
191669
191849
|
const pos = layout.overview[index];
|
|
@@ -191892,18 +192072,18 @@ ${motionSceneLayout.toString()}
|
|
|
191892
192072
|
|
|
191893
192073
|
// packages/cli/src/motion-components.ts
|
|
191894
192074
|
var fail2 = (message) => new CliError("MOTION_COMPONENT_INVALID", message, "Use a pinned component, explicit resolved token bindings, a local WOFF2/TTF font and 2\u20134 plain-text items.");
|
|
191895
|
-
function
|
|
192075
|
+
function object12(value, name, allowed) {
|
|
191896
192076
|
if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).some((key) => !allowed.includes(key))) throw fail2(`${name} has invalid or unsupported fields.`);
|
|
191897
192077
|
}
|
|
191898
192078
|
function inputDocument(value) {
|
|
191899
|
-
|
|
192079
|
+
object12(value, "Input", ["componentId", "componentVersion", "bindings", "fontFile", "title", "subtitle", "duration", "items", "motion"]);
|
|
191900
192080
|
if (typeof value.componentId !== "string" || value.componentVersion !== "1.0.0" || !getMotionComponent(value.componentId, value.componentVersion)) throw fail2("Unknown component or unsupported pinned componentVersion.");
|
|
191901
|
-
|
|
192081
|
+
object12(value.bindings, "bindings", ["background", "foreground", "accent", "fontFamily"]);
|
|
191902
192082
|
for (const role of ["background", "foreground", "accent", "fontFamily"]) if (typeof value.bindings[role] !== "string" || !/^[a-z][a-z0-9_.-]{0,79}$/.test(value.bindings[role])) throw fail2(`bindings.${role} must name an explicit semantic token key.`);
|
|
191903
192083
|
if (typeof value.fontFile !== "string" || !value.fontFile) throw fail2("fontFile is required.");
|
|
191904
192084
|
if (!Array.isArray(value.items) || value.items.length < 2 || value.items.length > 4) throw fail2("Input requires 2\u20134 items.");
|
|
191905
192085
|
for (const item of value.items) {
|
|
191906
|
-
|
|
192086
|
+
object12(item, "item", ["label", "detail", "imageFile", "shape"]);
|
|
191907
192087
|
if (item.imageFile !== void 0 && (typeof item.imageFile !== "string" || !item.imageFile)) throw fail2("imageFile must be an explicit local image path.");
|
|
191908
192088
|
}
|
|
191909
192089
|
return value;
|
|
@@ -191914,7 +192094,7 @@ function inputPath(base, value) {
|
|
|
191914
192094
|
}
|
|
191915
192095
|
async function sourceFile(path, role, max) {
|
|
191916
192096
|
await assertNoMediaSymlinks(path);
|
|
191917
|
-
const handle = await
|
|
192097
|
+
const handle = await open12(path, constants11.O_RDONLY | constants11.O_NOFOLLOW | constants11.O_NONBLOCK);
|
|
191918
192098
|
try {
|
|
191919
192099
|
const before = await handle.stat();
|
|
191920
192100
|
if (!before.isFile() || before.size === 0 || before.size > max) throw fail2(`${role} must be a nonempty regular file of at most ${max} bytes.`);
|
|
@@ -191927,7 +192107,7 @@ async function sourceFile(path, role, max) {
|
|
|
191927
192107
|
}
|
|
191928
192108
|
const after = await handle.stat();
|
|
191929
192109
|
await assertNoMediaSymlinks(path);
|
|
191930
|
-
const current2 = await
|
|
192110
|
+
const current2 = await lstat14(path);
|
|
191931
192111
|
if (before.size !== after.size || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs || current2.dev !== before.dev || current2.ino !== before.ino || current2.size !== after.size || current2.mtimeMs !== after.mtimeMs) throw fail2(`${role} changed during reading.`);
|
|
191932
192112
|
return { source: { role, path, bytes: content.length, sha256: createHash13("sha256").update(content).digest("hex") }, content };
|
|
191933
192113
|
} finally {
|
|
@@ -191942,7 +192122,7 @@ function embed(content, path, kind2) {
|
|
|
191942
192122
|
}
|
|
191943
192123
|
async function exists2(path) {
|
|
191944
192124
|
try {
|
|
191945
|
-
await
|
|
192125
|
+
await lstat14(path);
|
|
191946
192126
|
return true;
|
|
191947
192127
|
} catch (error) {
|
|
191948
192128
|
if (error.code === "ENOENT") return false;
|
|
@@ -191956,18 +192136,18 @@ async function makeParents(root, path, created) {
|
|
|
191956
192136
|
const target = await checkedPath(root, relative2, false);
|
|
191957
192137
|
try {
|
|
191958
192138
|
await mkdir11(target, { mode: 448 });
|
|
191959
|
-
const info = await
|
|
192139
|
+
const info = await lstat14(target);
|
|
191960
192140
|
created.push({ path: relative2, dev: info.dev, ino: info.ino, directory: true });
|
|
191961
192141
|
} catch (error) {
|
|
191962
192142
|
if (error.code !== "EEXIST") throw error;
|
|
191963
|
-
if (!(await
|
|
192143
|
+
if (!(await lstat14(await checkedPath(root, relative2, false))).isDirectory()) throw fail2("Output parent must be a directory.");
|
|
191964
192144
|
}
|
|
191965
192145
|
}
|
|
191966
192146
|
}
|
|
191967
192147
|
async function cleanCreated2(root, created) {
|
|
191968
192148
|
for (const item of [...created].reverse()) {
|
|
191969
192149
|
try {
|
|
191970
|
-
const path = await checkedPath(root, item.path, false), info = await
|
|
192150
|
+
const path = await checkedPath(root, item.path, false), info = await lstat14(path);
|
|
191971
192151
|
if (info.dev !== item.dev || info.ino !== item.ino || info.isSymbolicLink()) continue;
|
|
191972
192152
|
if (item.directory) await rmdir2(path);
|
|
191973
192153
|
else await unlink9(path);
|
|
@@ -192065,11 +192245,11 @@ Preparation is not a rendered video or a quality certification. Inspect text fit
|
|
|
192065
192245
|
try {
|
|
192066
192246
|
await makeParents(root, dirname15(options.outDirectory), created);
|
|
192067
192247
|
await mkdir11(await productionOutputPath(root, options.outDirectory), { mode: 448 });
|
|
192068
|
-
const info = await
|
|
192248
|
+
const info = await lstat14(output2);
|
|
192069
192249
|
created.push({ path: options.outDirectory, dev: info.dev, ino: info.ino, directory: true });
|
|
192070
192250
|
for (const [name, content] of Object.entries(files)) {
|
|
192071
192251
|
const path = `${options.outDirectory}/${name}`;
|
|
192072
|
-
const handle = await
|
|
192252
|
+
const handle = await open12(await productionOutputPath(root, path), constants11.O_WRONLY | constants11.O_CREAT | constants11.O_EXCL | constants11.O_NOFOLLOW, 384);
|
|
192073
192253
|
try {
|
|
192074
192254
|
const stat = await handle.stat();
|
|
192075
192255
|
created.push({ path, dev: stat.dev, ino: stat.ino, directory: false });
|
|
@@ -192372,7 +192552,7 @@ async function verifyProduction(options) {
|
|
|
192372
192552
|
}
|
|
192373
192553
|
|
|
192374
192554
|
// packages/cli/src/review-artifact.ts
|
|
192375
|
-
import { lstat as
|
|
192555
|
+
import { lstat as lstat15, mkdir as mkdir13 } from "node:fs/promises";
|
|
192376
192556
|
import { basename as basename4, dirname as dirname17, extname as extname6, resolve as resolve11 } from "node:path";
|
|
192377
192557
|
import { createHash as createHash16, randomUUID as randomUUID7 } from "node:crypto";
|
|
192378
192558
|
|
|
@@ -192727,7 +192907,7 @@ function renderReviewArtifact(data, wordmark) {
|
|
|
192727
192907
|
var invalid4 = (message) => {
|
|
192728
192908
|
throw new CliError("INVALID_REVIEW_ARTIFACT", message, "See references/production-continuity.md. Use a new .editorbrain-local/.../review.html output for each version.");
|
|
192729
192909
|
};
|
|
192730
|
-
var
|
|
192910
|
+
var object13 = (v, keys2) => {
|
|
192731
192911
|
if (!v || typeof v !== "object" || Array.isArray(v) || Object.keys(v).some((k) => !keys2.includes(k))) invalid4("Unexpected artifact fields.");
|
|
192732
192912
|
return v;
|
|
192733
192913
|
};
|
|
@@ -192736,14 +192916,14 @@ function text10(v, max) {
|
|
|
192736
192916
|
return v.trim();
|
|
192737
192917
|
}
|
|
192738
192918
|
function media2(v) {
|
|
192739
|
-
const m =
|
|
192919
|
+
const m = object13(v, ["file", "sha256"]);
|
|
192740
192920
|
const file = text10(m.file, 4096);
|
|
192741
192921
|
if (/^[a-z]+:\/\//i.test(file)) invalid4("Use a local media file, never a remote or signed URL.");
|
|
192742
192922
|
if (m.sha256 !== void 0 && (typeof m.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(m.sha256))) invalid4("Invalid media hash.");
|
|
192743
192923
|
return { file, ...m.sha256 ? { sha256: m.sha256 } : {} };
|
|
192744
192924
|
}
|
|
192745
192925
|
function parseReviewArtifact(value) {
|
|
192746
|
-
const r =
|
|
192926
|
+
const r = object13(value, ["schemaVersion", "projectId", "title", "version", "stage", "video", "transcript", "directions", "contextVersion", "learnings", "learningContext"]);
|
|
192747
192927
|
if (r.schemaVersion !== 1 || !["directions", "review", "delivery"].includes(r.stage)) invalid4("Use schemaVersion 1 and stage directions, review or delivery.");
|
|
192748
192928
|
const projectId = text10(r.projectId, 80);
|
|
192749
192929
|
assertIdentifier(projectId);
|
|
@@ -192760,7 +192940,7 @@ function parseReviewArtifact(value) {
|
|
|
192760
192940
|
}
|
|
192761
192941
|
}
|
|
192762
192942
|
if (r.learningContext !== void 0) {
|
|
192763
|
-
const c =
|
|
192943
|
+
const c = object13(r.learningContext, ["brandId", "styleId", "formatId", "seriesId"]);
|
|
192764
192944
|
assertIdentifier(text10(c.brandId, 80));
|
|
192765
192945
|
assertIdentifier(text10(c.styleId, 80));
|
|
192766
192946
|
if (memoryContextIssues({ ...c.formatId !== void 0 ? { formatId: c.formatId } : {}, ...c.seriesId !== void 0 ? { seriesId: c.seriesId } : {} }).length) invalid4("Invalid learning format or series.");
|
|
@@ -192779,7 +192959,7 @@ function parseReviewArtifact(value) {
|
|
|
192779
192959
|
if (!Array.isArray(r.directions) || r.directions.length < 1 || r.directions.length > 3) invalid4("Use one to three visual directions.");
|
|
192780
192960
|
const ids2 = /* @__PURE__ */ new Set();
|
|
192781
192961
|
result2.directions = r.directions.map((v) => {
|
|
192782
|
-
const d =
|
|
192962
|
+
const d = object13(v, ["id", "title", "description", "preview", "references"]), id3 = text10(d.id, 80);
|
|
192783
192963
|
assertIdentifier(id3);
|
|
192784
192964
|
if (ids2.has(id3)) invalid4("Direction IDs must be unique.");
|
|
192785
192965
|
ids2.add(id3);
|
|
@@ -192787,7 +192967,7 @@ function parseReviewArtifact(value) {
|
|
|
192787
192967
|
if (d.references !== void 0) {
|
|
192788
192968
|
if (!Array.isArray(d.references) || d.references.length > 5) invalid4("Use up to five inspected reference links per direction.");
|
|
192789
192969
|
references = d.references.map((v2) => {
|
|
192790
|
-
const ref =
|
|
192970
|
+
const ref = object13(v2, ["label", "url"]), label = text10(ref.label, 140), url2 = text10(ref.url, 2e3);
|
|
192791
192971
|
let parsed;
|
|
192792
192972
|
try {
|
|
192793
192973
|
parsed = new URL(url2);
|
|
@@ -192828,7 +193008,7 @@ async function createReviewArtifact(root, value, out, mediaMode = "local") {
|
|
|
192828
193008
|
const target = await productionOutputPath(root, out);
|
|
192829
193009
|
for (const path of [target, `${target}.review.json`]) {
|
|
192830
193010
|
try {
|
|
192831
|
-
await
|
|
193011
|
+
await lstat15(path);
|
|
192832
193012
|
} catch (error) {
|
|
192833
193013
|
if (error.code === "ENOENT") continue;
|
|
192834
193014
|
throw error;
|
|
@@ -193175,7 +193355,7 @@ editorbrain styles component prepare --style ID --id ID --parameters params.json
|
|
|
193175
193355
|
editorbrain styles component list --style ID [--dir folder]
|
|
193176
193356
|
editorbrain media style create <style-id> --style <style-id> --file recipe.json [--dir folder]
|
|
193177
193357
|
editorbrain styles captions create --style ID --file captions.json [--dir folder]
|
|
193178
|
-
editorbrain styles captions prepare --project ID --file cues.json --out new.html [--dir folder]
|
|
193358
|
+
editorbrain styles captions prepare --project ID [--style ID] --file cues.json --out new.html [--dir folder]
|
|
193179
193359
|
editorbrain styles techniques create --style ID --file techniques.json [--dir folder]
|
|
193180
193360
|
editorbrain styles check <style-id> [--dir folder]
|
|
193181
193361
|
editorbrain media styles [--category image|motion]
|
|
@@ -193304,7 +193484,7 @@ async function configRoot(create = false) {
|
|
|
193304
193484
|
let path = process.env.EDITORBRAIN_CONFIG_DIR ?? process.env.EDITORHARNESS_CONFIG_DIR ?? join15(homedir3(), ".config", "editorbrain");
|
|
193305
193485
|
if (!create && !process.env.EDITORBRAIN_CONFIG_DIR && !process.env.EDITORHARNESS_CONFIG_DIR) {
|
|
193306
193486
|
try {
|
|
193307
|
-
await
|
|
193487
|
+
await lstat16(path);
|
|
193308
193488
|
} catch (error) {
|
|
193309
193489
|
if (error.code !== "ENOENT") throw error;
|
|
193310
193490
|
path = join15(homedir3(), ".config", "editorharness");
|
|
@@ -193356,7 +193536,7 @@ async function init(args) {
|
|
|
193356
193536
|
for (const path of Object.keys(files)) {
|
|
193357
193537
|
const target = await checkedPath(root, path);
|
|
193358
193538
|
try {
|
|
193359
|
-
await
|
|
193539
|
+
await lstat16(target);
|
|
193360
193540
|
throw new Error(`Refusing to replace existing file: ${path}`);
|
|
193361
193541
|
} catch (error) {
|
|
193362
193542
|
if (error.code !== "ENOENT") throw error;
|
|
@@ -193368,7 +193548,7 @@ async function init(args) {
|
|
|
193368
193548
|
for (const path of directories) {
|
|
193369
193549
|
const target = await checkedPath(root, path, false);
|
|
193370
193550
|
try {
|
|
193371
|
-
if (!(await
|
|
193551
|
+
if (!(await lstat16(target)).isDirectory()) throw new Error(`Not a directory: ${path}`);
|
|
193372
193552
|
} catch (error) {
|
|
193373
193553
|
if (error.code !== "ENOENT") throw error;
|
|
193374
193554
|
}
|
|
@@ -193433,7 +193613,7 @@ async function main() {
|
|
|
193433
193613
|
output({ name: "EditorBrain", version: await cliVersion() });
|
|
193434
193614
|
return;
|
|
193435
193615
|
}
|
|
193436
|
-
if (args.flags["dry-run"] && !["push", "pull", "update"].includes(command) && !(command === "onboarding" && ["apply", "sync"].includes(subcommand))) throw new CliError("INVALID_ARGUMENT", "--dry-run is supported by push, pull, update and onboarding apply/sync.", "Read editorbrain help.");
|
|
193616
|
+
if (args.flags["dry-run"] && !["push", "pull", "update"].includes(command) && !(command === "onboarding" && ["apply", "sync"].includes(subcommand)) && !(command === "styles" && ["push", "pull"].includes(subcommand))) throw new CliError("INVALID_ARGUMENT", "--dry-run is supported by push, pull, update, styles push/pull and onboarding apply/sync.", "Read editorbrain help.");
|
|
193437
193617
|
if (args.flags.offline && command !== "doctor" && !(command === "production" && ["verify", "mix-events"].includes(subcommand))) throw new CliError("INVALID_ARGUMENT", "--offline is supported by doctor, production verify and project-scoped mix-events.", "Read editorbrain help.");
|
|
193438
193618
|
if (!command || command === "help" || args.flags.help) {
|
|
193439
193619
|
process.stdout.write(HELP);
|
|
@@ -193925,9 +194105,9 @@ async function main() {
|
|
|
193925
194105
|
throw new Error("Use styles component extract --style ID --id ID --scene scene.html [--bindings file.json], or prepare --parameters file.json --out new.html");
|
|
193926
194106
|
}
|
|
193927
194107
|
if (subcommand === "captions" && argument === "prepare") {
|
|
193928
|
-
valid(3, ["project", "file", "out"]);
|
|
193929
|
-
if (!str(args, "project") || !str(args, "file") || !str(args, "out")) throw new Error("Use styles captions prepare --project ID --file cues.json --out new.html");
|
|
193930
|
-
output(await prepareCaptions(directory, str(args, "project"), str(args, "file"), str(args, "out")));
|
|
194108
|
+
valid(3, ["project", "style", "file", "out"]);
|
|
194109
|
+
if (!str(args, "project") || !str(args, "file") || !str(args, "out")) throw new Error("Use styles captions prepare --project ID [--style ID] --file cues.json --out new.html");
|
|
194110
|
+
output(await prepareCaptions(directory, str(args, "project"), str(args, "file"), str(args, "out"), str(args, "style")));
|
|
193931
194111
|
return;
|
|
193932
194112
|
}
|
|
193933
194113
|
valid(command === "media" ? 4 : 3, ["style", "file"]);
|
|
@@ -193978,7 +194158,7 @@ async function main() {
|
|
|
193978
194158
|
const outRoot = await ensureRoot(resolve12(str(args, "dir") ?? process.cwd(), destination), true);
|
|
193979
194159
|
for (const path of Object.keys(result2.files)) {
|
|
193980
194160
|
try {
|
|
193981
|
-
await
|
|
194161
|
+
await lstat16(await checkedPath(outRoot, path, false));
|
|
193982
194162
|
throw new Error(`Refusing to replace existing proposal: ${path}`);
|
|
193983
194163
|
} catch (error) {
|
|
193984
194164
|
if (error.code !== "ENOENT") throw error;
|
|
@@ -194135,7 +194315,7 @@ async function main() {
|
|
|
194135
194315
|
}
|
|
194136
194316
|
if (subcommand === "upload" && argument) {
|
|
194137
194317
|
const target = resolve12(str(args, "dir") ?? process.cwd(), argument);
|
|
194138
|
-
const handle = await
|
|
194318
|
+
const handle = await open13(target, constants12.O_RDONLY | constants12.O_NOFOLLOW);
|
|
194139
194319
|
let bytes;
|
|
194140
194320
|
try {
|
|
194141
194321
|
const info = await handle.stat();
|
|
@@ -194223,7 +194403,7 @@ async function main() {
|
|
|
194223
194403
|
if (command === "search" && subcommand === "brief") {
|
|
194224
194404
|
const path = str(args, "file");
|
|
194225
194405
|
if (!path) throw new Error("Provide --file with the editorial brief JSON after inspecting the actual material.");
|
|
194226
|
-
const handle = await
|
|
194406
|
+
const handle = await open13(resolve12(path), constants12.O_RDONLY | constants12.O_NOFOLLOW);
|
|
194227
194407
|
let brief;
|
|
194228
194408
|
try {
|
|
194229
194409
|
const stat = await handle.stat();
|
|
@@ -194245,7 +194425,7 @@ async function main() {
|
|
|
194245
194425
|
const scriptPath = str(args, "script"), videoPath = str(args, "video");
|
|
194246
194426
|
let script, assetId = str(args, "asset");
|
|
194247
194427
|
const readInput = async (path, max) => {
|
|
194248
|
-
const handle = await
|
|
194428
|
+
const handle = await open13(resolve12(path), constants12.O_RDONLY | constants12.O_NOFOLLOW);
|
|
194249
194429
|
try {
|
|
194250
194430
|
const stat = await handle.stat();
|
|
194251
194431
|
if (!stat.isFile() || stat.size < 1 || stat.size > max) throw new Error(`Input must be a regular file of at most ${max} bytes.`);
|