rushes 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +5 -5
- package/README.md +47 -1
- package/dist/cli/main.js +4 -2
- package/dist/core/agentActivity.js +171 -0
- package/dist/core/agentRules.js +193 -0
- package/dist/core/alwaysLabel.js +8 -0
- package/dist/core/noteState.js +31 -2
- package/dist/core/notes.js +19 -3
- package/dist/core/projectFolder.js +23 -0
- package/dist/core/schema.js +60 -2
- package/dist/core/store.js +23 -3
- package/dist/mcp/stdio.js +16 -12
- package/dist/mcp/tools.js +13 -1
- package/dist/server/agent/acp.js +162 -0
- package/dist/server/agent/adapters.js +102 -0
- package/dist/server/agent/broker.js +111 -0
- package/dist/server/agent/detect.js +44 -0
- package/dist/server/agent/followUp.js +30 -0
- package/dist/server/agent/notify.js +54 -0
- package/dist/server/agent/ownTools.js +88 -0
- package/dist/server/agent/rpc.js +126 -0
- package/dist/server/agent/rules.js +105 -0
- package/dist/server/agent/runner.js +1031 -0
- package/dist/server/agent/seenCalls.js +48 -0
- package/dist/server/agent/terminal.js +27 -0
- package/dist/server/app.js +182 -5
- package/dist/server/start.js +83 -4
- package/dist/version.js +2 -0
- package/package.json +1 -1
- package/skills/rushes/SKILL.md +4 -4
- package/web-dist/assets/{index-DebHxWrg.css → index-BIJlv6zN.css} +1 -1
- package/web-dist/assets/index-D430jOsg.js +70 -0
- package/web-dist/index.html +2 -2
- package/web-dist/assets/index-D-520-nU.js +0 -67
|
@@ -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.
|
|
4
|
+
"version": "0.10.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
|
@@ -110,16 +110,16 @@ The user can shelve a film they have set aside (**Shelve film** in the dashboard
|
|
|
110
110
|
## The loop
|
|
111
111
|
|
|
112
112
|
1. **Register what you made.**
|
|
113
|
-
- A render: `rushes_add_version` with `video` and `file`. Run it again for each new cut. Give every cut a short `label` (48 characters at most) that says what changed, e.g. `"launch 1.45x slower"`, and put the detail in `note
|
|
113
|
+
- A render: `rushes_add_version` with `video` and `file`. Run it again for each new cut. Give every cut a short `label` (48 characters at most) that says what changed, e.g. `"launch 1.45x slower"`, and put the detail in `note` as one short summary line, then a `- ` line per change (the Cut menu shows them as points): the Cut menu's version list shows the label, and a longer one is refused. When the cut is likely to play badly in a browser (4K or larger, over 1.5 GB, or a codec such as ProRes), the reply carries `proxySuggested: true` and `proxyReason`; the Timeline tab then offers the user a proxy (**Create proxy**, under the player). Prefer H.264 MP4 to begin with and this won't come up.
|
|
114
114
|
- Other shapes of the same cut (a 9:16, 1:1 or 4:5 of the 16:9: same edit, same length): register every shape you rendered, main one first. `rushes_add_version` with `file` (the main one) and `formats: [{ file }, …]` registers them all in one call; `rushes_add_format` (`file`, optional `video`, `version` and `label`) adds one to a cut already registered. Rushes measures each ratio with ffprobe; here `label` is only a ratio hint for an unusual shape such as 2.39:1 (not the cut's short label, which belongs to `rushes_add_version`). A second render with a ratio the cut already has is refused: a re-render is a new version. A shape more than 0.1 s off the cut's length is still registered, with a warning: `rushes_add_format` returns it as `warning`, and `rushes_add_version` returns a list as `formatWarnings` (there, `warning` means "Picture is locked").
|
|
115
115
|
- 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
116
|
- 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
117
|
- 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).
|
|
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.
|
|
119
119
|
- 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
120
|
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. 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
|
|
122
|
-
4. **Fix each note.** 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.
|
|
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.
|
|
122
|
+
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
123
|
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
124
|
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.
|
|
125
125
|
7. **Audio batches.** For a note on the voice, the music, the effects or the mix (stage `mix` is the Timeline tab, where every take in use plays together), call `rushes_get_picks` first (pass the note's film as `video`: picks and levels are per film), so you know which read or variant is in use before you fix anything. It also returns `levels: { voice?, music?, sfx? }` in dB — where the user wants each sound to sit. Don't try to change these; they're set from the level on each sound's row of the Timeline tab and only tell you the balance the user has already chosen. Then fix each note:
|
|
@@ -153,7 +153,7 @@ Rushes keeps a log of what happened in the project, written as it happens (`.rus
|
|
|
153
153
|
|
|
154
154
|
## Tools
|
|
155
155
|
|
|
156
|
-
The MCP server has twenty-
|
|
156
|
+
The MCP server has twenty-five tools: `rushes_open`, `rushes_status`, `rushes_add_version`, `rushes_add_format`, `rushes_add_visual`, `rushes_add_variant`, `rushes_set_films`, `rushes_set_script`, `rushes_get_script`, `rushes_add_take`, `rushes_list_notes`, `rushes_list_assets`, `rushes_get_batch`, `rushes_reply`, `rushes_working_on`, `rushes_get_picks`, `rushes_set_shots`, `rushes_lock_picture`, `rushes_add_file`, `rushes_export_notes`, `rushes_log`, `rushes_get_log`, `rushes_scan`, `rushes_bring_in` and `rushes_doctor`. Each takes an optional `project` folder, which defaults to the folder the harness started in.
|
|
157
157
|
|
|
158
158
|
## Rules
|
|
159
159
|
|
package/README.md
CHANGED
|
@@ -186,7 +186,7 @@ If your user asked you to use Rushes, do this:
|
|
|
186
186
|
2. If it added anything, tell the user to restart the app (or start a new session) so the `rushes_*` tools load.
|
|
187
187
|
3. From then on, follow [AGENTS.md](AGENTS.md). If the user wants a new film, start with **Starting a film** in AGENTS.md: plan it with them first, then build. Otherwise, in short: register what you made, call `rushes_open`, wait for the user to press **Send**, then `rushes_get_batch`, fix the notes, and `rushes_reply`.
|
|
188
188
|
|
|
189
|
-
The MCP server has twenty-
|
|
189
|
+
The MCP server has twenty-five tools: `rushes_open`, `rushes_status`, `rushes_add_version`, `rushes_add_format`, `rushes_add_visual`, `rushes_add_variant`, `rushes_set_films`, `rushes_set_script`, `rushes_get_script`, `rushes_add_take`, `rushes_list_notes`, `rushes_list_assets`, `rushes_get_batch`, `rushes_reply`, `rushes_working_on`, `rushes_get_picks`, `rushes_set_shots`, `rushes_lock_picture`, `rushes_add_file`, `rushes_export_notes`, `rushes_log`, `rushes_get_log`, `rushes_scan`, `rushes_bring_in` and `rushes_doctor`.
|
|
190
190
|
|
|
191
191
|
If you can't run commands, give the user the matching line from **Manual setup** below.
|
|
192
192
|
|
|
@@ -289,6 +289,52 @@ When the project's folder already holds files for a locked Voice, Music or Effec
|
|
|
289
289
|
|
|
290
290
|
Hovering a locked tab shows a short tooltip, e.g. "Locked: ask your agent for music beds". The Assets workspace follows the same rule.
|
|
291
291
|
|
|
292
|
+
## Send to AI
|
|
293
|
+
|
|
294
|
+
Send to AI hands your notes to an agent on this Mac, so there's no prompt to paste. It starts your own Claude Code or Codex in the project folder, signed in your way (a Claude or ChatGPT plan, or an API key), so every run is billed to that account, just as if you had typed the prompt yourself. The first run fetches a small adapter for that agent with `npx`.
|
|
295
|
+
|
|
296
|
+
Rushes never sees a password or key, and never signs you in. When an agent isn't signed in, **Sign in in Terminal** opens Terminal with that agent's own login command (`claude auth login` or `codex login`) for you to run there.
|
|
297
|
+
|
|
298
|
+
**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
|
+
|
|
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?".
|
|
301
|
+
|
|
302
|
+
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
|
+
|
|
304
|
+
The agent's name opens a menu to choose another agent, **Start a fresh conversation**, change what it may do without asking, and see the "Always" rules. **Stop** ends a run and gives its unfinished notes back.
|
|
305
|
+
|
|
306
|
+
**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
|
+
|
|
308
|
+
**Permissions.** There are two levels:
|
|
309
|
+
|
|
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.
|
|
312
|
+
|
|
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.
|
|
314
|
+
|
|
315
|
+
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
|
+
|
|
317
|
+
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
|
+
|
|
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.
|
|
320
|
+
|
|
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.
|
|
322
|
+
|
|
323
|
+
"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
|
+
|
|
325
|
+
- options that start other programs, such as `git grep -O`, `rg --pre`, `ssh -o ProxyCommand`, `find -exec` and `npm run --script-shell`;
|
|
326
|
+
- project scripts that `npm run`, `bun run` and `go run` execute, and a package `npx` finds in the project's own `node_modules`;
|
|
327
|
+
- packages that `npm install`, `npm init`, `npm create` and `npm explore` fetch and run;
|
|
328
|
+
- services that `docker compose run` starts.
|
|
329
|
+
|
|
330
|
+
Rushes never offers "Always" for:
|
|
331
|
+
|
|
332
|
+
- a shell, or a wrapper such as `nohup` or `sudo`;
|
|
333
|
+
- a quoted or spaced program path;
|
|
334
|
+
- a subcommand that runs any package or program (`npm exec`, `npm x`, `pnpm dlx`, `uv run`, `uv tool`, `docker container`, `deno run`, `nix run`);
|
|
335
|
+
- one package runner run through another (`npx npm`, `bunx pnpm`, `npx pnpm@9`, `npx @pnpm/exe`, `uvx poetry`);
|
|
336
|
+
- a request to read, edit, search, move or delete a file outside the project or in one of the folders above.
|
|
337
|
+
|
|
292
338
|
## The Change Log
|
|
293
339
|
|
|
294
340
|
The **Activity** tab of the notes panel (what was the Change Log button) is a log of what happened, newest first and grouped by day:
|
package/dist/cli/main.js
CHANGED
|
@@ -33,7 +33,7 @@ Usage
|
|
|
33
33
|
rushes new <folder> [--name NAME] [--no-browser] start a film: the folders and a brief.md to fill in, then open it
|
|
34
34
|
rushes setup [--only claude-code,codex,...] [--dry-run]
|
|
35
35
|
add Rushes to every agent harness on this machine
|
|
36
|
-
rushes mcp
|
|
36
|
+
rushes mcp [folder] [--pinned] run the MCP server over stdio (--pinned: that folder only)
|
|
37
37
|
rushes status [dir] tabs and open items
|
|
38
38
|
rushes doctor [dir] [--json] check Node, ffmpeg, agent harnesses and this project
|
|
39
39
|
rushes add version <file> --video NAME [--label TEXT] [--note TEXT]
|
|
@@ -93,6 +93,8 @@ const OPTIONS = {
|
|
|
93
93
|
only: { type: "string" },
|
|
94
94
|
"dry-run": { type: "boolean" },
|
|
95
95
|
"idle-minutes": { type: "string" },
|
|
96
|
+
// R17: `mcp --pinned`, the server Send to AI hands its agent: tools work on the given folder only.
|
|
97
|
+
pinned: { type: "boolean" },
|
|
96
98
|
help: { type: "boolean", short: "h" },
|
|
97
99
|
version: { type: "boolean", short: "v" },
|
|
98
100
|
};
|
|
@@ -336,7 +338,7 @@ export async function main(argv, io) {
|
|
|
336
338
|
return results.some((r) => r.status === "failed") ? 1 : 0;
|
|
337
339
|
}
|
|
338
340
|
case "mcp":
|
|
339
|
-
await runStdio(io.cwd);
|
|
341
|
+
await runStdio(rest[0] ? resolve(io.cwd, rest[0]) : io.cwd, { pinned: o.pinned === true });
|
|
340
342
|
return 0;
|
|
341
343
|
case "status": {
|
|
342
344
|
const root = rest[0] ? resolve(io.cwd, rest[0]) : dir;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// §28.3: what the runner tells the agent beside the batch prompt, and how the agent's session/update
|
|
2
|
+
// notifications read as Activity lines. Pure: the server and its tests share it.
|
|
3
|
+
import { oneLine } from "./labels.js";
|
|
4
|
+
/** Added after the batch prompt in what the runner sends. The prompt stored in batches.json never carries it. */
|
|
5
|
+
export const AGENT_LINES = "Before you start on each note, call rushes_working_on with the note's id and what you are doing, in a few plain words.\n" +
|
|
6
|
+
"If you are not sure what a note means, ask on the note with rushes_reply (no status) and go on to the next one. The user answers on the note.\n" +
|
|
7
|
+
"Only add a new version when the picture or sound changed.\n" +
|
|
8
|
+
"Wait for each command to finish before you reply on a note; do not run work as a background task.";
|
|
9
|
+
/** An Activity line is one line of at most this many characters. */
|
|
10
|
+
export const ACTIVITY_LINE_MAX = 120;
|
|
11
|
+
/** A command in a line is cut to this many characters. */
|
|
12
|
+
const COMMAND_MAX = 80;
|
|
13
|
+
/** The agent's own Rushes calls, in Claude's spelling (mcp__rushes__rushes_x) and Codex's (mcp.rushes.rushes_x). */
|
|
14
|
+
const OWN_TOOL = /^mcp(__|\.)rushes(__|\.)rushes_/;
|
|
15
|
+
/** Tool calls that are the agent's housekeeping, not work on the notes. */
|
|
16
|
+
const HOUSEKEEPING = new Set(["Load skill", "ToolSearch", "Guardian Review", "Preparing file…"]);
|
|
17
|
+
/** The titles an adapter gives a shell command. */
|
|
18
|
+
const SHELL = new Set(["Terminal", "Bash"]);
|
|
19
|
+
/**
|
|
20
|
+
* `text` with the project folder cut from every path in it: "<root>/a/b" reads "a/b", the folder itself ".". Only
|
|
21
|
+
* the root followed by a slash, or the root alone (at the end, or before a line break, quote, bracket or punctuation),
|
|
22
|
+
* and only where a path starts (M7): "<root> 2/a" and "<root>-old/a" are other folders and stay as they are. A root
|
|
23
|
+
* followed by a space may be such a folder, so it is left whole.
|
|
24
|
+
*/
|
|
25
|
+
function withoutRoot(text, root) {
|
|
26
|
+
const base = root.replace(/[\\/]+$/, "");
|
|
27
|
+
if (!base)
|
|
28
|
+
return text;
|
|
29
|
+
const escaped = base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
30
|
+
const at = new RegExp(`(?<![\\w./-])${escaped}(?:/|(?=$|[\\r\\n"'\`),;:\\]]))`, "g");
|
|
31
|
+
return text.replace(at, (m) => (m.endsWith("/") && m.length > base.length ? "" : "."));
|
|
32
|
+
}
|
|
33
|
+
/** What a masked secret reads as. */
|
|
34
|
+
const MASK = "•••";
|
|
35
|
+
/** A secret's value: a quoted string (quotes and all), or a run up to a space, a quote or a shell separator. */
|
|
36
|
+
const VALUE = String.raw `(?:"[^"]*"|'[^']*'|[^\s'"&|;]+)`;
|
|
37
|
+
/** M3: the common shapes of a secret in a command, each with the part kept before its value. */
|
|
38
|
+
const SECRETS = [
|
|
39
|
+
// An Authorization header, whatever its scheme: "Authorization: Bearer x", "Authorization: Basic x", "authorization:x".
|
|
40
|
+
new RegExp(String.raw `(\bAuthorization:\s*)(?:[A-Za-z]+\s+(?=[^\s'"]))?[^\s'"]+`, "gi"),
|
|
41
|
+
new RegExp(String.raw `(\bBearer\s+)[^\s'"]+`, "g"),
|
|
42
|
+
new RegExp(String.raw `((?<![\w-])--(?:token|password)(?:=|\s+))${VALUE}`, "gi"),
|
|
43
|
+
new RegExp(String.raw `((?<![\w-])(?:password|token|api_key|apikey)=)${VALUE}`, "gi"),
|
|
44
|
+
new RegExp(String.raw `(\b[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+)*_(?:KEY|TOKEN|SECRET)=)${VALUE}`, "g"),
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* `text` with the value of each secret it shows replaced by •••: a bearer token, an Authorization header, --token and
|
|
48
|
+
* --password, password=, token=, api_key= and apikey=, and a NAME_KEY, NAME_TOKEN or NAME_SECRET variable. For the
|
|
49
|
+
* Activity line only: the ask card shows the command as it is, since that is what the user is asked to allow.
|
|
50
|
+
*/
|
|
51
|
+
export function maskSecrets(text) {
|
|
52
|
+
return SECRETS.reduce((t, re) => t.replace(re, `$1${MASK}`), text);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* One session/update as an Activity line, or null when it isn't worth one: a tool call is its title, a plan
|
|
56
|
+
* its number of steps. Message chunks are too chatty, and kinds this build doesn't know are left out.
|
|
57
|
+
*/
|
|
58
|
+
export function activityLine(update, root) {
|
|
59
|
+
if (typeof update !== "object" || update === null)
|
|
60
|
+
return null;
|
|
61
|
+
const u = update;
|
|
62
|
+
switch (u.sessionUpdate) {
|
|
63
|
+
case "tool_call": {
|
|
64
|
+
if (typeof u.title !== "string")
|
|
65
|
+
return null;
|
|
66
|
+
const title = u.title.trim();
|
|
67
|
+
if (OWN_TOOL.test(title) || HOUSEKEEPING.has(title))
|
|
68
|
+
return null;
|
|
69
|
+
// Secrets are masked before anything is cut, so a cut can't leave part of one showing.
|
|
70
|
+
let text = maskSecrets(u.title);
|
|
71
|
+
if (SHELL.has(title)) {
|
|
72
|
+
const raw = u.rawInput;
|
|
73
|
+
const first = typeof raw?.command === "string" ? raw.command.split(/\r\n|\r|\n/).map((l) => l.trim()).find((l) => l !== "") : undefined;
|
|
74
|
+
text = first ? `Ran a command: ${oneLine(withoutRoot(maskSecrets(first), root), COMMAND_MAX)}` : "Ran a command";
|
|
75
|
+
}
|
|
76
|
+
const line = oneLine(withoutRoot(text, root), ACTIVITY_LINE_MAX);
|
|
77
|
+
return line === "" || line === "…" ? null : line;
|
|
78
|
+
}
|
|
79
|
+
case "plan": {
|
|
80
|
+
const n = Array.isArray(u.entries) ? u.entries.length : 0;
|
|
81
|
+
return `Planned ${n} ${n === 1 ? "step" : "steps"}`;
|
|
82
|
+
}
|
|
83
|
+
default:
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** A command's text from a tool call's input: Claude's `command` string, or Codex's argv. Null when it has none. */
|
|
88
|
+
function commandOf(raw) {
|
|
89
|
+
const c = raw?.command;
|
|
90
|
+
if (typeof c === "string")
|
|
91
|
+
return c;
|
|
92
|
+
if (Array.isArray(c) && c.every((x) => typeof x === "string"))
|
|
93
|
+
return c.join(" ");
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Task 10 (3): Activity lines from a session's updates, knowing each tool call's story. A tool call that runs a command
|
|
98
|
+
* (a shell title, or an execute call whose input holds a command) says nothing until it ends. Claude announces it
|
|
99
|
+
* `pending`, before any ask and before its input has streamed in; Codex announces it `in_progress` when the item starts
|
|
100
|
+
* (codex-acp 2.7.0 toToolStatus sends no pending), and an ask for that started command can come after. So its one line
|
|
101
|
+
* comes at `completed`, "Ran a command: <first line, clipped, secrets masked>", or at `failed`, which covers a refusal
|
|
102
|
+
* or a decline as well as a failed run. Any other tool call says its title at once, as activityLine does.
|
|
103
|
+
*/
|
|
104
|
+
export class ActivityTracker {
|
|
105
|
+
root;
|
|
106
|
+
calls = new Map();
|
|
107
|
+
constructor(root) {
|
|
108
|
+
this.root = root;
|
|
109
|
+
}
|
|
110
|
+
line(update) {
|
|
111
|
+
if (typeof update !== "object" || update === null)
|
|
112
|
+
return null;
|
|
113
|
+
const u = update;
|
|
114
|
+
const id = typeof u.toolCallId === "string" ? u.toolCallId : null;
|
|
115
|
+
if ((u.sessionUpdate !== "tool_call" && u.sessionUpdate !== "tool_call_update") || id === null)
|
|
116
|
+
return activityLine(update, this.root);
|
|
117
|
+
const known = this.calls.get(id);
|
|
118
|
+
const call = {
|
|
119
|
+
title: typeof u.title === "string" ? u.title : known?.title ?? null,
|
|
120
|
+
kind: typeof u.kind === "string" ? u.kind : known?.kind ?? null,
|
|
121
|
+
raw: u.rawInput !== undefined ? u.rawInput : known?.raw,
|
|
122
|
+
said: known?.said ?? false,
|
|
123
|
+
};
|
|
124
|
+
this.calls.set(id, call);
|
|
125
|
+
if (this.isLookup(call) && !this.isCommand(call)) {
|
|
126
|
+
// Round 3: a read or a search (Codex's parse of a `cat` or `rg` it starts before its ask) says its title once it
|
|
127
|
+
// completes, the same rule as a command.
|
|
128
|
+
if (call.said || u.status !== "completed" || call.title === null)
|
|
129
|
+
return null;
|
|
130
|
+
call.said = true;
|
|
131
|
+
return activityLine({ sessionUpdate: "tool_call", title: call.title }, this.root);
|
|
132
|
+
}
|
|
133
|
+
if (!this.isCommand(call))
|
|
134
|
+
return u.sessionUpdate === "tool_call" && !known ? activityLine(update, this.root) : null;
|
|
135
|
+
if (call.said)
|
|
136
|
+
return null;
|
|
137
|
+
const status = u.status;
|
|
138
|
+
// Only the end counts: Codex reports a command in_progress when it starts, which can be before its approval.
|
|
139
|
+
if (status !== "completed" && status !== "failed")
|
|
140
|
+
return null;
|
|
141
|
+
call.said = true;
|
|
142
|
+
const text = this.commandText(call);
|
|
143
|
+
const lead = status === "failed" ? "A command failed or was not run" : "Ran a command";
|
|
144
|
+
return oneLine(text ? `${lead}: ${text}` : lead, ACTIVITY_LINE_MAX);
|
|
145
|
+
}
|
|
146
|
+
isLookup(c) {
|
|
147
|
+
return c.kind === "read" || c.kind === "search";
|
|
148
|
+
}
|
|
149
|
+
isCommand(c) {
|
|
150
|
+
const title = c.title?.trim() ?? "";
|
|
151
|
+
if (OWN_TOOL.test(title) || HOUSEKEEPING.has(title))
|
|
152
|
+
return false;
|
|
153
|
+
return SHELL.has(title) || (c.kind === "execute" && (commandOf(c.raw) !== null || (title !== "" && !/^mcp(__|\.)/.test(title) && !isMcpInput(c.raw))));
|
|
154
|
+
}
|
|
155
|
+
commandText(c) {
|
|
156
|
+
const raw = commandOf(c.raw);
|
|
157
|
+
const title = c.title?.trim() ?? "";
|
|
158
|
+
const source = raw ?? (title !== "" && !SHELL.has(title) ? title : null);
|
|
159
|
+
if (source === null)
|
|
160
|
+
return null;
|
|
161
|
+
const first = source.split(/\r\n|\r|\n/).map((l) => l.trim()).find((l) => l !== "");
|
|
162
|
+
if (!first)
|
|
163
|
+
return null;
|
|
164
|
+
const text = oneLine(withoutRoot(maskSecrets(first), this.root), COMMAND_MAX);
|
|
165
|
+
return text === "" || text === "…" ? null : text;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/** An MCP tool call's input, as Codex sends it ({ server, tool, arguments }): not a command. */
|
|
169
|
+
function isMcpInput(raw) {
|
|
170
|
+
return typeof raw === "object" && raw !== null && "server" in raw && "tool" in raw;
|
|
171
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, resolve, sep, relative, isAbsolute } from "node:path";
|
|
3
|
+
/** Resolve a path through symlinks. A path not there yet is judged by its longest existing ancestor, plus the rest. */
|
|
4
|
+
export function real(p) {
|
|
5
|
+
const abs = resolve(p);
|
|
6
|
+
let cur = abs;
|
|
7
|
+
const rest = [];
|
|
8
|
+
for (;;) {
|
|
9
|
+
try {
|
|
10
|
+
const r = realpathSync(cur);
|
|
11
|
+
return rest.length ? resolve(r, ...rest.reverse()) : r;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
const up = dirname(cur);
|
|
15
|
+
if (up === cur)
|
|
16
|
+
return abs;
|
|
17
|
+
rest.push(cur.slice(up.length + (up.endsWith(sep) ? 0 : 1)));
|
|
18
|
+
cur = up;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** True only for `root` itself or a path under it, after symlinks are resolved. */
|
|
23
|
+
export function inside(root, path) {
|
|
24
|
+
const r = real(root);
|
|
25
|
+
const p = real(path);
|
|
26
|
+
if (p === r)
|
|
27
|
+
return true;
|
|
28
|
+
const rel = relative(r, p);
|
|
29
|
+
return rel !== "" && !rel.startsWith("..") && !isAbsolute(rel) && p.startsWith(r.endsWith(sep) ? r : r + sep);
|
|
30
|
+
}
|
|
31
|
+
const PROJECT_KINDS = new Set(["read", "edit", "search", "move", "delete"]);
|
|
32
|
+
/**
|
|
33
|
+
* R10: folders and files in the project that hold the agent's and the editor's own settings, hooks or tokens.
|
|
34
|
+
* A read, edit, delete, move or search of one never goes through on its own, under project-edits or any Always
|
|
35
|
+
* rule: it always asks. Matched by name, case-insensitively, as any part of the path under the root (a nested
|
|
36
|
+
* repo's `.git/hooks` too).
|
|
37
|
+
*/
|
|
38
|
+
export const PROTECTED_PATHS = [".rushes", ".git", ".claude", ".codex", ".mcp.json", ".vscode", ".idea"];
|
|
39
|
+
const PROTECTED = new Set(PROTECTED_PATHS);
|
|
40
|
+
/**
|
|
41
|
+
* A name as a case-insensitive volume compares it, for the security checks here: NFKC, then lower-cased. APFS opens
|
|
42
|
+
* `.ruſhes` (U+017F, the long s) as `.rushes`, which `toLowerCase` alone would miss; NFKC maps ſ to s (and
|
|
43
|
+
* full-width letters to plain ones, which only makes the checks stricter).
|
|
44
|
+
*/
|
|
45
|
+
export const fold = (s) => s.normalize("NFKC").toLowerCase();
|
|
46
|
+
/** True when `path`, under `root`, is or is inside a protected folder or file (after symlinks are resolved). */
|
|
47
|
+
export function isProtected(root, path) {
|
|
48
|
+
const rel = relative(real(root), real(path));
|
|
49
|
+
return rel.split(sep).some((part) => PROTECTED.has(fold(part)));
|
|
50
|
+
}
|
|
51
|
+
/** Kinds that change where a path is: never for the project folder itself (M5). */
|
|
52
|
+
const ROOT_CHANGES = new Set(["delete", "move"]);
|
|
53
|
+
/**
|
|
54
|
+
* Every path is inside the project and none is protected; a delete or move must also not be the project folder
|
|
55
|
+
* itself. With no path at all, false.
|
|
56
|
+
*/
|
|
57
|
+
function inProject(req, root) {
|
|
58
|
+
const notRoot = req.kind !== null && ROOT_CHANGES.has(req.kind);
|
|
59
|
+
return (req.paths.length > 0 &&
|
|
60
|
+
req.paths.every((p) => inside(root, p) && !isProtected(root, p) && !(notRoot && real(p) === real(root))));
|
|
61
|
+
}
|
|
62
|
+
/** Kinds an Always rule is never offered or honoured for: "other" (an untyped tool call) and a switch of the agent's mode. */
|
|
63
|
+
const NEVER_ALWAYS = new Set(["other", "switch_mode"]);
|
|
64
|
+
/**
|
|
65
|
+
* A plain command: letters, digits, space, tab, `_ . / : = @ % + , -` and quotes. Anything else may make a shell
|
|
66
|
+
* run more than the named command (chaining, pipes, redirects, substitution, zsh's `=(…)` and glob qualifiers,
|
|
67
|
+
* globs, `~`, `$`), so a command with it always asks, whatever Always rules there are.
|
|
68
|
+
*/
|
|
69
|
+
export const SAFE_COMMAND = /^[A-Za-z0-9 \t_.\/:=@%+,'"-]*$/;
|
|
70
|
+
/** Shells (and env): any of them runs whatever script follows it. broker.ts unwraps `[shell, -c|-lc, script]` by this list. */
|
|
71
|
+
export const SHELLS = new Set(["sh", "bash", "zsh", "fish", "dash", "ksh", "csh", "tcsh", "rbash", "mksh", "pwsh", "env"]);
|
|
72
|
+
/** Programs that run another program given after them, so the program and subcommand would be the next words. */
|
|
73
|
+
export const WRAPPERS = new Set([
|
|
74
|
+
"exec", "command", "builtin", "nohup", "time", "nice", "timeout", "xargs", "sudo", "doas", "caffeinate", "arch", "eval", "source",
|
|
75
|
+
"noglob", "nocorrect", "coproc", "repeat", "trap", "watch", "stdbuf", "unbuffer", "chroot", "taskpolicy", "sandbox-exec", "corepack",
|
|
76
|
+
"open", "osascript",
|
|
77
|
+
]);
|
|
78
|
+
/** Subcommands that run any package or program named after them (`npm x`, `npm exec`, `npm exe`, `pnpm dlx`), whatever the program. */
|
|
79
|
+
export const RUNNER_SUBCOMMANDS = new Set(["x", "exe", "exec", "dlx"]);
|
|
80
|
+
/** Programs whose `run` runs any program or package named after it (`uv run perl`), not a project script. */
|
|
81
|
+
export const RUN_ANY_PROGRAM = new Set(["uv", "pipx", "poetry", "pdm", "hatch", "conda", "docker", "podman", "mise", "deno", "nix"]);
|
|
82
|
+
/** Programs that run the package named as their subcommand (`npx hyperframes`), so that package is the real program. */
|
|
83
|
+
export const PACKAGE_RUNNERS = new Set(["npx", "bunx", "pnpx", "yarn", "uvx"]);
|
|
84
|
+
/** Package runners and managers: run by a PACKAGE_RUNNER, their own subcommand (`npx npm exec x`) would go unchecked. */
|
|
85
|
+
export const RUNNER_PROGRAMS = new Set([
|
|
86
|
+
"npm", "npx", "pnpm", "pnpx", "yarn", "bun", "bunx", "uv", "uvx", "pipx", "deno", "corepack", "poetry", "hatch", "pdm", "yarnpkg",
|
|
87
|
+
]);
|
|
88
|
+
/** A program and subcommand that is itself a runner of anything (`uv tool run perl`, `docker container run img`). */
|
|
89
|
+
export const RUNNER_PAIRS = new Map([["uv", "tool"], ["docker", "container"], ["podman", "container"]]);
|
|
90
|
+
/** A word a rule may be made of: no quotes, no `=`, nothing a shell reads as more than the word itself. */
|
|
91
|
+
const RULE_WORD = /^[A-Za-z0-9_.\/@:+-]+$/;
|
|
92
|
+
/** A word's basename for the lists, folded: macOS volumes are case-insensitive, so `NOHUP` and `ſudo` run nohup and sudo. */
|
|
93
|
+
const name = (word) => fold(basename(word));
|
|
94
|
+
/**
|
|
95
|
+
* The names the lists know a subcommand word by (R8). Run by a package runner it is a package spec, so a leading
|
|
96
|
+
* `@scope/` and a trailing `@version` are cut, and the scope counts too: `pnpm@9` is pnpm, `@pnpm/exe` is exe and pnpm.
|
|
97
|
+
*/
|
|
98
|
+
function names(word) {
|
|
99
|
+
const lower = fold(word);
|
|
100
|
+
const scoped = /^@([^/]+)\/(.+)$/.exec(lower);
|
|
101
|
+
const bare = name(scoped ? scoped[2] : lower).replace(/(.)@[^@]*$/, "$1");
|
|
102
|
+
return scoped ? [scoped[1], bare] : [bare];
|
|
103
|
+
}
|
|
104
|
+
function ruleWord(word, ids) {
|
|
105
|
+
if (!RULE_WORD.test(word) || word.startsWith("-") || word.split("/").includes(".."))
|
|
106
|
+
return false;
|
|
107
|
+
return !ids.some((n) => SHELLS.has(n) || WRAPPERS.has(n));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* R7: the words an Always rule names, the program and its subcommand (the command's first two whitespace-separated
|
|
111
|
+
* words), or null when they are not an exact identity of one program and subcommand: a word that is quoted, holds
|
|
112
|
+
* `=`, climbs a `..` path, is a flag, a shell or a wrapper, or a subcommand that runs any package or program.
|
|
113
|
+
* The shell reads quote-free words exactly as split here, so these are the program and subcommand it runs.
|
|
114
|
+
*/
|
|
115
|
+
export function alwaysWords(command) {
|
|
116
|
+
const words = command.trim().split(/\s+/).filter(Boolean).slice(0, 2);
|
|
117
|
+
// `.` as the program is the shell's source; as the subcommand (`find .`) it is a path.
|
|
118
|
+
if (words.length === 0 || words[0] === ".")
|
|
119
|
+
return null;
|
|
120
|
+
const program = name(words[0]);
|
|
121
|
+
if (!ruleWord(words[0], [program]))
|
|
122
|
+
return null;
|
|
123
|
+
if (words.length === 2) {
|
|
124
|
+
const sub = names(words[1]);
|
|
125
|
+
if (!ruleWord(words[1], sub))
|
|
126
|
+
return null;
|
|
127
|
+
if (sub.some((n) => RUNNER_SUBCOMMANDS.has(n)))
|
|
128
|
+
return null;
|
|
129
|
+
if (sub.includes("run") && RUN_ANY_PROGRAM.has(program))
|
|
130
|
+
return null;
|
|
131
|
+
if (PACKAGE_RUNNERS.has(program) && sub.some((n) => RUNNER_PROGRAMS.has(n)))
|
|
132
|
+
return null;
|
|
133
|
+
if (sub.includes(RUNNER_PAIRS.get(program) ?? "\0"))
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
return words;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A command an Always rule may be offered for and honoured on: plain (SAFE_COMMAND) as a whole, with its first two
|
|
140
|
+
* words an exact program and subcommand (alwaysWords). Later words are that program's arguments.
|
|
141
|
+
*/
|
|
142
|
+
export function plainCommand(command) {
|
|
143
|
+
return command.trim() !== "" && SAFE_COMMAND.test(command) && alwaysWords(command) !== null;
|
|
144
|
+
}
|
|
145
|
+
function matches(rule, req, root) {
|
|
146
|
+
// "other" (an untyped tool call) would cover every future one, and switch_mode the agent's own mode: never kept,
|
|
147
|
+
// and never honoured in an old file.
|
|
148
|
+
if (NEVER_ALWAYS.has(rule.kind) || rule.kind !== (req.kind ?? "other"))
|
|
149
|
+
return false;
|
|
150
|
+
if (PROJECT_KINDS.has(rule.kind))
|
|
151
|
+
return inProject(req, root);
|
|
152
|
+
if (rule.kind !== "execute")
|
|
153
|
+
return true;
|
|
154
|
+
if (rule.command === null || req.command === null)
|
|
155
|
+
return false;
|
|
156
|
+
// The stored rule as well as the request: an old file's rule of a shape R7 refuses is never honoured.
|
|
157
|
+
if (rule.command.trim().split(/\s+/).length > 2)
|
|
158
|
+
return false;
|
|
159
|
+
const want = alwaysWords(rule.command);
|
|
160
|
+
const got = plainCommand(req.command) ? alwaysWords(req.command) : null;
|
|
161
|
+
return want !== null && got !== null && want.length === got.length && want.every((w, i) => w === got[i]);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Whether an "Always" can be offered for this request: not for an untyped tool call or switch_mode, not for a
|
|
165
|
+
* command that isn't a plain program and subcommand (plainCommand), and not for a path request with any path
|
|
166
|
+
* outside the project or protected (M4), which such a rule could never allow.
|
|
167
|
+
*/
|
|
168
|
+
export function canAlways(req, root) {
|
|
169
|
+
const kind = req.kind ?? "other";
|
|
170
|
+
if (NEVER_ALWAYS.has(kind))
|
|
171
|
+
return false;
|
|
172
|
+
if (PROJECT_KINDS.has(kind))
|
|
173
|
+
return inProject(req, root);
|
|
174
|
+
return kind !== "execute" || plainCommand(req.command ?? "");
|
|
175
|
+
}
|
|
176
|
+
export function decide(req, s, root) {
|
|
177
|
+
if (s.permissions === "ask-all")
|
|
178
|
+
return "ask";
|
|
179
|
+
if (s.always.some((r) => matches(r, req, root)))
|
|
180
|
+
return "allow";
|
|
181
|
+
if (req.kind && PROJECT_KINDS.has(req.kind) && inProject(req, root))
|
|
182
|
+
return "allow";
|
|
183
|
+
return "ask";
|
|
184
|
+
}
|
|
185
|
+
export function ruleFor(req) {
|
|
186
|
+
const kind = req.kind ?? "other";
|
|
187
|
+
if (kind !== "execute")
|
|
188
|
+
return { kind, command: null };
|
|
189
|
+
const words = (req.command ?? "").trim().split(/\s+/).filter(Boolean);
|
|
190
|
+
return { kind, command: words.length ? words.slice(0, 2).join(" ") : null };
|
|
191
|
+
}
|
|
192
|
+
// The label lives in its own pure file, so the desk can bundle it.
|
|
193
|
+
export { alwaysLabel } from "./alwaysLabel.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const WORDS = { read: "reads", edit: "edits", delete: "deletes", move: "moves", search: "searches" };
|
|
2
|
+
export function alwaysLabel(rule) {
|
|
3
|
+
if (rule.kind === "execute")
|
|
4
|
+
return `Always for ${rule.command ?? "commands"} here`;
|
|
5
|
+
if (rule.kind === "fetch")
|
|
6
|
+
return "Always for web requests here";
|
|
7
|
+
return `Always for ${WORDS[rule.kind] ?? "this"} here`;
|
|
8
|
+
}
|
package/dist/core/noteState.js
CHANGED
|
@@ -2,7 +2,7 @@ export const NOTE_STATES = ["todo", "sent", "done"];
|
|
|
2
2
|
/** Every move a note can make: from a state, on an event, to a state. A move not listed is refused. */
|
|
3
3
|
export const NOTE_TRANSITIONS = {
|
|
4
4
|
todo: { send: "sent", resolve: "done" },
|
|
5
|
-
sent: { resolve: "done" },
|
|
5
|
+
sent: { resolve: "done", recall: "todo" },
|
|
6
6
|
done: { reopen: "todo" },
|
|
7
7
|
};
|
|
8
8
|
/** Each state in words, for a marker's or a dot's name and tooltip, and for an agent. */
|
|
@@ -21,6 +21,8 @@ export function moveNote(n, event) {
|
|
|
21
21
|
n.batch = event.batch;
|
|
22
22
|
else if (event.type === "resolve")
|
|
23
23
|
n.status = "done";
|
|
24
|
+
else if (event.type === "recall")
|
|
25
|
+
n.batch = null;
|
|
24
26
|
else {
|
|
25
27
|
n.status = "todo";
|
|
26
28
|
n.batch = null;
|
|
@@ -42,5 +44,32 @@ export function markSent(notes, batch) {
|
|
|
42
44
|
if (ids.has(n.id) && noteState(n) === "todo")
|
|
43
45
|
moveNote(n, { type: "send", batch: batch.id });
|
|
44
46
|
}
|
|
47
|
+
/** Recall: every sent note of these batches goes back to to do. Done notes stay. Returns the ids moved. */
|
|
48
|
+
export function recallNotes(notes, batchIds) {
|
|
49
|
+
const batches = new Set(batchIds);
|
|
50
|
+
const moved = [];
|
|
51
|
+
for (const n of notes) {
|
|
52
|
+
if (n.batch !== null && batches.has(n.batch) && noteState(n) === "sent") {
|
|
53
|
+
moveNote(n, { type: "recall" });
|
|
54
|
+
moved.push(n.id);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return moved;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Recall one note: sent goes back to to do with no batch; the rest of its batch stays. With `batch`, only while
|
|
61
|
+
* the note is still in that batch (one filed again elsewhere is left alone). True when it moved.
|
|
62
|
+
*/
|
|
63
|
+
export function recallNote(notes, id, batch) {
|
|
64
|
+
const n = notes.find((x) => x.id === id);
|
|
65
|
+
if (!n || noteState(n) !== "sent" || (batch !== undefined && n.batch !== batch))
|
|
66
|
+
return false;
|
|
67
|
+
moveNote(n, { type: "recall" });
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
/** It is the user's turn: the note is with the agent and the last word in its thread is the agent's. */
|
|
71
|
+
export function needsYou(n) {
|
|
72
|
+
return noteState(n) === "sent" && n.replies.at(-1)?.by === "agent";
|
|
73
|
+
}
|
|
45
74
|
/** The note with its state, as the server hands it out. A copy: the stored note never carries one. */
|
|
46
|
-
export const withState = (n) => ({ ...n, state: noteState(n) });
|
|
75
|
+
export const withState = (n) => ({ ...n, state: noteState(n), needsYou: needsYou(n) });
|
package/dist/core/notes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NoteSchema, } from "./schema.js";
|
|
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
4
|
import { newId } from "./ids.js";
|
|
@@ -21,10 +21,14 @@ function find(file, id) {
|
|
|
21
21
|
throw new NotFoundError("note", id);
|
|
22
22
|
return n;
|
|
23
23
|
}
|
|
24
|
-
export function applyReply(file, r) {
|
|
24
|
+
export function applyReply(file, r, now = new Date()) {
|
|
25
25
|
const n = find(file, r.id);
|
|
26
|
-
if (r.reply !== undefined)
|
|
26
|
+
if (r.reply !== undefined) {
|
|
27
27
|
n.reply = r.reply;
|
|
28
|
+
const text = r.reply.trim();
|
|
29
|
+
if (text !== "")
|
|
30
|
+
n.replies.push({ by: "agent", text, at: now.toISOString() });
|
|
31
|
+
}
|
|
28
32
|
// A status is a move in the note's lifecycle (noteState.ts): done to todo reopens it, which leaves its batch.
|
|
29
33
|
setStatus(n, r.status);
|
|
30
34
|
if (r.fixT !== undefined)
|
|
@@ -33,6 +37,18 @@ export function applyReply(file, r) {
|
|
|
33
37
|
n.fixVersion = r.fixVersion;
|
|
34
38
|
return n;
|
|
35
39
|
}
|
|
40
|
+
export const USER_REPLY_MAX = 4000;
|
|
41
|
+
/** The user's answer to the agent's reply, added to the note's thread. */
|
|
42
|
+
export function addUserReply(file, id, text, now = new Date()) {
|
|
43
|
+
const n = find(file, id);
|
|
44
|
+
if (text.trim().length > USER_REPLY_MAX)
|
|
45
|
+
throw new InvalidError(`An answer is at most ${USER_REPLY_MAX} characters`);
|
|
46
|
+
const parsed = ReplySchema.safeParse({ by: "user", text, at: now.toISOString() });
|
|
47
|
+
if (!parsed.success)
|
|
48
|
+
throw new InvalidError("Reply is invalid", parsed.error.issues);
|
|
49
|
+
n.replies.push(parsed.data);
|
|
50
|
+
return n;
|
|
51
|
+
}
|
|
36
52
|
export function applyUserEdit(file, e, check) {
|
|
37
53
|
const n = find(file, e.id);
|
|
38
54
|
const next = { ...n };
|