rushes 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.11.0",
4
+ "version": "0.12.0",
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
@@ -55,7 +55,7 @@ When the user wants a new video ("start a new film", "make a launch video", "a n
55
55
  2. **Interview, briefly.** Ask at most three questions, and only ones whose answer changes the film: length and formats, who it is for, tone. Give each a recommended answer with its trade-off ("30 seconds fits a feed; 60 leaves room for the demo"). Never send a list of ten.
56
56
  3. **Write `brief.md`.** Its sections, in order, are Title, Purpose, Audience, Length and formats, Tone, Include and avoid, Built with, Open questions and References. Fill every one, keep the `Status: draft` line, and tell the user to open Plan › Brief in Rushes, change any section and press **Approve brief**. Rushes then sets `Status: approved` in the file itself. Never approve it yourself or change that line, and if they say it's approved in chat while the file still says `draft`, ask them to press Approve. When they press **Send** on the Brief page, read `brief.md` again and keep their wording: a section they changed shows "Edited by you" with your last version struck through beneath it, so read the file before you rewrite it.
57
57
  4. **Script.** Add it with `rushes_set_script`. The user edits and approves each section in Plan › Script. Read `rushes_get_script` and wait until every section is `approved`.
58
- 5. **Storyboard.** Write `storyboard.md` in the project root: a `# Storyboard: <film>` title, then one section per shot, in this shape:
58
+ 5. **Storyboard.** Write the film's storyboard (`storyboard.md` in the project root for the first film, `films/<film-id>/storyboard.md` for any other: see "More than one film" below): a `# Storyboard: <film>` title, then one section per shot, in this shape:
59
59
 
60
60
  ```markdown
61
61
  ## Shot 02 · Drop a folder
@@ -73,6 +73,16 @@ When the user wants a new video ("start a new film", "make a launch video", "a n
73
73
 
74
74
  The brief and the storyboard are Markdown files the user reads and approves on their own pages under Plan. Use the same file names so the next session finds them.
75
75
 
76
+ ### More than one film
77
+
78
+ A project can hold several films (each film is a `video`). Everything on the desk belongs to a film, and the user works on one film at a time: with a film selected, every tab shows only that film's material. Each film has its own script, brief and storyboard:
79
+
80
+ - **Brief and storyboard:** the project's first film keeps `brief.md` and `storyboard.md` at the project root. Every other film's are `films/<film-id>/brief.md` and `films/<film-id>/storyboard.md`. `rushes_status` gives every film's paths in `plans` (by film id); write each film's in its own place, and never put one film's shots in another's file. A film's first cut starts with its own storyboard's shots.
81
+ - **Script:** `rushes_set_script` and `rushes_get_script` take `film`.
82
+ - **Tools that read or write a film's material** (`rushes_status`, `rushes_set_script`, `rushes_get_script`, `rushes_add_take`, `rushes_list_notes`, `rushes_get_log`, `rushes_list_assets`) take `film`: the film's id or name. With one film you may leave it out; with several, leaving it out is an error that lists the films.
83
+ - **Visuals** are the project's, not a film's: they show on every film as shared.
84
+ - Nothing is on no film: a note, take or file that names none is the first film's.
85
+
76
86
  ## Picking up a film that's underway
77
87
 
78
88
  When the user asks to open or review a film they started in the chat, or the project already has files but no `brief.md`, don't make them start again. Rebuild the plan from what you have, then say what you did.
@@ -115,10 +125,10 @@ The user can shelve a film they have set aside (**Shelve film** in the dashboard
115
125
  - A VO script: `rushes_set_script` with sections `{start, end, current}` in seconds. It merges by `id`: send only the sections you changed, with their ids, plus any new ones without an id. Sections you leave out are kept, with their takes. Pass `replace: true` only when you mean to replace the whole script. `rushes_get_script` reads the whole script back.
116
126
  - A voice read: `rushes_add_variant` with `stage: "voice"`, `video` (the film it is for) and `round` (the round's name, e.g. "Round 2 · Gerald, tone" — reads in one round are compared side by side; a new direction gets a new round, a small fix to a marked word can stay in the current one). Say in `description` what the read is, or what changed from the one it's based on. `rushes_add_take` stays in the file format and API for compatibility only; voiceover work doesn't use it.
117
127
  - Music beds or SFX passes: `rushes_add_variant` with `stage` `music` or `sfx`, `video`, and `round` as for a voice read (each new batch of beds or passes is a round, e.g. "Round 2 · softer middle"). Give it `meta: {description: "..."}` (and `bpm`, `key` or `lufs` when you know them), shown in its details: the tooltip on its name in the tab's list of takes and the line its details button opens; SFX passes also take `cues` (`{name, t, file?}`: `t` in seconds, and `file` the sample you placed there, an audio file, optional), labelled on the waveform. Give a sound the same name every time it comes back (`thud`, not `thud 2`): the Effects tab groups cues by name into layers, one per sound, and shows a cue's `file` on its card, where the user can play that sample on its own.
118
- - Every voice read, music bed and SFX pass belongs to one film or several: pass its `video` (an id or name, or a list of them when one bed is fitted to several films) to `rushes_add_variant`, and the Voice, Music and Effects tabs (and the Timeline) list it only on those films. In a project with more than one film, one without a `video` is on no film: it waits, folded, under "Not on this film" on each film's tab (with the ones on other films) until someone puts it on one. `rushes_set_films` (`lane`, `variant`, `videos`) moves an existing one; the user does the same from the **Films** button on its card. `rushes_bring_in` and `rushes_open` give the files they bring in the `film` you name (or, for the files they match to the newest cut, that cut's film). Put a take only on the films it was fitted to: a read timed to one film's cut is that film's alone, even when another film shares its script (Red, 16 Nov 2026: earlier reads listed on a second film read as clutter from the wrong film). When a new cut changes a film's length or timing, fit its bed and effects to the new cut and add them as new takes on that film; until then, tell the user the bed in use was made for an older cut.
128
+ - Every voice read, music bed and SFX pass belongs to one film or several: pass its `video` (an id or name, or a list of them when one bed is fitted to several films) to `rushes_add_variant`, and the Voice, Music and Effects tabs (and the Timeline) list it only on those films. In a project with more than one film, one without a `video` whose film can't be told from its names goes on the first film (the reply carries a `warning`): nothing is on no film. The ones on other films wait, folded, under "Not on this film" on each film's tab. `rushes_set_films` (`lane`, `variant`, `videos`) moves an existing one; the user does the same from the **Films** button on its card. `rushes_bring_in` and `rushes_open` give the files they bring in the `film` you name (or, for the files they match to the newest cut, that cut's film). Put a take only on the films it was fitted to: a read timed to one film's cut is that film's alone, even when another film shares its script (Red, 16 Nov 2026: earlier reads listed on a second film read as clutter from the wrong film). When a new cut changes a film's length or timing, fit its bed and effects to the new cut and add them as new takes on that film; until then, tell the user the bed in use was made for an older cut.
119
129
  - The storyboard's shots, once you have the first cut: `rushes_set_shots` with `video`, optional `version` (defaults to the newest) and `shots` as `{start, name, tag?}`. Send new timings whenever a later cut moves them.
120
130
  2. **Open it for the user:** `rushes_open`. It also looks through the project folder and brings in the files that go with the cut (next section). Each project's dashboard lives at its own address, `/p/<id>/` — safe to run more than one project at once. A tab unlocks as soon as it has something in it.
121
- 3. **Wait for feedback.** The user presses **Send**, at the foot of the notes panel, which saves a batch and gives them a prompt to paste to you. With **Send to AI** on, Rushes starts the user's own Claude Code or Codex with that prompt instead, and you may be that agent; then any note you leave with neither a done reply nor a question on it goes back to the user's to do when your turn ends. Wherever they press it, the batch holds every open note from every tab and every film in play, plus any changed script sections; its `stage` is the tab when everything came from one, or `null` when it spans tabs. Each note carries its own `stage` and `video`: fix each one on its own tab and film. Call `rushes_get_batch` to read the latest batch, its notes and any changed script sections. When the brief or the storyboard changed too, the user gives you a line about each: at the end of the prompt they paste or, with **Send to AI** on, in a separate message they paste to you themselves, since those lines are not handed over with the batch yet.
131
+ 3. **Wait for feedback.** The user presses **Send**, at the foot of the notes panel, which saves a batch and gives them a prompt to paste to you. With **Send to AI** on, Rushes starts the user's own Claude Code or Codex with that prompt instead, and you may be that agent; then any note you leave with neither a done reply nor a question on it goes back to the user's to do when your turn ends. What you may do without asking is the user's choice, one of four rows in Rushes's agent menu: **Manual** (every action asks the user in Rushes), **Accept edits** (file edits inside the project go through; commands ask unless an Always rule covers them), **Auto** (your own safety review decides, and Rushes sees only what you ask) or **Bypass** (nothing asks). Only the user sets it, in the menu; never try to change it, and never write the user's rules files under `~/.config/rushes/`. Under every row, leave `.rushes/` and `.git/` alone except through the Rushes tools. A batch is about one film: the film the user had selected when they pressed Send. It holds every open note from every tab on that film (plus any on the shared Visuals), and that film's changed script sections; its `stage` is the tab when everything came from one, or `null` when it spans tabs. `rushes_get_batch` names the batch's `film`: pass it to every tool that asks for one while you work the batch. Each note carries its own `stage` and `video`: fix each one on its own tab. Call `rushes_get_batch` to read the latest batch, its notes and any changed script sections. When the brief or the storyboard changed too, the user gives you a line about each: at the end of the prompt they paste or, with **Send to AI** on, in a separate message they paste to you themselves, since those lines are not handed over with the batch yet.
122
132
  4. **Fix each note.** Before you start on a note, call `rushes_working_on` with its `note` id and what you are doing in a few plain words (`doing`, 200 characters at most, e.g. "Moving the title up"): the user sees it on the note while you work. It is only for a note that was sent to you; any other is refused (`note_not_sent`). It shows only while Rushes is running you on a batch or an answer; otherwise (the user pasted the prompt to you) it is accepted and changes nothing. A note has `stage`, `scope` (`point`, `range` or `whole` — on every tab, a voice read included: a voice range note is about that stretch of the read), `t`, `tOut`, `on` (the lane, variant, take, cue or section it's about), `text`, and optionally `box` (normalised 0 to 1), `grab` (a PNG path in `screenshots/`; older notes may point to `.rushes/grabs/`), `shot` (the shot it falls in, `{n, name}`, worked out by the server from the version's shots — not yours to set) and, on Picture, `format` (`null` when the note is for every format, or a format id such as `"9x16"` when it's for that shape only). When a note's `format` is not null, fix only that format and leave the others alone; an all-format note is for every shape, so fix each and say in `reply` which formats you fixed. `rushes_list_notes` takes `format` (an id such as `9x16`, or its label `9:16`: that format's Picture notes plus the all-format ones) and `onlyThisFormat: true` (only that format's). On an audio stage, `on` is `"<laneId>/<variantId>"` for a music bed, SFX pass or voice read (the lane and variant ids `rushes_add_variant` returns) — for a voice read the lane id is the round's slugged name, so `on` names the round and the read together — or `"<laneId>/<variantId>:<cueId>"` for an SFX cue. On a mix note (stage `mix`, made on the Timeline tab) it's `null` for the whole mix, `"vo"` for the voice (the newest round with a pick), or `"<laneId>/<variantId>"` for the music or the effects. Older notes may carry a bare variant id, `"vo"` on a voice note itself, a section id, `"<sectionId>:<takeId>"` for a take, `"<variantId>:<cueId>"` or a bare cue id; Rushes still lists these with a sensible label, but none of them name a read any more. A music, sfx or mix note can also carry `marks` — short feedback like `Fall` (bring the level down over the range) or `Quieter 3 dB` (3 dB lower over the range). `rushes_list_notes`, `rushes_get_batch` and exported notes all show them. Marks are the user's, like a note's text and times — you read and act on them, you don't set them. Voice notes carry no marks: a voice note is about the whole read (`scope: "whole"`), a point in it (`t`) or a range of it (`t` to `tOut`: replace or fix just that stretch), and its `text` says what to change. Older voice notes may begin with a word such as `Speaker`, `Pacing`, `Tone`, `Fix this` or `Keep this`, from quick-start buttons the dashboard no longer has.
123
133
  5. **Register the new cut** with `rushes_add_version`, with a short `label` and the detail in `note`. If the video is locked, the reply carries `warning: "Picture is locked at vN"`; the version is still added.
124
134
  6. **Reply to every note** in one `rushes_reply` call. For each, set `status: "done"`, a one-line `reply`, `fixT` (when the fix is visible in the new cut, in seconds) and `fixVersion`. If you didn't fix a note, leave it `todo` and say why in `reply`. Every note comes back with its `state`: `todo` (the user's, not sent yet), `sent` (in a batch the user sent: yours, and shown to them as "With your agent") or `done`. `rushes_list_notes` with `state: "sent"` lists everything you have been given and not finished, whichever batch it came in. A done note the user opens again is `todo` and goes out in their next batch.
package/README.md CHANGED
@@ -93,6 +93,8 @@ Rewrite a line, add a direction, flag it or approve it. Every line sits in a fie
93
93
 
94
94
  Plan is one workspace, so planning never crowds the review. A switch at its top opens **Brief**, **Script** and **Storyboard**, each with a tick once it is approved and a dot while it has edits you haven't sent; key `1` comes back to the page you used last. **Brief** shows `brief.md` in your project folder, one field per section. Edit a section and Rushes writes it into the file; press **Approve brief** and it sets the file's status line. If your agent rewrites `brief.md`, the page follows without a reload. **Storyboard** works the same way over `storyboard.md`: a row per shot with its still (click it to enlarge), its description, a direction line and a tick to approve it. A line at the foot of each page counts what is approved and what you have edited. When the brief, every script line (if the film has a script) and every shot are approved, the Plan tab in the top bar shows a green check and the row above the page says **Ready to build**, with a prompt to copy. Rushes never stops your agent building before then: it only says what is still waiting.
95
95
 
96
+ In a project with several films, each film has its own brief, script and storyboard, and every tab shows only the film selected in the top bar (it is in the address, `?film=`, so a reload or a shared link keeps it). The first film keeps `brief.md` and `storyboard.md` at the project root; every other film's are in `films/<film-id>/`. Visuals are the one exception: they are campaign material, so they show on every film, marked **Shared**. Notes, takes and files from before a project had a second film are moved once to its first film.
97
+
96
98
  ### Voice: compare reads, round by round
97
99
 
98
100
  <img src="docs/assets/screens/voiceover.jpg" alt="The Voice tab. Under the monitor, Round 2's read, Voice A slower, is In use, and Earlier lists Round 1's two reads, Voice A and Voice B, each with its waveform and description. In the notes panel, the note on Round 1's Voice A has a green tick and the agent's reply: Round 2 is Voice A at a slower pace." width="880">
@@ -138,7 +140,7 @@ Rushes keeps a running log of what happened, in the **Activity** tab of the note
138
140
  ## Why Rushes
139
141
 
140
142
  - **Notes your agent can act on.** Each one carries its stage, a timecode or range, an optional box on the frame, a frame grab, and the shot it falls in.
141
- - **Everything in one batch.** **Send** sends every open note from every tab and every film, wherever you press it, so nothing waits behind.
143
+ - **Everything in one batch.** **Send** sends every open note from every tab of the film you are on, wherever you press it, so nothing waits behind. In a project with several films, a batch is about one film.
142
144
  - **Versions keep their history.** Notes follow the work from cut to cut, and you can lock picture when it's done.
143
145
  - **Local, with no sign-up.** No account, no API key, nothing uploaded. It runs on your machine.
144
146
  - **Works with the agent you already use.** One MCP server for Claude Code, Codex, Cursor, Claude Desktop and Gemini CLI, a plugin and skill for Claude Code, and a command line for anything else.
@@ -297,7 +299,7 @@ Rushes never sees a password or key, and never signs you in. When an agent isn't
297
299
 
298
300
  **The switch.** Above **Send**, a row reads **Send to AI** with the agent's name and a switch. On, Send files the batch as always and hands it to the agent: what it is doing shows on each note and in Activity, its questions arrive as replies on the note, and your answer goes back to it. Off, Send copies the prompt, as before. Under Send, one line says what the agent may do: "Edits files in this project, asks before commands" or "Asks before everything", and "next Send continues the conversation" when there is one to continue.
299
301
 
300
- The first time you press Send, a sheet asks "Who should get these notes?" (an agent, or copy a prompt as before), then "What may <agent> do without asking?".
302
+ The first time you press Send, a sheet asks "Who should get these notes?" (an agent, or copy a prompt as before), then "What may <agent> do without asking?". It asks once per Mac, not once per project: your answer is kept as the default, and every new project starts from it, so Send goes straight to your agent there. The last choice you make in the sheet, the agent's menu or the switch turned on is the default; turning Send to AI off on one project leaves it as it is.
301
303
 
302
304
  If the agent fails to start, the notes go back in to do and nothing is copied. If Send to AI is not set up, not signed in or not installed, Send opens the copy dialog with the prompt and says why, with **Set up**: once you finish the sheet it opens, the notes in that dialog go to the agent. A note says it is with the agent by name only while the agent has it. Lines about the brief and the storyboard are not handed to the agent yet: when they changed, Send hands over the notes and opens **Message for your agent** with those lines, saying the agent has the notes but not these lines, for you to copy to it yourself.
303
305
 
@@ -305,20 +307,24 @@ The agent's name opens a menu to choose another agent, **Start a fresh conversat
305
307
 
306
308
  **New cuts.** When the agent adds a version and nothing holds the picture, the desk switches to it and a toast says so, such as "v3 is in". When something does (a cut or a sound playing on any tab, a note or mark you are making, or a locked picture), the picture stays where it is: the toast offers the cut with **Show**, and the **Cut** menu shows a dot until you look. The agent only adds a version when the picture or sound changed, and it is asked to wait for its commands to finish before it replies, so a run does not leave work going in the background.
307
309
 
308
- **Permissions.** There are two levels:
310
+ **Permissions.** The agent's menu, and the sheet's second step, offer four rows, the same for Claude Code and Codex:
311
+
312
+ - **Manual** (always ask): every action asks.
313
+ - **Accept edits** (the default): the agent reads, edits, searches, moves and deletes files inside the project folder without asking. Commands, the network and anything outside the folder ask first, unless an Always rule covers them. The line under Send reads "Edits files in this project, asks before commands"; under Manual it reads "Asks before everything".
314
+ - **Auto** (the agent decides): the agent's own safety reviewer approves or refuses each step (Claude Code's auto mode, Codex's Auto review). Rushes sees only what the agent chooses to ask, and no longer guards `.rushes` and `.git`. If Claude Code's model can't run auto mode, Claude falls back to accepting edits and asking for commands, and Activity says so.
315
+ - **Bypass** (accepts everything): nothing asks and nothing is checked, `.rushes` and `.git` included. Picking it shows a one-line warning. It is never a default: a new project never starts in Bypass.
309
316
 
310
- - **Edit files in this project** (the default): the agent reads, edits, searches, moves and deletes files inside the project folder without asking. Commands, the network and anything outside the folder ask first.
311
- - **Ask me for everything**: every action asks.
317
+ A change of row applies from the next Send. A batch already running keeps the row it started in; the agent starts again (continuing the conversation) when the next Send needs another mode. Auto and Bypass are chosen only by you, in the menu or the sheet, never by anything in a project. Auto can be your default for new projects, like any row you pick; a brand-new Mac starts in Accept edits.
312
318
 
313
- Some folders and files in the project always ask, at either level and whatever "Always" rules you keep, even to read them: they hold settings, hooks or tokens. They are `.rushes/`, `.git/`, `.claude/`, `.codex/`, `.mcp.json`, `.vscode/` and `.idea/`. Moving or deleting the project folder itself always asks too.
319
+ Under Manual and Accept edits, some folders and files in the project always ask, whatever "Always" rules you keep, even to read them: they hold settings, hooks or tokens. They are `.rushes/`, `.git/`, `.claude/`, `.codex/`, `.mcp.json`, `.vscode/` and `.idea/`. Moving or deleting the project folder itself always asks too.
314
320
 
315
321
  An ask shows what the agent wants to do and the exact command, with **Allow once**, **Always** and **No**. It waits until you answer. It never turns into a yes by itself. When the agent asks, or ends a run with a question, and no Rushes tab is open, your Mac shows a notification saying the agent is waiting in this project.
316
322
 
317
323
  Rushes sees only what the agent asks it. The agent's own permission settings, such as allow rules in Claude Code's settings, can still approve actions without asking, and Rushes never sees those.
318
324
 
319
- With Codex, commands that write files or reach the network ask, but commands that only read, such as searches and listings, run without asking.
325
+ With Codex under Manual or Accept edits, commands that write files or reach the network ask, but commands that only read, such as searches and listings, run without asking.
320
326
 
321
- **"Always" rules.** **Always** keeps a rule for this project, so the same request runs without asking next time. The button names the rule, such as "Always for npx hyperframes here". The agent's menu lists the rules, and you can remove any of them. Always rules are kept in your user settings, outside the project, so the agent cannot change them. The permission level, the rules, whether you have answered the first-Send sheet and which agent you turned Send to AI on for are in `~/.config/rushes/agent-rules/` (or under `$XDG_CONFIG_HOME`), one file per project. That agent is set only when you turn Send to AI on, in the sheet, the agent's menu or the switch. Copy a prompt and switching off clear it, and changing what it may do leaves it as it is. `.rushes/agent.json` keeps the project's switch, its agent and the conversation to continue. Nothing secret. Send hands notes to an agent only when that switch is on and its agent is the one in your file. Otherwise Send to AI shows as off and Send copies the prompt, so a project folder from someone else, or anything that writes `agent.json`, can't start an agent you didn't choose. A project set up with an earlier build asks once more.
327
+ **"Always" rules.** **Always** keeps a rule for this project, so the same request runs without asking next time. The button names the rule, such as "Always for npx hyperframes here". The agent's menu lists the rules, and you can remove any of them. Always rules are kept in your user settings, outside the project, so the agent cannot change them. The permission level, the rules, whether you have answered the first-Send sheet and which agent you turned Send to AI on for are in `~/.config/rushes/agent-rules/` (or under `$XDG_CONFIG_HOME`), one file per project. That agent is set only when you turn Send to AI on, in the sheet, the agent's menu or the switch. Copy a prompt and switching off clear it, and changing what it may do leaves it as it is. `.rushes/agent.json` keeps the project's switch, its agent and the conversation to continue. Nothing secret. Send hands notes to an agent only when that switch is on and its agent is the one in your file. Otherwise Send to AI shows as off and Send copies the prompt, so a project folder from someone else, or anything that writes `agent.json`, can't start an agent you didn't choose. A project set up with an earlier build asks once more. The default for new projects is `~/.config/rushes/agent-defaults.json` (the agent and what it may do, never Always rules, which stay per project). It is yours, outside every project, so nothing in a project can set it.
322
328
 
323
329
  "Always" trusts one program and subcommand, such as `npx hyperframes`, `npm install` or `git commit`. Later commands that start with the same two words run without asking, whatever their other arguments. That trust covers whatever that program and subcommand can be told to run:
324
330
 
package/dist/cli/demo.js CHANGED
@@ -5,7 +5,7 @@ import { join, resolve } from "node:path";
5
5
  import { addVariant, addVersion, setShots, shotAt } from "../core/project.js";
6
6
  import { addNote } from "../core/notes.js";
7
7
  import { setInUse } from "../core/picks.js";
8
- import { setSections } from "../core/script.js";
8
+ import { filmScriptDraft, setSections } from "../core/script.js";
9
9
  import { toManifestPath } from "../core/paths.js";
10
10
  import { Store } from "../core/store.js";
11
11
  /** A `Runner` over `cmd`, via `child_process.spawn` with no shell. */
@@ -251,8 +251,9 @@ export async function makeDemo(dir, deps) {
251
251
  { id: "s3", start: 15, end: 22.5, current: "Notes, picks and a locked cut travel with the project, not a chat log." },
252
252
  { id: "s4", start: 22.5, end: 30, current: `${PRODUCT}: fewer rounds, and a cut everyone signed off on.` },
253
253
  ];
254
+ const filmsNow = await store.read("project");
254
255
  await store.update("script", (s) => {
255
- setSections(s, sections, { replace: true });
256
+ setSections(filmScriptDraft(s, filmsNow, videoId), sections, { replace: true });
256
257
  });
257
258
  // 3. Voice reads, two rounds: Round 1 compares two voices; Round 2 is one voice at a slower pace.
258
259
  const scriptText = sections.map((s) => s.current).join(" ");
package/dist/cli/main.js CHANGED
@@ -513,7 +513,9 @@ export async function main(argv, io) {
513
513
  // What an audio note is on (M4) and a Picture note's format (§21.4, R4), from the state.
514
514
  const state = notes.some((n) => n.stage !== "script" || n.on != null) ? await c.get("/api/state") : null;
515
515
  for (const n of notes) {
516
- const label = state ? onLabel(n, state) : null;
516
+ // §31.3: a note on the script names a line of its own film's script.
517
+ const own = n.video ? state?.films?.[n.video]?.script : undefined;
518
+ const label = state ? onLabel(n, own ? { ...state, script: own } : state) : null;
517
519
  const on = label ? `${stripControl(label)} ` : "";
518
520
  const tag = state ? formatTag(n, state.project?.videos ?? []) : null;
519
521
  const fmtCol = tag ? `${stripControl(tag)} ` : "";
@@ -173,9 +173,16 @@ export function canAlways(req, root) {
173
173
  return inProject(req, root);
174
174
  return kind !== "execute" || plainCommand(req.command ?? "");
175
175
  }
176
+ /**
177
+ * Whether an ask the agent sent goes through unasked. Manual asks for everything. Accept edits allows edits in the
178
+ * project and the Always rules. In Auto the agent's own reviewer has already passed what it didn't send, and what it does
179
+ * send is treated as under Accept edits. Bypass allows everything (§33): nothing is checked, not even .rushes and .git.
180
+ */
176
181
  export function decide(req, s, root) {
177
182
  if (s.permissions === "ask-all")
178
183
  return "ask";
184
+ if (s.permissions === "bypass")
185
+ return "allow";
179
186
  if (s.always.some((r) => matches(r, req, root)))
180
187
  return "allow";
181
188
  if (req.kind && PROJECT_KINDS.has(req.kind) && inProject(req, root))
@@ -1,5 +1,6 @@
1
1
  import { chipOrder, versionFormats } from "./formats.js";
2
2
  import { STAGES } from "./schema.js";
3
+ import { noteOnFilm } from "./films.js";
3
4
  import { EmptyBatchError } from "./errors.js";
4
5
  import { noteInPlay } from "./project.js";
5
6
  import { moveNote, noteState } from "./noteState.js";
@@ -16,13 +17,17 @@ const STAGE_NAMES = {
16
17
  };
17
18
  /**
18
19
  * Gather open, unsent items into a batch: to-do notes with no batch yet, and changed or flagged
19
- * script sections. With a stage, only that tab's; with none (Send), every tab's, on every
20
- * film in play. A batch whose items all come from one tab is that tab's batch; one that spans tabs
21
- * has no stage.
20
+ * script sections. With a stage, only that tab's; with none (Send), every tab's. A batch whose items
21
+ * all come from one tab is that tab's batch; one that spans tabs has no stage.
22
+ *
23
+ * §31.2.2: with a film, only that film's notes (and the visuals', which are on every film) and that film's script
24
+ * (`ctx.script` is that film's), and the batch carries the film. With none (a project with no film yet, or an older
25
+ * caller), every note on every film in play, as before.
22
26
  */
23
27
  export function createBatch(ctx, stage, now = new Date()) {
28
+ const film = ctx.video ?? null;
24
29
  // §26: a shelved film is never asked about; its open notes stay unsent.
25
- const notes = ctx.notes.notes.filter((n) => (stage === undefined || n.stage === stage) && noteState(n) === "todo" && noteInPlay(n, ctx.project));
30
+ const notes = ctx.notes.notes.filter((n) => (stage === undefined || n.stage === stage) && noteState(n) === "todo" && noteInPlay(n, ctx.project) && noteOnFilm(n, film, ctx.project.videos));
26
31
  const sections = stage === undefined || stage === "script" ? ctx.script.sections.filter((s) => isChanged(s) || s.status === "flagged") : [];
27
32
  if (notes.length === 0 && sections.length === 0)
28
33
  throw new EmptyBatchError(stage);
@@ -40,8 +45,9 @@ export function createBatch(ctx, stage, now = new Date()) {
40
45
  sectionIds: sections.map((s) => s.id),
41
46
  sentAt: now.toISOString(),
42
47
  prompt: only
43
- ? buildPrompt(ctx.project.name, only, id, notes.length, sections.length, only === "picture" ? formatLines(ctx.project, picture) : [])
44
- : buildWidePrompt(ctx.project, id, notes, sections.length),
48
+ ? buildPrompt(ctx.project.name, only, id, notes.length, sections.length, only === "picture" ? formatLines(ctx.project, picture) : [], filmName(ctx.project, film))
49
+ : buildWidePrompt(ctx.project, id, notes, sections.length, film),
50
+ ...(film ? { video: film } : {}),
45
51
  };
46
52
  ctx.batches.batches.push(batch);
47
53
  return batch;
@@ -97,19 +103,29 @@ function stepsFor(stage) {
97
103
  ? 'Use rushes_get_batch and rushes_get_picks, fix each note (marks such as "Fall" or "Quieter 3 dB" are part of the note), register the new variant, then rushes_reply.'
98
104
  : "Use rushes_get_batch, fix each note, then rushes_reply with a fixT for each and rushes_add_version for the new cut.";
99
105
  }
100
- export function buildPrompt(project, stage, batchId, notes, sections, extra = []) {
106
+ /** §31.2.2: the film a batch is about, by name, in a project with more than one film (with one, nothing changes). */
107
+ function filmName(project, film) {
108
+ if (!film || project.videos.length < 2)
109
+ return null;
110
+ return project.videos.find((v) => v.id === film)?.name ?? film;
111
+ }
112
+ /** The words that say which film a batch is about, and that it is about that film alone. */
113
+ const filmLine = (name) => `This batch is about the film "${name}" only: its notes and script are that film's. Pass "${name}" as the film wherever a tool asks for one.`;
114
+ export function buildPrompt(project, stage, batchId, notes, sections, extra = [], film = null) {
101
115
  const parts = [];
102
116
  if (notes)
103
117
  parts.push(`${notes} note${notes === 1 ? "" : "s"}`);
104
118
  if (sections)
105
119
  parts.push(`${sections} script section${sections === 1 ? "" : "s"}`);
106
- return `Work through ${STAGE_NAMES[stage]} batch ${batchId} on ${project}: ${parts.join(" and ")}.\n${[...extra, stepsFor(stage)].join("\n")}`;
120
+ const on = film ? `${project} › ${film}` : project;
121
+ return `Work through ${STAGE_NAMES[stage]} batch ${batchId} on ${on}: ${parts.join(" and ")}.\n${[...(film ? [filmLine(film)] : []), ...extra, stepsFor(stage)].join("\n")}`;
107
122
  }
108
123
  /**
109
124
  * The prompt for a batch that spans tabs: what is in it, tab by tab with the films each tab's notes
110
125
  * are on, then what to do on each tab.
111
126
  */
112
- export function buildWidePrompt(project, batchId, notes, sections) {
127
+ export function buildWidePrompt(project, batchId, notes, sections, video = null) {
128
+ const film = filmName(project, video);
113
129
  const lines = [];
114
130
  const counts = [];
115
131
  for (const stage of STAGES) {
@@ -127,8 +143,10 @@ export function buildWidePrompt(project, batchId, notes, sections) {
127
143
  lines.push(`${TAB_NAMES[stage]}: ${[...extra, stepsFor(stage)].join(" ")}`);
128
144
  }
129
145
  const total = notes.length + sections;
130
- const head = `Work through batch ${batchId} on ${project.name}: ${total} item${total === 1 ? "" : "s"} across ${counts.length} tabs. Each note says its tab (stage) and film (video); on an audio tab, pass that film to rushes_get_picks.`;
131
- return [head, ...counts.map((c) => `- ${c}`), ...lines].join("\n");
146
+ const head = film
147
+ ? `Work through batch ${batchId} on ${project.name} › ${film}: ${total} item${total === 1 ? "" : "s"} across ${counts.length} tabs. Each note says its tab (stage); on an audio tab, pass the film to rushes_get_picks.`
148
+ : `Work through batch ${batchId} on ${project.name}: ${total} item${total === 1 ? "" : "s"} across ${counts.length} tabs. Each note says its tab (stage) and film (video); on an audio tab, pass that film to rushes_get_picks.`;
149
+ return [head, ...(film ? [filmLine(film)] : []), ...counts.map((c) => `- ${c}`), ...lines].join("\n");
132
150
  }
133
151
  export function latestBatch(file) {
134
152
  return file.batches[file.batches.length - 1];
@@ -48,7 +48,9 @@ function noteTime(t, tOut) {
48
48
  function continued(text, indent) {
49
49
  return text.split("\n").join(`\n${indent}`);
50
50
  }
51
- function noteLines(n, ctx, videos) {
51
+ function noteLines(n, base, videos) {
52
+ // §31.3: a note on the script names a line of its own film's script.
53
+ const ctx = base.scriptOf ? { ...base, script: base.scriptOf(n.video) } : base;
52
54
  // What an audio note is on (M4): "Music · Warm keys", "S2 · Take 1", "Whole mix" ...
53
55
  const label = onLabel(n, ctx);
54
56
  const on = label ? ` · ${label}` : "";
@@ -95,7 +97,7 @@ function byTimecode(a, b) {
95
97
  * escaped (this is a file, not HTML), and the same input always produces the same string.
96
98
  */
97
99
  export function notesMarkdown(project, notes, now, script = { sections: [] }, picks, visuals) {
98
- const ctx = { project, script, picks };
100
+ const ctx = typeof script === "function" ? { project, script: { sections: [] }, scriptOf: script, picks } : { project, script, picks };
99
101
  // §26: a shelved film has no section; its notes are kept in the project and come back when it is restored.
100
102
  notes = notes.filter((n) => noteInPlay(n, project));
101
103
  const lines = [`# ${project.name} — notes`, `Exported ${localDateTime(now)}`];
@@ -0,0 +1,114 @@
1
+ // §31: everything on the desk belongs to a film. With a film selected, every tab shows only that film's material.
2
+ // The one exception is Visuals, which stay project-wide (campaign material) and show on every film as shared.
3
+ // Nothing is on no film: a note, take or file that names none is the project's first film's (`videos[0]`), and the
4
+ // one-time move (server/films.ts) writes that down.
5
+ import { RushesError } from "./errors.js";
6
+ import { slugify } from "./ids.js";
7
+ import { toSchema2 } from "./script.js";
8
+ import { variantFilms } from "./schema.js";
9
+ /** The project's first film, whose the old project-wide plan files and anything on no film are (§31.2.1, §31.2.4). */
10
+ export function firstFilm(project) {
11
+ return project.videos[0]?.id ?? null;
12
+ }
13
+ /** Whether something that names `own` (a film id, or none) is on `film`. On no film is on the first film. */
14
+ function ownsFilm(own, film, videos) {
15
+ return own ? own === film : videos.length === 0 || videos[0].id === film;
16
+ }
17
+ /**
18
+ * §31.5: whether a note shows on `film`. A note on a visual shows on every film (Visuals are shared, §31.2.3); any
19
+ * other note is its film's, and one that names none is the first film's. With no film named, every note.
20
+ */
21
+ export function noteOnFilm(note, film, videos) {
22
+ if (!film || note.stage === "visuals")
23
+ return true;
24
+ return ownsFilm(note.video, film, videos);
25
+ }
26
+ /** A registered file's film: its own, or (naming none) the first film's. */
27
+ export function fileOnFilm(file, film, videos) {
28
+ return !film || ownsFilm(file.video, film, videos);
29
+ }
30
+ export const BRIEF_NAME = "brief.md";
31
+ export const STORYBOARD_NAME = "storyboard.md";
32
+ /** The folder every film but the first keeps its own plan files in: films/<film-id>/. */
33
+ export const FILMS_DIR = "films";
34
+ /** The paths of a film's plan files (§31.3): the root's for the first film or no film, else films/<film-id>/. */
35
+ export function filmPlace(project, video) {
36
+ const first = firstFilm(project);
37
+ const film = video ?? first;
38
+ if (film === null || film === first)
39
+ return { video: film, first: true, brief: BRIEF_NAME, storyboard: STORYBOARD_NAME, slot: null };
40
+ return { video: film, first: false, brief: `${FILMS_DIR}/${film}/${BRIEF_NAME}`, storyboard: `${FILMS_DIR}/${film}/${STORYBOARD_NAME}`, slot: film };
41
+ }
42
+ /** How a film is named back: "Five views (five-views)". */
43
+ const filmWords = (v) => (v.name === v.id ? v.id : `${v.name} (${v.id})`);
44
+ /** §31.6: a film's material asked for without saying which film, in a project with several. Lists them. */
45
+ export class FilmRequiredError extends RushesError {
46
+ constructor(videos, what = "this") {
47
+ super(`This project has ${videos.length} films, so say which one ${what} is for: ${videos.map(filmWords).join(", ")}.`, 400, "film_required", { films: videos.map((v) => ({ id: v.id, name: v.name })) });
48
+ }
49
+ }
50
+ /**
51
+ * The film a request is about (§31.6): the one it names (an id or a name, as resolveVideo reads them), or, naming none,
52
+ * the only film. With several and none named, a FilmRequiredError that lists them. Null while there is no film.
53
+ */
54
+ export function chooseFilm(project, given, what) {
55
+ if (given) {
56
+ const slug = slugify(given);
57
+ const v = project.videos.find((x) => x.id === given) ?? project.videos.find((x) => x.id === slug) ?? project.videos.find((x) => x.name.toLowerCase() === given.toLowerCase());
58
+ if (!v)
59
+ throw new RushesError(`No film "${given}". Films: ${project.videos.map(filmWords).join(", ") || "none yet"}.`, 404, "not_found", { films: project.videos.map((x) => ({ id: x.id, name: x.name })) });
60
+ return v;
61
+ }
62
+ if (project.videos.length > 1)
63
+ throw new FilmRequiredError(project.videos, what);
64
+ return project.videos[0] ?? null;
65
+ }
66
+ export const movedAnything = (m) => m.notes + m.takes + m.files > 0 || m.script;
67
+ /**
68
+ * §31.4, on drafts: gives the first film every note on no film (except a visual's), every read, bed and pass on no
69
+ * film, every registered file on no film, and a schema 1 script (as schema 2). Only with two or more films; a second
70
+ * run finds nothing. Visuals (visuals.json) are never touched.
71
+ */
72
+ export function moveToFirstFilm(d, film, filmCount) {
73
+ const moved = { film, notes: 0, takes: 0, files: 0, sections: 0, script: false };
74
+ if (filmCount < 2)
75
+ return moved;
76
+ for (const n of d.notes?.notes ?? []) {
77
+ if (n.video || n.stage === "visuals")
78
+ continue;
79
+ n.video = film.id;
80
+ moved.notes += 1;
81
+ }
82
+ for (const lane of d.project?.lanes ?? []) {
83
+ for (const v of lane.variants) {
84
+ if (variantFilms(v).length > 0)
85
+ continue;
86
+ v.videos = [film.id];
87
+ moved.takes += 1;
88
+ }
89
+ }
90
+ for (const f of d.project?.files ?? []) {
91
+ if (f.video)
92
+ continue;
93
+ f.video = film.id;
94
+ moved.files += 1;
95
+ }
96
+ if (d.script?.schema === 1) {
97
+ moved.sections = d.script.sections.length;
98
+ toSchema2(d.script, film.id);
99
+ moved.script = true;
100
+ }
101
+ return moved;
102
+ }
103
+ const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
104
+ /** The one Activity line the move writes: "Moved to Meet your agents: 3 notes, 2 takes and the script (4 sections)". */
105
+ export function movedText(m) {
106
+ const parts = [
107
+ m.notes ? plural(m.notes, "note", "notes") : "",
108
+ m.takes ? plural(m.takes, "take", "takes") : "",
109
+ m.files ? plural(m.files, "file", "files") : "",
110
+ m.script ? `the script (${plural(m.sections, "section", "sections")})` : "",
111
+ ].filter(Boolean);
112
+ const list = parts.length > 1 ? `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}` : parts[0];
113
+ return `Moved to ${m.film.name}: ${list}, which were on no film`;
114
+ }
package/dist/core/log.js CHANGED
@@ -5,6 +5,7 @@ import { newId } from "./ids.js";
5
5
  import { oneLineOf } from "./labels.js";
6
6
  import { STAGE_WORDS, cutEvent, fileEvent, notesSentEvent } from "./logEvents.js";
7
7
  import { LOG_MAX, MERGE_MS, logText } from "./logText.js";
8
+ import { sectionsOf } from "./script.js";
8
9
  /** The newest entry this event may merge into: same kind, area and writer, within the window (R4). */
9
10
  function mergeTarget(entries, event, by, t) {
10
11
  const window = event.windowMs ?? MERGE_MS;
@@ -17,7 +18,8 @@ function mergeTarget(entries, event, by, t) {
17
18
  continue;
18
19
  if (!(age <= window))
19
20
  return -1; // older than the window, and so is everything before it
20
- if (e.kind === event.kind && e.area === event.area && e.by === by)
21
+ // §30: and about the same film, so one film's line never takes in another film's count or text.
22
+ if (e.kind === event.kind && e.area === event.area && e.by === by && (e.video ?? null) === (event.video ?? null))
21
23
  return i;
22
24
  }
23
25
  return -1;
@@ -148,7 +150,7 @@ export function backfillLog(file, src, before) {
148
150
  export function undatedRefs(project, script) {
149
151
  const refs = [
150
152
  ...project.lanes.flatMap((l) => l.variants.map((v) => `${l.id}/${v.id}`)),
151
- ...script.sections.flatMap((s) => s.takes.map((t) => `${s.id}:${t.id}`)),
153
+ ...sectionsOf(script).flatMap((s) => s.takes.map((t) => `${s.id}:${t.id}`)),
152
154
  ];
153
155
  return refs.slice(0, LOG_MAX);
154
156
  }
@@ -166,11 +168,39 @@ export function undatedLines(refs, ctx) {
166
168
  const name = oneLineOf(lane.name);
167
169
  out.push({ area: lane.stage, text: logText(name && name !== word ? `${word}: ${lane.name} (${n} ${noun})` : `${word}: ${n} ${noun}`) });
168
170
  }
169
- const sections = ctx.script.sections.filter((s) => s.takes.some((t) => set.has(`${s.id}:${t.id}`))).length;
171
+ const sections = sectionsOf(ctx.script).filter((s) => s.takes.some((t) => set.has(`${s.id}:${t.id}`))).length;
170
172
  if (sections)
171
173
  out.push({ area: "voice", text: `Voiceover: ${sections} section${sections === 1 ? "" : "s"} with takes` });
172
174
  return out;
173
175
  }
176
+ /**
177
+ * §30: the films a Change Log line is about. Its own film when it has one; for a line written before lines carried
178
+ * one, the films of the notes it names (a reply line's `notes:<ids>`) or of the take it is about (`<lane>/<variant>`).
179
+ * Empty: the line is about the whole project, or its film can't be told. The dashboard's copy is web/src/lib.ts.
180
+ */
181
+ export function lineFilms(line, ctx) {
182
+ if (line.video)
183
+ return [line.video];
184
+ const ref = line.ref ?? "";
185
+ if (ref.startsWith("notes:")) {
186
+ const ids = new Set(ref.slice("notes:".length).split(","));
187
+ return [...new Set(ctx.notes.filter((n) => ids.has(n.id) && n.video).map((n) => n.video))];
188
+ }
189
+ const slash = ref.indexOf("/");
190
+ if (slash > 0) {
191
+ const variant = ctx.lanes.find((l) => l.id === ref.slice(0, slash))?.variants.find((v) => v.id === ref.slice(slash + 1));
192
+ if (variant)
193
+ return variant.videos ?? (variant.video === undefined ? [] : [variant.video]);
194
+ }
195
+ return [];
196
+ }
197
+ /** §30, §31.5: whether Activity on `film` shows a line: its own and the project's. With one film (or none) every line. */
198
+ export function lineOnFilm(line, film, ctx) {
199
+ if (!film || ctx.videos.length < 2)
200
+ return true;
201
+ const films = lineFilms(line, ctx);
202
+ return films.length === 0 || films.includes(film);
203
+ }
174
204
  /** §22.7: the newest `limit` lines (default 30), newest first, matching `area` and `since`. */
175
205
  export function logView(file, q, ctx) {
176
206
  const asked = Number.isFinite(q.limit) ? Math.floor(q.limit) : 30;
@@ -183,6 +213,8 @@ export function logView(file, q, ctx) {
183
213
  continue;
184
214
  if (from !== null && !(Date.parse(e.at) > from))
185
215
  continue;
216
+ if (q.video !== undefined && ctx.films && !lineOnFilm(e, q.video, ctx.films))
217
+ continue;
186
218
  matching.push(e);
187
219
  }
188
220
  const undated = from !== null ? [] : undatedLines(file.undated, ctx).filter((l) => q.area === undefined || l.area === q.area);
@@ -122,9 +122,9 @@ export function takeEvent(section, take, number) {
122
122
  many: (n, subject) => `Voiceover: ${plural(n, "take", "takes")} added${subject ? ` to ${subject}` : ""}`,
123
123
  };
124
124
  }
125
- /** "Script set: 6 sections". */
126
- export function scriptEvent(sections) {
127
- return { area: "script", kind: "script", merge: "replace", text: `Script set: ${plural(sections, "section", "sections")}` };
125
+ /** "Script set: 6 sections". §31.2.1: a film's script line is that film's (`video`), so Activity shows it only there. */
126
+ export function scriptEvent(sections, video = null) {
127
+ return { area: "script", kind: "script", merge: "replace", ...(video ? { video, subject: video } : {}), text: `Script set: ${plural(sections, "section", "sections")}` };
128
128
  }
129
129
  /** `Picks: voice “Vo Jules, full read”, music “Night drive, held back”`, the whole set after the change; for one film, `Picks for “Key”: …`. */
130
130
  export function picksEvent(project, lanes, video) {
@@ -162,7 +162,7 @@ export function filmEvent(video, shelved) {
162
162
  return { area: "picture", kind: "film", merge: "replace", subject: video.id, text, video: video.id, version: null };
163
163
  }
164
164
  /** "3 notes sent from Picture"; on Script, "1 note and 2 script edits sent from Script"; from more than one tab, "5 notes sent from several tabs". */
165
- export function notesSentEvent(batch) {
165
+ export function notesSentEvent(batch, video = null) {
166
166
  const tab = batch.stage === null ? "" : TAB_NAMES[batch.stage];
167
167
  const notes = batch.noteIds.length;
168
168
  const edits = batch.sectionIds.length;
@@ -170,7 +170,7 @@ export function notesSentEvent(batch) {
170
170
  ? `${plural(notes, "note", "notes")} and ${plural(edits, "script edit", "script edits")}`
171
171
  : edits ? plural(edits, "script edit", "script edits") : plural(notes, "note", "notes");
172
172
  return {
173
- area: "notes", kind: "notes-sent", merge: "count", count: Math.max(1, notes + edits), subject: tab, tab: batch.stage,
173
+ area: "notes", kind: "notes-sent", merge: "count", count: Math.max(1, notes + edits), subject: tab, tab: batch.stage, video,
174
174
  text: `${what} sent from ${tab || "several tabs"}`,
175
175
  many: (n, subject) => `${plural(n, "note", "notes")} sent from ${subject || "several tabs"}`,
176
176
  };
@@ -191,12 +191,12 @@ function replyKey(ids) {
191
191
  }
192
192
  const doneIn = (text) => Number(/\((\d+) done\)/.exec(text)?.[1] ?? 0);
193
193
  /** "Agent replied to 3 notes (2 done)"; replies in a burst are one line that counts every note (R4, final review I1). */
194
- export function repliesEvent(notes) {
194
+ export function repliesEvent(notes, video = null) {
195
195
  const said = (n, done) => `Agent replied to ${plural(n, "note", "notes")}${done ? ` (${done} done)` : ""}`;
196
196
  const done = notes.filter((n) => n.status === "done").length;
197
197
  const stages = new Set(notes.map((n) => n.stage));
198
198
  return {
199
- area: "notes", kind: "replies", merge: "count", count: Math.max(1, notes.length), tab: stages.size === 1 ? [...stages][0] : null,
199
+ area: "notes", kind: "replies", merge: "count", count: Math.max(1, notes.length), tab: stages.size === 1 ? [...stages][0] : null, video,
200
200
  ref: replyKey(notes.map((n) => n.id)),
201
201
  text: said(notes.length, done),
202
202
  // The line says how many were done as it stood, so this call's are added to that.
@@ -1,6 +1,7 @@
1
1
  import { NoteSchema, ReplySchema, } from "./schema.js";
2
2
  import { InvalidError, NotFoundError, RushesError } from "./errors.js";
3
3
  import { labelOfId, versionFormats } from "./formats.js";
4
+ import { noteOnFilm } from "./films.js";
4
5
  import { newId } from "./ids.js";
5
6
  import { noteState, setStatus } from "./noteState.js";
6
7
  export function addNote(file, input, now = new Date()) {
@@ -168,10 +169,27 @@ export function onLabel(note, ctx) {
168
169
  return withCue ? cueLabel(withCue.l, withCue.v, on) : null;
169
170
  }
170
171
  export function filterNotes(notes, f = {}) {
171
- return notes.filter((n) => (f.stage === undefined || n.stage === f.stage) &&
172
+ return notes.filter((n) => (f.video === undefined || noteOnFilm(n, f.video, f.videos ?? [])) &&
173
+ (f.stage === undefined || n.stage === f.stage) &&
172
174
  (f.status === undefined || n.status === f.status) &&
173
175
  (f.state === undefined || noteState(n) === f.state) &&
174
176
  (f.batch === undefined || n.batch === f.batch) &&
175
177
  (f.version === undefined || n.version === f.version) &&
176
178
  (f.format === undefined || (n.stage === "picture" && (n.format === f.format || (!f.onlyThisFormat && n.format === null)))));
177
179
  }
180
+ /**
181
+ * §30: the notes of a batch (or a reply), by the film each is on, so a line about them is written per film and Activity
182
+ * on one film never counts another's. A note on no film (and a batch's script edits) is under null. In first-seen order.
183
+ */
184
+ export function byFilm(items, filmOf) {
185
+ const out = new Map();
186
+ for (const item of items) {
187
+ const film = filmOf(item) ?? null;
188
+ const group = out.get(film);
189
+ if (group)
190
+ group.push(item);
191
+ else
192
+ out.set(film, [item]);
193
+ }
194
+ return [...out];
195
+ }