@q253595422/dsh-imagegen-video 1.10.0 → 1.14.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/CHANGELOG.md CHANGED
@@ -5,6 +5,137 @@ Attribution for third-party code is in [NOTICE](./NOTICE).
5
5
 
6
6
  ## Releases
7
7
 
8
+ ### 1.14.0 — draw it in code, render it here
9
+
10
+ - **A second renderer, chosen per task.** The canvas composer now carries a
11
+ *Rendering* select: **Model** (the historical path, unchanged and still the
12
+ default) or **Code**. The choice belongs to the task being submitted — it is
13
+ not a setting, not a global switch, and nothing is written to disk, so the
14
+ next generation on the same canvas can use the other one.
15
+ - **No image or video provider involved.** In code mode the drawing program is
16
+ written by the conversation model DSH already has (`ctx.agentDefaultModel`,
17
+ mounted through the host's `agents` and `agentPresets` services) — not the
18
+ plugin's prompt-enhancement endpoint — and rendered on this machine. One
19
+ headless turn, no tools, no vendor SDK, no second credential.
20
+ - **Rendered, not prompted.** The returned JavaScript runs in a `node:vm`
21
+ context with a drawing API and no `require`, `process` or filesystem; each
22
+ frame is RGBA pixels handed to ffmpeg, or encoded straight to PNG. Nothing
23
+ leaves the machine, so a code render costs no image/video quota.
24
+ - **Same pipeline, same slots.** A code result is submitted through the same
25
+ `GenerateRequest` / `VideoGenerateRequest` (an extra `renderer: 'code'`),
26
+ lands in the same `images/` and `videos/` directories and the same history
27
+ stores, and is therefore stitchable, timeline-cuttable, transitionable,
28
+ favouritable and re-framable exactly like a model result. Resolution,
29
+ aspect and duration come from the same composer controls; frames =
30
+ duration × 30 fps.
31
+ - **Failures are named and recoverable.** `code-prompt-empty`,
32
+ `code-prompt-too-long`, `code-no-chat-model`, `code-chat-failed`,
33
+ `code-not-code`, `code-syntax`, `code-runtime`, `render-timeout`,
34
+ `render-no-ffmpeg`, `render-cancelled`, `render-encoder-died`,
35
+ `render-encoder-failed`, `render-empty`. The node shows the host's own
36
+ message plus a hint to switch back to Model and retry; a missing ffmpeg is
37
+ warned about in the composer *before* submitting (`POST /code/probe`).
38
+ - **A non-code answer still produces something.** If the model replies with
39
+ prose instead of a program, the render falls back to a built-in title card
40
+ and the task is marked `degraded` with the reason — a wasted render is worse
41
+ than a plain one.
42
+ - **Retry replays the program.** The generated source is kept on the task, so
43
+ retrying a failed *render* does not ask the model again; generating again
44
+ does.
45
+ - **No new dependency.** `node:vm`, hand-written PNG encoding and the existing
46
+ `locateFfmpeg()` / `clip-compose.ts` path — ffmpeg remains the only external
47
+ tool, needed for code videos only.
48
+
49
+ ### 1.13.0 — the video is directed before it is rendered
50
+
51
+ - **A planning step before every render.** With the studio's new *Plan first*
52
+ switch on (the default), a one-line request is no longer forwarded verbatim.
53
+ A reasoning pass splits it into shots, subject motion, camera work, duration
54
+ and style, and produces the prompt and parameters the provider actually
55
+ receives. The finished task, its queue summary and the history entry all
56
+ carry the plan, so a clip can be explained later without re-running anything.
57
+ - **The plan is the request.** The planned prompt replaces the typed one, and
58
+ the planned duration / aspect / resolution replace the panel's values. A plan
59
+ may only NARROW them: a model asking for 30s when the user chose 5s gets 5s,
60
+ and a frame the family cannot render (4:3 on comemoe) is overruled. A
61
+ previewed plan that arrives back over the wire is re-clamped before use.
62
+ - **Preview before you pay for a render.** `POST /video/plan` runs the same
63
+ planning code with no submit, and the studio's *Preview plan* button shows
64
+ the shots and parameters. Submitting afterwards adopts that exact plan
65
+ instead of asking the chat model again, so what was previewed is what gets
66
+ rendered.
67
+ - **Planning degrades, it does not disappear.** No chat model configured, an
68
+ unreachable endpoint, a timeout, or an answer that is not the agreed JSON all
69
+ fall back to an offline shot planner. The plan is marked `degraded` with the
70
+ reason, shown in the panel and recorded under the new `video-plan`
71
+ diagnostics phase — the raw sentence is never silently submitted.
72
+ - **Inputs are bounded.** An empty prompt is refused with `video-prompt-empty`
73
+ and one over 4000 characters with `video-prompt-too-long`, both before any
74
+ submit. A planned prompt is capped at 900 characters.
75
+ - **Prompt structure follows Wan 2.2.** The shot skeleton (style → shot size and
76
+ lighting → per-shot subject, motion and camera; motion over static scene for
77
+ image-bearing modes) is the one Wan's own Apache-2.0 `--use_prompt_extend`
78
+ guide teaches, which is the reference implementation behind the `wan2.2-*`
79
+ family this plugin routes.
80
+ - **No new credential.** Planning reuses the existing prompt-enhancement chat
81
+ endpoint (`promptModel` / `promptApiUrl` / `promptApiKey`); blank values reuse
82
+ the image channel. `pnpm test:director` covers all of the above offline, and
83
+ an end-to-end run against a real channel was verified: the planning model
84
+ produced the shot list and the provider rendered from it.
85
+
86
+ ### 1.12.0 — cut, join, and keep the same face
87
+
88
+ - **A timeline editor on the canvas.** The dock's new film button lines the
89
+ finished clips up in canvas reading order, then lets them be reordered,
90
+ trimmed (in/out point per clip) and joined with a transition. The result is
91
+ still an ordinary video node, so preview / download / favorite / retry keep
92
+ working on it.
93
+ - **Trims are clamped to the clip.** An out point past the end of the material
94
+ is the material's own length, never a read past the last frame; a transition
95
+ is clamped to half of the shorter clip beside it at *calculation* time, so
96
+ xfade never receives an offset longer than its input.
97
+ - **Real transitions in ffmpeg.** Hard cuts keep the single `concat` pass; any
98
+ fade/dissolve switches to a chained `xfade`/`acrossfade` graph with a unified
99
+ time base on both sides. Audio is optional — turning it off omits the audio
100
+ chain entirely instead of mapping a silent one.
101
+ - **The editor's total matches the file.** Both sides read
102
+ `timeline.ts`, so the length shown in the panel is the length that gets
103
+ written. `pnpm test:timeline` checks the rules offline and
104
+ `pnpm test:timeline-compose` runs four real ffmpeg renders and measures them.
105
+ - **Identity anchoring.** Any image node can be pinned as a character, item or
106
+ style with a name. Pinned nodes join every later image and video generation
107
+ as references automatically, and the prompt gains one sentence saying which
108
+ reference is whom. Connecting a node still wins for *this* run; the pin is the
109
+ film's standing definition and is de-duplicated against it (one image sent
110
+ once, one name sent once).
111
+ - **A pin that only exists on screen is a bug, not a feature.** The pin lives in
112
+ `metadata.cast` on the node, so it survives a reload and every later run reads
113
+ the same definition — change the face by re-shooting that one node.
114
+ - **Video mode upgrades rather than degrades.** With nothing wired but a
115
+ character pinned, an `auto` video run becomes reference-mode instead of
116
+ quietly falling back to text-to-video.
117
+
118
+ ### 1.11.0 — the canvas runs the whole chain, not one node
119
+
120
+ - **A workflow run.** The dock's new branch button walks the graph downstream
121
+ from the selection (or from every unfinished node when nothing is selected)
122
+ and runs the whole chain: nodes with no remaining dependency start together,
123
+ the next layer waits for the previous one, and finished nodes are reused
124
+ rather than generated twice.
125
+ - **Failures stop the chain where they happen.** One node failing ends the run
126
+ and names the node, instead of submitting a downstream wave that would fail
127
+ for lack of input and read like a broken app.
128
+ - **A cycle is refused before anything is submitted.** Self-loops count as
129
+ cycles: a node wired to itself would wait for its own product forever.
130
+ - **A running node is adopted, not resubmitted.** Re-running a chain no longer
131
+ pays twice for work already in flight.
132
+ - **Progress and stop.** A bar reports the current layer and how many nodes are
133
+ done; stopping ends the chain at the next layer boundary while tasks already
134
+ submitted finish on their own.
135
+ - The scheduling rules are pure functions (`workflow-graph.ts`) and the run loop
136
+ is engine-free (`workflow-runner.ts`), so `pnpm test:workflow` exercises them
137
+ offline.
138
+
8
139
  ### 1.10.0 — storyboards: a shot list that runs into clip nodes
9
140
 
10
141
  - **A storyboard node.** One board is a list of shots — a prompt and a length
package/README.md CHANGED
@@ -83,9 +83,11 @@ dsh plugin --profile web add ./q253595422-dsh-imagegen-video-1.7.8.tgz
83
83
  | **无限画布** | 把提示词、参考图和生成节点连成可迭代的创作流程。 |
84
84
  | **视频节点与拼接** | 视频节点与图片节点同一套控制;多选后按画布位置拼成一条成片。 |
85
85
  | **分镜节点** | 一列镜头各出一段视频,可接上一镜尾帧;成品就是普通视频节点,同样能拼接。 |
86
+ | **时间线与身份锚定** | 成片可以在时间线里排序、裁剪、加转场再拼;钉住的角色/物品会跟着后续每一次生成。 |
86
87
  | **电商套图** | 从商品参考图生成主图、卖点图、场景图等成套素材。 |
87
88
  | **文生图 / 图生图** | 使用兼容的生图渠道生成、编辑并比较图片。 |
88
89
  | **生视频** | 文生视频、图生视频、首尾帧与多参考图;按协议族适配异步渲染与轮询。 |
90
+ | **代码生成** | 让 DSH 里已有的对话模型写绘图程序,本机渲染成视频或图片;不调生图/生视频模型,每个任务单独选。 |
89
91
  | **对话与 Agent** | 在 DSH 对话中生成图片、继续编辑,并把结果带回会话。 |
90
92
  | **画廊与历史** | 图片与视频同列管理,支持模板与标签;在不同设备上接续创作。 |
91
93
 
@@ -102,6 +104,8 @@ dsh plugin --profile web add ./q253595422-dsh-imagegen-video-1.7.8.tgz
102
104
 
103
105
  - 支持图片、文本、视频、生成配置、文件与**分镜**节点;图片节点可标注、移除背景或拆分图层。
104
106
  - **分镜**:一个节点就是一列镜头,每镜一条提示词与一个时长,顺序即片序。可以「每镜独立」一次提交全部待生成的镜头,也可以「接上一镜尾帧」一次跑一镜——用上一镜的最后一帧当这一镜的第一帧。每一镜的成品都是普通视频节点,预览、下载、收藏、重试和拼接都走原来那条链路;分镜自己有「拼接全部镜头」,交给同一套本机 ffmpeg 和同一张顺序确认卡。
107
+ - **时间线**:画布底部的胶片按钮把选中的成片按阅读顺序排成一条,可以重排、逐段设入点/出点、给每条接缝选硬切 / 叠化 / 淡入淡出并调时长,也可以整体关掉声音。面板上显示的总时长与最终文件一致。
108
+ - **身份锚定**:任意有图的图片节点右键「钉为身份参考」,选角色 / 物品 / 风格并起名。之后每一次图像与视频生成都会自动带上这些参考,提示词里补一句说明谁是第几张;连线仍然优先,二者去重合并。定义存在节点上,重拍那张图就能改脸。
105
109
  - **取尾帧续拍**:任意已完成的片段可以一键取结尾帧,落成图片节点并接好一个视频配置节点,直接写下一镜的描述就能接着拍。
106
110
  - **海报编辑**:在图片节点上叠加文字与 Logo 图层,拖动改位置,实时预览;导出是一张新图片节点,原图与图层配方都保留,随时可以重开继续改。整条链路纯本地 Canvas 2D,不调用任何模型、不消耗额度。
107
111
  - **快捷键面板**:按 `?`(或 `F1`)随时呼出,或点工具栏的键盘图标;`Esc` 关闭。常用操作同时写在控件自身的提示里(如「撤销 (Ctrl+Z)」),不必先记住有这块面板。
@@ -123,6 +127,7 @@ dsh plugin --profile web add ./q253595422-dsh-imagegen-video-1.7.8.tgz
123
127
  - **本机 ffmpeg 执行**:不调用任何模型、不联网、不消耗额度。工具从 `~/.local/bin`、`/opt/homebrew/bin`、`/usr/local/bin`、`/usr/bin` 依次查找;找不到时按钮会明确说明原因,而不是静默失败。
124
128
  - **成片进入视频历史**:拼接结果作为一条普通视频记录落盘,可以在侧栏看到、播放,也可以收藏进素材库。
125
129
  - 找不到的片段会让**整次拼接失败**并指出是第几段,而不是悄悄少拼一段。
130
+ - **要剪再接就用时间线**:底部胶片按钮打开时间线,逐段裁剪、选转场、决定是否保留声音,再一次性交给同一条 ffmpeg 链路。不设时间线时行为与以前完全一致(整段、硬切、带音轨)。
126
131
  - 输出统一为 1280×720 / 30fps / H.264 + AAC,不同尺寸或帧率的输入会等比缩放并补边,不会变形。
127
132
 
128
133
  判定规则与已知边界见 [`docs/compose-contract.md`](docs/compose-contract.md)。
@@ -156,6 +161,24 @@ dsh plugin --profile web add ./q253595422-dsh-imagegen-video-1.7.8.tgz
156
161
 
157
162
  **视频模型按渠道单独配置**,与图片模型分开:渠道里的「视频模型」目录决定该渠道能用哪些视频模型,因为视频走的是提交+轮询协议,和图片的同步返回不是一回事。
158
163
 
164
+ #### 先规划(导演规划)
165
+
166
+ 视频面板的**先规划**开关默认打开。开启后,提交前会先跑一轮推理,把一句话需求拆成镜头、动作、运镜、时长与风格,再落成真正发给模型的提示词与参数:
167
+
168
+ - **提示词**:上游收到的是规划后的多镜头描述,而不是你输入的原句。结构参照 Wan 2.2 官方 `--use_prompt_extend` 的电影语言(景别、光线、运镜、风格),在「生成前先规划」之后,原句只作为素材。
169
+ - **参数**:时长、画幅、分辨率可以按镜头节奏收紧,但**永远不会超过你自己选的值**;规划提出的画幅/分辨率还会再按模型协议族收敛一次(例如算力萌只接受 16:9 / 9:16 / 1:1)。
170
+ - **可检查**:点「预览规划」不消耗渲染,只运行规划本身;确认后提交会**沿用这份预览**,不会重新问一次对话模型,所以所预览即所提交。
171
+ - **降级有据**:对话模型调用失败、超时或返回的不是合法 JSON 时,会自动改用离线镜头规划,并在面板与视频历史里标明降级原因与来源(`对话模型` / `本地规则`),不会静默地把原句发出去。
172
+ - **拒绝非法输入**:空描述直接报 `video-prompt-empty`;超过 4000 字符报 `video-prompt-too-long`,且都不会提交到上游。
173
+
174
+ 规划用的对话模型复用「设置 → 提示词增强模型」那一处配置(`promptModel` / `promptApiUrl` / `promptApiKey`),**不需要额外申请密钥**:
175
+
176
+ - `promptModel`:任意支持 `/chat/completions` 的模型;留空时退回本地规则规划。
177
+ - `promptApiUrl` / `promptApiKey`:留空时复用生图渠道的地址与密钥。
178
+ - 规划阶段失败只降级、不会中断渲染;渲染本身失败仍按原有报错返回。
179
+
180
+ 代码落点:`src/video-director.ts`(规划与参数收敛)、`src/generation-runtime.ts`(接入 `runVideo`)、`POST /api/dsh-imagegen/video/plan`(预览)。对应离线检查:`pnpm run test:director`。
181
+
159
182
  <details>
160
183
  <summary><b>支持的协议族与模式</b></summary>
161
184
 
@@ -171,6 +194,40 @@ dsh plugin --profile web add ./q253595422-dsh-imagegen-video-1.7.8.tgz
171
194
 
172
195
  </details>
173
196
 
197
+ #### 代码生成路径(不调生图/生视频模型)
198
+
199
+ 画布合成栏里有一个「生成方式」下拉,两个选项:**模型生成**(默认,就是上面那整条链路)和**代码生成**。它**按任务选**,不写进设置、不做全局开关;同一个画布上这一张用模型、下一张用代码都行。
200
+
201
+ 选「代码生成」时:
202
+
203
+ - **谁来画**:用 **DSH 里已经接入的对话模型**——就是你在对话面板里选中的那个模型,不是插件设置里的「提示词增强模型」,插件也不新增任何模型或密钥配置。宿主把这个请求当成一次无头对话:系统提示里给绘图 API 与约束,用户消息就是你的描述,模型返回一段 JavaScript 绘图程序。
204
+ - **谁来渲染**:本机 `node:vm` 沙箱逐帧执行这段程序,拿到 RGBA 像素后交给 ffmpeg 编码(视频)或直接写成 PNG(图片)。全过程不产生任何网络请求,也不消耗生图/生视频额度。沙箱里没有 `require`、没有 `process`、没有文件系统,只有一套绘图方法(矩形、圆、路径、渐变、文字等)。
205
+ - **参数照旧**:分辨率、比例、时长仍按合成栏选的档位生效(`480P`/`720P`/`1080P` × 比例,30fps),视频帧数 = 时长 × 30。同一套档位,代码路径不另立一套。
206
+ - **产物对等**:视频落进同一个 `videos/` 目录、同一条视频历史(条目带 `renderer: 'code'`),因此预览、下载、收藏、取尾帧、多选拼接、时间线裁剪与转场、工作流执行器全部照常;图片落进同一个 `images/` 与图片历史,可以继续做标注、海报编辑、当参考图。
207
+ - **模型会「答非所问」时降级**:如果模型返回的不是代码(比如直接回了一段说明),会改用内置标题卡渲染,任务标记 `degraded` 并记录原因——**照样出图/出片**,不会白跑一趟。真正无法继续的情况(语法错、运行时抛错、超时、缺 ffmpeg)才失败。
208
+ - **重试不重复问模型**:第一次生成的绘图程序存在任务里,重试会沿用它;想换一版再重新生成。
209
+
210
+ 失败语义(错误码会直接显示在节点上,并附一行「可在上方「生成方式」里切回模型生成后重试」):
211
+
212
+ | 错误码 | 含义 | 怎么办 |
213
+ | --- | --- | --- |
214
+ | `code-prompt-empty` | 描述为空 | 写一句画面描述(代码路径靠这句话绘图,不会自己编) |
215
+ | `code-prompt-too-long` | 描述超过 4000 字符 | 压缩到核心画面与文案 |
216
+ | `code-no-chat-model` | DSH 里没有选中的对话模型 | 在对话面板选一个模型,或切回模型生成 |
217
+ | `code-chat-failed` | 对话模型调用失败(鉴权、网络、上游报错) | 看节点上的原始原因;换模型或切回模型生成 |
218
+ | `code-not-code` / `code-syntax` | 模型返回的不是可执行代码,或代码编译不过 | 重试(会重新问模型),或切回模型生成 |
219
+ | `code-runtime` | 代码逐帧执行时抛错(报文里带第几帧) | 同上 |
220
+ | `render-timeout` | 整次渲染超过 120 秒 | 缩短时长或降分辨率后重试 |
221
+ | `render-no-ffmpeg` | 本机找不到 ffmpeg,无法编码视频 | `brew install ffmpeg`,或在设置里填 `FFMPEG_PATH`;图片不需要 ffmpeg |
222
+ | `render-cancelled` | 用户取消 | 重新提交即可 |
223
+ | `render-encoder-died` / `render-encoder-failed` | ffmpeg 进程异常退出 | 重试;持续失败请查 ffmpeg 是否可用 |
224
+
225
+ 缺 ffmpeg 在**提交前**就会提示(合成栏下方一行黄色说明),不会等渲染到一半才报。
226
+
227
+ 依赖只有 ffmpeg(视频路径;图片路径零依赖)。不引入任何新框架或原生模块。
228
+
229
+ </details>
230
+
174
231
  #### 多模型对比
175
232
 
176
233
  同一提示词可提交给多个模型并列查看结果,便于快速挑选风格与质量。
@@ -263,9 +320,11 @@ node scripts/smoke-video.mjs
263
320
  pnpm run test:negative
264
321
  ```
265
322
 
266
- `pnpm test` 跑全部十一项离线检查(`verify-tracked` 排第一);`pnpm run test:negative` 做反向验证——
323
+ `pnpm test` 跑全部离线检查(`verify-tracked` 排第一);`pnpm run test:negative` 做反向验证——
267
324
  把每处修复对应的缺陷重新注回**仓库副本**,要求对应检查变红,
268
- 工作树不被改动。
325
+ 工作树不被改动。时间线与身份锚定各有自己的纯函数套件,可以单独跑:
326
+ `pnpm run test:timeline`、`pnpm run test:cast`、`pnpm run test:timeline-compose`
327
+ (最后一个需要本机 ffmpeg,缺工具时明确跳过)。
269
328
 
270
329
  跟进本项目的上游发布:
271
330
 
@@ -0,0 +1,53 @@
1
+ # 1.12.0 — 一条片子该有的三件事:剪、接、认人
2
+
3
+ 这一版补的是「已经能逐镜生成之后」还缺的三层:把成片排成时间线、让同一个人
4
+ 在每一镜里都还是他、以及一套可改的转场。三件事共用同一个原则——**成品仍然是
5
+ 普通视频节点**,没有第二套工程文件,也没有第二种节点类型。
6
+
7
+ ## 时间线:先排、再剪、然后才拼
8
+
9
+ - **时间线面板。** 画布底部新增「时间线编辑」入口:选中的成片按画布阅读顺序
10
+ 排成一条,可以直接上下移动、移出、调整顺序。没有选区时自动取画布上全部
11
+ 成片,少于两段时说明原因而不是打开一个空面板。
12
+ - **每段可以裁。** 每段给出入点与出点,按素材的真实时长夹住——出点填成 99
13
+ 秒不会让 ffmpeg 去读不存在的帧,只会切到结尾。时长未知的素材照常显示,
14
+ 只是不参与总时长的计算。
15
+ - **接缝上有转场。** 硬切 / 叠化 / 淡入淡出三选一,可调时长。转场时长在
16
+ **计算期**就被夹到两侧素材的一半以内(并留 0.05 秒余量),所以不会出现
17
+ ffmpeg 报一个看不懂的偏移错误。面板上的总时长和文件里的长度是同一套算法。
18
+ - **音频轨可选。** 关掉「保留声音」后成片不带音轨,省掉一次重编码后的静音轨。
19
+
20
+ 底层是真正重写过的:全硬切走一次 `concat`,任一转场走链式 `xfade` /
21
+ `acrossfade`,接缝两侧统一时间基(`settb=AVTB`)。`-c copy` 在这里不可用——
22
+ 输入尺寸或帧率不一致时它会静默产出一个坏文件,所以显式 filtergraph 重编码。
23
+ `pnpm test:timeline-compose` 会用本机 ffmpeg 真跑四种形态并校验成片时长;
24
+ 机器上没有 ffmpeg 时明确跳过,不伪装成通过。
25
+
26
+ 时间线的规则是纯函数(`src/client/timeline.ts`),`pnpm test:timeline` 离线
27
+ 验证裁剪、总时长、转场上限与归一化。
28
+
29
+ ## 身份锚定:定义一次,后面每一镜都带着
30
+
31
+ - **钉住一张脸。** 任意有图的图片节点右键即可「钉为身份参考」,选角色
32
+ (角色 / 物品 / 风格)并起个名字。节点上会出现一枚角标,提示词里也会补
33
+ 一句「参考图 1 是角色「阿禾」,保持同一个人」。
34
+ - **后续生成自动带上。** 图像生成与视频生成都会把被钉住的节点并进参考图,
35
+ 不需要每镜重新连线。连线仍然优先——它表示「这一张的输入」,身份是「这部
36
+ 片子的设定」,两者合并去重:同一张图不会送两次,同名只送第一个。
37
+ - **视频模式会因此升级。** 什么都没连、但有钉住的角色时,自动从文生视频切到
38
+ 参考图模式,而不是悄悄退化成一次没有参考的生成。
39
+ - **改脸只改一处。** 定义就在那个节点上,重拍它,后面所有生成自动跟着变。
40
+ 这是把 `metadata.cast` 放在节点上、而不是新建一个角色库的原因。
41
+
42
+ 规则同样是纯函数(`src/client/cast.ts`),`pnpm test:cast` 离线验证收集、
43
+ 去重与提示词生成。
44
+
45
+ ## 契约与边界
46
+
47
+ - **没有新增节点类型。** 时间线的成品、被钉住的身份,都是普通节点上的属性,
48
+ 所以预览、下载、收藏、重试、再拼接全部照旧。
49
+ - **旧画布原样打开。** 没有 `metadata.cast` 的文档行为与 1.11 完全一致;
50
+ 没有 `timeline` 参数的拼接请求走原来的整段硬切路径。
51
+ - **格式错误的 `timeline` 参数会被拒绝**,而不是静默退回普通拼接——静默退回
52
+ 意味着用户以为设了转场,文件里却没有。
53
+ - z-index 没有新增档位:时间线面板与身份面板复用 `--z-notice`。
@@ -0,0 +1,35 @@
1
+ # v1.13.0 — 视频生成前先做一轮导演规划
2
+
3
+ 一句话概括:视频不再「输入提示词就直接生成」——生成前先推理一轮,把需求拆成镜头、动作、运镜、时长与风格,而这些结果**就是**实际发给模型的提示词和参数。
4
+
5
+ ## 为什么
6
+
7
+ 旧链路里 `request.prompt` 原样进入上游请求体。写「两个人在咖啡馆门口相遇」,模型收到的就是这七个字:没有景别、没有运镜、没有时间结构,参数也是面板默认值。这不是提示词写得不好,是中间少了一步。
8
+
9
+ ## 做了什么
10
+
11
+ - **导演规划(`src/video-director.ts`)**:把一句话拆成镜头列表,产出最终提示词与 `seconds / aspectRatio / resolution`。
12
+ - **接进唯一汇聚点 `runVideo`**:面板、画布、分镜、Agent 工具、工作流执行器都经过这里,一处接入全线生效。
13
+ - **参数只收紧、不放宽**:用户选的值是上限;规划提议的参数还要再按模型协议族收敛(如算力萌只接受 16:9 / 9:16 / 1:1)。
14
+ - **预览即提交**:`POST /api/dsh-imagegen/video/plan` 只跑规划不渲染;提交时带上这份预览,宿主不重新问对话模型,避免「看的是一版、发的是另一版」。
15
+ - **降级有据**:未配置对话模型、端点不可达、超时、返回不是合法 JSON,一律退回离线镜头规划,并标明来源与原因,记入新的 `video-plan` 诊断阶段。
16
+ - **输入边界**:空输入 `video-prompt-empty`;超 4000 字符 `video-prompt-too-long`,两者都不会提交到上游。
17
+
18
+ ## 计划记录在哪里
19
+
20
+ - 任务摘要(`VideoTaskSummary.plan`):渲染中就能看到规划;
21
+ - 视频历史(`VideoHistoryEntry.plan`):事后能解释「为什么是 10s / 9:16」;
22
+ - 诊断面板:规划降级时留一条 `video-plan` 记录。
23
+
24
+ ## 提示词结构依据
25
+
26
+ 沿用 Wan 2.2 官方 `--use_prompt_extend` 的电影语言(景别、光线、运镜、风格;图生视频强调动作而非复述静帧)。选它的理由见 README 的选型说明:Apache-2.0、无需私有服务,且本插件的 `wan2.2-*` 渠道正是这条协议族。
27
+
28
+ ## 验证
29
+
30
+ - `pnpm test`:219 项通过(含新增 `pnpm test:director` 的 13 项)。
31
+ - 端到端实测:真实对话模型产出镜头规划 → 提交时采用同一份预览 → 算力萌真实渲染 5 秒成片 → 历史中保存了规划,上游收到的提示词与预览逐字一致。
32
+
33
+ ## 配置
34
+
35
+ 规划复用「设置 → 提示词增强模型」的 `promptModel`,`promptApiUrl` / `promptApiKey` 留空时复用生图渠道。**无需新增密钥**。留空 `promptModel` 时退回离线规则规划,视频照常生成。
@@ -0,0 +1,51 @@
1
+ # v1.14.0 — 代码生成:对话模型写程序,本机渲染成片
2
+
3
+ 一句话概括:画布合成栏多了一个「生成方式」选项。选「代码生成」后,DSH 里已经在用的对话模型写一段绘图程序,本机把它渲染成视频或图片——**不需要任何生图或生视频模型**。「模型生成」原样保留,仍是默认值,两条路每个任务各选一次。
4
+
5
+ ## 为什么
6
+
7
+ 生图和生视频都受两件事约束:要有额度,要等上游。而有些画面——标题卡、数据动图、几何转场、确定性的图表动画——用代码直接画出来更快、更准、更便宜,也更容易复现。DSH 里本来就有对话模型,缺的只是「让它写程序、由本机执行」这一段。
8
+
9
+ ## 做了什么
10
+
11
+ - **每任务选择,不做全局开关**:入口在现有合成栏里(`生成方式` 下拉),状态只活在当前画布,不写设置、不落盘。选「代码生成」时该分支的模型选择器隐藏,比例 / 分辨率 / 时长保留——它们照常决定输出。
12
+ - **走宿主已有的模型,不新增配置**:`ctx.inject(['skills','agents'])` 拿到宿主的 `agents` 与 `agentPresets`,用 `ctx.agentDefaultModel` 的当前选择组一次无头回合:系统提示放绘图 API 与约束,用户消息就是那句描述,回合结束读最后一条助手文本。**不是**插件设置里的「提示词增强模型」,也不需要新密钥。没选模型时报 `code-no-chat-model`。
13
+ - **沙箱执行**:`node:vm` + `Object.create(null)` 上下文,2 秒编译超时 + 整次渲染 deadline(默认 120 秒)。上下文里没有 `require` / `process` / `fs`,只有一套固定的绘图方法(矩形、圆、路径、渐变、文字、图像的像素级操作)。生成源码上限 60000 字符。
14
+ - **渲染**:逐帧得到 RGBA 缓冲,视频写进 ffmpeg 的 stdin 编成 MP4(`libx264` + `yuv420p`,可直接播放,也能被 `clip-compose.ts` 拼接);图片用自写的 PNG 编码(IHDR/IDAT/IEND + CRC32 + `zlib.deflateSync`)直接落盘,零原生依赖。
15
+ - **产物对等**:不新开队列,不新开存储。请求只多一个 `renderer: 'code'`,其余照旧走 `GenerationRequest` / `VideoGenerateRequest`,因此占位节点、轮询、取消、重试、历史、画廊、取尾帧、多选拼接、时间线裁剪与转场、工作流执行器**全部直接复用**。视频条目与图片条目都带 `renderer: 'code'` 与 `renderSource`。
16
+ - **唯一的额外路由是只读的**:`POST /api/dsh-imagegen/code/probe` 回答「会渲染成多大、多少帧、本机有没有 ffmpeg」,不调模型、不渲染。故意**没有** `code/render`——两条生产入口迟早会让占位/取消/重试各写一遍并漂移。
17
+ - **降级而不是死路**:模型回了一段散文而不是代码时,改用内置标题卡渲染,任务标 `degraded` 并记原因;`code-not-code` 只用于拿不到可执行内容的情况。
18
+
19
+ ## 失败语义
20
+
21
+ 节点上直接显示宿主原文,并在下方补一行「可在上方「生成方式」里切回模型生成后重试」。
22
+
23
+ | 错误码 | 触发条件 |
24
+ | --- | --- |
25
+ | `code-prompt-empty` / `code-prompt-too-long` | 描述为空 / 超过 4000 字符(路由边界拦,不调模型) |
26
+ | `code-no-chat-model` | DSH 里没有选中的对话模型,或 `agents` 服务不可用 |
27
+ | `code-chat-failed` | 回合失败(鉴权、网络、上游报错),报文带宿主持久化的失败原因 |
28
+ | `code-not-code` / `code-syntax` | 模型没给出可执行代码 / 代码编译不过 |
29
+ | `code-runtime` | 逐帧执行抛错,报文标明第几帧 |
30
+ | `render-timeout` | 超过 120 秒 |
31
+ | `render-no-ffmpeg` | 找不到 ffmpeg(含 `FFMPEG_PATH` 候选),提示安装方式 |
32
+ | `render-cancelled` | 用户取消 |
33
+ | `render-encoder-died` / `render-encoder-failed` / `render-empty` | ffmpeg 异常退出 / 无输出 |
34
+
35
+ 缺 ffmpeg 会在**提交前**预警(`code/probe`),且只影响视频——图片路径不需要 ffmpeg。
36
+
37
+ ## 重试
38
+
39
+ 生成出的绘图程序存在任务上。重试一次**渲染失败**的任务会沿用同一份源码,不再问模型;想换一版就重新生成。
40
+
41
+ ## 验证
42
+
43
+ - `pnpm run typecheck`、`pnpm run build`、`pnpm test` 全绿。
44
+ - `node scripts/smoke-code-render.mjs`:13 项,含真实 ffmpeg 出片(ffprobe 复核 1280×720 / 30fps / ~3s)、真实 PNG(校验签名与 `1080x1080`)、代码片段进入 `createClipComposer()` 拼接出带 `ftyp` 的 MP4,以及宿主 seam 的正常与三类失败(无 `agents`、无模型、回合 `turn/end` 为 error)。
45
+ - `scripts/smoke.mjs` 里补了画布交互用例:默认「模型生成」、切到「代码生成」后模型选择器消失而比例/分辨率/时长保留、提交体带 `renderer: 'code'` 且 `model` / `channelId` 为空、占位节点带 `renderer`、失败节点显示错误码与切回提示、切回后模型选择器回来。
46
+
47
+ ## 依赖与边界
48
+
49
+ - 新增依赖:**无**。ffmpeg 仍是唯一外部工具,仅视频路径需要。
50
+ - 代码路径不参与导演规划:代码本身就是规划。
51
+ - 代码渲染是 CPU 任务,视频队列并发为 1,与模型渲染串行;`MAX_PIXELS` 限 4096²。