rushes 0.5.0 → 0.5.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rushes",
3
3
  "description": "A local review desk for video made with AI agents: timecoded notes, script edits and audio picks your agent reads and acts on.",
4
- "version": "0.5.0",
4
+ "version": "0.5.1",
5
5
  "author": { "name": "Red Morley Hewitt" },
6
6
  "homepage": "https://github.com/iamredmh/rushes",
7
7
  "repository": "https://github.com/iamredmh/rushes",
package/AGENTS.md CHANGED
@@ -68,7 +68,7 @@ When the user wants a new video ("start a new film", "make a launch video", "a n
68
68
  A folder of clips lands in the window from the right.
69
69
  ```
70
70
 
71
- `Length` is planned seconds (they become the cut's shot starts), `Still` is a project-relative picture (png, jpg, webp, gif or avif), best saved under `storyboard/`, and `Direction` is the user's line. Make a still for each shot if your tools can; the Storyboard page shows any still the file names, registered or not. The user reads and approves each shot in Planning › Storyboard, and Rushes sets `Status: approved` itself: never set or change a shot's status yourself. When they press **Send to agent** there, read `storyboard.md` again, keep their wording, and update the still if what happens has changed.
71
+ `Length` is planned seconds (they become the cut's shot starts), `Still` is a project-relative picture (png, jpg, webp or gif), best saved under `storyboard/`, and `Direction` is the user's line. Make a still for each shot if your tools can; the Storyboard page shows any still the file names, registered or not. The user reads and approves each shot in Planning › Storyboard, and Rushes sets `Status: approved` itself: never set or change a shot's status yourself. When they press **Send to agent** there, read `storyboard.md` again, keep their wording, and update the still if what happens has changed.
72
72
  6. **Build only when all three are approved** (`rushes_status` reports `build`: `ready`, and what it is `waitingOn`). If the user says "just build it", do. Build in whatever tool suits the film, and name each scene after its planned shot. Then register the cut with `rushes_add_version`: a film's first cut starts with the storyboard's shots by itself (each `start` the running total of the lengths before it), so call `rushes_set_shots` only when the real timings differ (a cut brought in with `rushes_scan` or `rushes_bring_in` does not: send its shots with `rushes_set_shots`). A film with no script has nothing to wait on there: the script is only waited on when the film has one. While the plan isn't all approved the reply carries `planWarning`: a nudge, not a refusal.
73
73
 
74
74
  The brief and the storyboard are Markdown files the user reads and approves on their own pages under Planning. Use the same file names so the next session finds them.
package/dist/cli/main.js CHANGED
@@ -340,17 +340,19 @@ export async function main(argv, io) {
340
340
  case "status": {
341
341
  const root = rest[0] ? resolve(io.cwd, rest[0]) : dir;
342
342
  const { tabs, brief, storyboard, build } = await (await ensureServer(root, io.ensure)).get("/api/tabs");
343
+ // The second column starts in the same place on every line: as wide as the longest label shown.
344
+ const w = storyboard?.exists ? "storyboard".length : 8;
343
345
  for (const t of tabs) {
344
- io.out(`${t.stage.padEnd(8)} ${t.unlocked ? "open " : "locked"} ${t.todo ? `${t.todo} to do` : ""}`.trimEnd());
346
+ io.out(`${t.stage.padEnd(w)} ${t.unlocked ? "open " : "locked"} ${t.todo ? `${t.todo} to do` : ""}`.trimEnd());
345
347
  }
346
348
  // §24 step 2: brief.md, when there is one: its status and how many sections the user has changed.
347
349
  if (brief?.exists)
348
- io.out(`${"brief".padEnd(8)} ${String(brief.status ?? "draft").padEnd(6)} ${brief.changed ? `${brief.changed} changed` : ""}`.trimEnd());
350
+ io.out(`${"brief".padEnd(w)} ${String(brief.status ?? "draft").padEnd(6)} ${brief.changed ? `${brief.changed} changed` : ""}`.trimEnd());
349
351
  // §24.12: storyboard.md, and whether the plan is approved, once planning has begun.
350
352
  if (storyboard?.exists)
351
- io.out(`storyboard ${storyboard.approved} of ${storyboard.shots} approved${storyboard.changed ? `, ${storyboard.changed} changed` : ""}`);
353
+ io.out(`${"storyboard".padEnd(w)} ${storyboard.approved} of ${storyboard.shots} approved${storyboard.changed ? `, ${storyboard.changed} changed` : ""}`);
352
354
  if (build?.started)
353
- io.out(`${"build".padEnd(8)} ${build.ready ? "ready" : `waiting on ${build.waitingOn.join(", ")}`}`);
355
+ io.out(`${"build".padEnd(w)} ${build.ready ? "ready" : `waiting on ${build.waitingOn.join(", ")}`}`);
354
356
  return 0;
355
357
  }
356
358
  case "doctor": {
@@ -4,7 +4,8 @@ import { createHash } from "node:crypto";
4
4
  // the file (the preamble, other sections, the user's own formatting) is left exactly as it was.
5
5
  /** The brief's file name, in the project folder's root. */
6
6
  export const BRIEF_FILE = "brief.md";
7
- const STATUS_LINE = /^Status:[ \t]*(draft|approved)[ \t]*$/i;
7
+ /** `Status: approved`, and the same in bold or italics (`**Status:** approved`): an agent often writes the line that way. */
8
+ const STATUS_LINE = /^[*_]{0,2}Status[*_]{0,2}:[*_]{0,2}[ \t]*(draft|approved)[ \t]*$/i;
8
9
  /** A short fingerprint of the file's text: what a page sends back to prove it saw the current file. */
9
10
  export function hashText(text) {
10
11
  return createHash("sha1").update(text).digest("hex").slice(0, 12);
@@ -8,7 +8,7 @@ export const STORYBOARD_FILE = "storyboard.md";
8
8
  const HEADING = /^Shot\s+(\d+)\s*[·:–—-]\s*(.+?)\s*$/i;
9
9
  const META = /^(Tag|Length|Still|Status|Direction):[ \t]*(.*?)[ \t]*$/i;
10
10
  /** What a still may be: pictures a browser shows inline. */
11
- const IMAGE = /\.(png|jpe?g|webp|gif|avif)$/i;
11
+ const IMAGE = /\.(png|jpe?g|webp|gif)$/i;
12
12
  /** A still's path as the page may use it: relative, inside the project, a picture. Anything else is no still. */
13
13
  export function stillPath(raw) {
14
14
  const p = raw.trim().replace(/^\.\//, "");
@@ -97,8 +97,12 @@ export function editShot(text, index, heading, edit) {
97
97
  */
98
98
  export function cutShots(shots) {
99
99
  let start = 0;
100
- return shots.map((s) => {
101
- const out = { name: s.name.slice(0, 80), start: Math.round(start * 1000) / 1000, tag: s.tag.slice(0, 24) };
100
+ let last = -1;
101
+ // A shot list holds at most 200 shots, and no two may start together: lengths too small to tell apart still step by a millisecond.
102
+ return shots.slice(0, 200).map((s) => {
103
+ const at = Math.max(Math.round(start * 1000) / 1000, last + 0.001);
104
+ const out = { name: s.name.slice(0, 80), start: Math.round(at * 1000) / 1000, tag: s.tag.slice(0, 24) };
105
+ last = out.start;
102
106
  start += s.length ?? 1;
103
107
  return out;
104
108
  });
@@ -31,7 +31,7 @@ import { buildState, planWarning } from "../core/plan.js";
31
31
  import { broughtInEvent, cutEvent, fileEvent, formatEvent, lineEvent, lockEvent, notesSentEvent, picksEvent, repliesEvent, scriptEvent, takeEvent, variantEvent, } from "../core/logEvents.js";
32
32
  import { LOG_AREAS, LOG_MAX, changeLogFileName, logText, recentChanges } from "../core/logText.js";
33
33
  import { defaultRunner, measureMix } from "./loudness.js";
34
- export const VERSION = "0.5.0";
34
+ export const VERSION = "0.5.1";
35
35
  async function body(c, schema) {
36
36
  let json;
37
37
  try {
@@ -1,7 +1,8 @@
1
- import { lstat, readFile, rename, writeFile } from "node:fs/promises";
1
+ import { constants } from "node:fs";
2
+ import { lstat, open, rename, writeFile } from "node:fs/promises";
2
3
  import { join } from "node:path";
3
4
  import { hashText } from "../core/brief.js";
4
- import { NotFoundError } from "../core/errors.js";
5
+ import { InvalidError, NotFoundError } from "../core/errors.js";
5
6
  // §24 steps 2 and 3: brief.md and storyboard.md are files of record. The agent writes them with its own tools; the
6
7
  // dashboard writes them through a service built on this. Rushes keeps only `.rushes/<key>.json` for each: the agent's
7
8
  // last text (the "Current" column) and the hash it last saw, so it can tell the dashboard's writes from anyone else's.
@@ -32,20 +33,50 @@ export class RecordFile {
32
33
  this.queue = next;
33
34
  return next;
34
35
  }
35
- /** The file's text, or null when there is none: missing, a folder, a link (never followed), or too big to be one. */
36
- async readText() {
36
+ /**
37
+ * The file's bytes, or null when there is none: missing, a folder, a link (never followed), or too big to be one.
38
+ * The file is opened without following a link and read through that handle, so a link swapped in after the check
39
+ * is refused too, not read.
40
+ */
41
+ async readBytes() {
37
42
  try {
38
- const st = await lstat(this.path);
39
- if (!st.isFile() || st.size > MAX_RECORD_BYTES)
43
+ if (!(await lstat(this.path)).isFile())
40
44
  return null;
41
- return await readFile(this.path, "utf8");
45
+ const fh = await open(this.path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
46
+ try {
47
+ const st = await fh.stat();
48
+ if (!st.isFile() || st.size > MAX_RECORD_BYTES)
49
+ return null;
50
+ return await fh.readFile();
51
+ }
52
+ finally {
53
+ await fh.close();
54
+ }
42
55
  }
43
56
  catch (e) {
44
- if (["ENOENT", "ENOTDIR", "EISDIR", "ELOOP"].includes(e.code ?? ""))
57
+ if (["ENOENT", "ENOTDIR", "EISDIR", "ELOOP", "EMLINK"].includes(e.code ?? ""))
45
58
  return null;
46
59
  throw e;
47
60
  }
48
61
  }
62
+ /** The file's text, or null when there is none (see readBytes). Bytes that are not UTF-8 are shown as replacement characters. */
63
+ async readText() {
64
+ const bytes = await this.readBytes();
65
+ return bytes === null ? null : bytes.toString("utf8");
66
+ }
67
+ /** Whether the file is valid UTF-8, so that a save cannot change bytes the user never touched. */
68
+ async isUtf8() {
69
+ const bytes = await this.readBytes();
70
+ if (bytes === null)
71
+ return true;
72
+ try {
73
+ new TextDecoder("utf-8", { fatal: true }).decode(bytes);
74
+ return true;
75
+ }
76
+ catch {
77
+ return false;
78
+ }
79
+ }
49
80
  /** Notices a change made by anyone but the dashboard: that text becomes the agent's version. */
50
81
  sync() {
51
82
  return this.run(async () => {
@@ -62,6 +93,10 @@ export class RecordFile {
62
93
  });
63
94
  }
64
95
  async write(prev, next) {
96
+ // One more look just before the file is replaced, so a write that landed since the check is refused, not overwritten.
97
+ const again = await this.readText();
98
+ if (again === null || hashText(again) !== hashText(prev))
99
+ throw this.changed();
65
100
  const tmp = join(this.store.root, `.${this.file}.${process.pid}.${Date.now()}.tmp`);
66
101
  await writeFile(tmp, next, "utf8");
67
102
  await rename(tmp, this.path);
@@ -81,6 +116,8 @@ export class RecordFile {
81
116
  throw new NotFoundError(this.file === "brief.md" ? "Brief" : "Storyboard", this.file);
82
117
  if (hashText(text) !== expectHash)
83
118
  throw this.changed();
119
+ if (!(await this.isUtf8()))
120
+ throw new InvalidError(`${this.file} isn't UTF-8 text, so Rushes won't save over it. Edit it in your editor.`);
84
121
  return text;
85
122
  }
86
123
  /** Looks for changes made outside the dashboard every `pollMs`, and once at the start. Returns a stop function. */
@@ -93,8 +130,16 @@ export class RecordFile {
93
130
  const st = await lstat(this.path).catch(() => null);
94
131
  const sig = st ? `${st.mtimeMs}:${st.size}:${st.ino}` : "";
95
132
  if (sig !== last) {
133
+ const hadFile = last !== null && last !== "";
96
134
  last = sig;
97
135
  await this.sync();
136
+ // A file that is deleted, or becomes a folder or a link, changes nothing in `.rushes/` by itself. Forget what was
137
+ // seen, which announces it, and which makes the same text coming back (git stash pop, say) a change to announce too.
138
+ if (hadFile && (await this.run(() => this.readText())) === null) {
139
+ await this.store.update(this.key, (d) => {
140
+ d.seen = "";
141
+ });
142
+ }
98
143
  }
99
144
  }
100
145
  catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rushes",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "A local review desk for video made with AI agents: timecoded notes, script edits and audio picks your agent can read and act on.",
5
5
  "keywords": [
6
6
  "video",
@@ -30,7 +30,7 @@ When the user wants a new video ("start a new film", "make a launch video", "a n
30
30
  A folder of clips lands in the window from the right.
31
31
  ```
32
32
 
33
- `Length` is planned seconds (they become the cut's shot starts), `Still` is a project-relative picture (png, jpg, webp, gif or avif), best saved under `storyboard/`, and `Direction` is the user's line. Make a still for each shot if your tools can; the Storyboard page shows any still the file names, registered or not. The user reads and approves each shot in Planning › Storyboard, and Rushes sets `Status: approved` itself: never set or change a shot's status yourself. When they press **Send to agent** there, read `storyboard.md` again, keep their wording, and update the still if what happens has changed.
33
+ `Length` is planned seconds (they become the cut's shot starts), `Still` is a project-relative picture (png, jpg, webp or gif), best saved under `storyboard/`, and `Direction` is the user's line. Make a still for each shot if your tools can; the Storyboard page shows any still the file names, registered or not. The user reads and approves each shot in Planning › Storyboard, and Rushes sets `Status: approved` itself: never set or change a shot's status yourself. When they press **Send to agent** there, read `storyboard.md` again, keep their wording, and update the still if what happens has changed.
34
34
  6. **Build only when all three are approved** (`rushes_status` reports `build`: `ready`, and what it is `waitingOn`). If the user says "just build it", do. Build in whatever tool suits the film, and name each scene after its planned shot. Then register the cut with `rushes_add_version`: a film's first cut starts with the storyboard's shots by itself (each `start` the running total of the lengths before it), so call `rushes_set_shots` only when the real timings differ (a cut brought in with `rushes_scan` or `rushes_bring_in` does not: send its shots with `rushes_set_shots`). A film with no script has nothing to wait on there: the script is only waited on when the film has one. While the plan isn't all approved the reply carries `planWarning`: a nudge, not a refusal.
35
35
 
36
36
  The brief and the storyboard are Markdown files the user reads and approves on their own pages under Planning.