@speclip/pi-talking-head 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -16
- package/extensions/talking-head/index.ts +171 -7
- package/package.json +1 -1
- package/prompts/edit-talking-head.md +1 -1
- package/skills/talking-head-edit/SKILL.md +11 -2
- package/skills/talking-head-edit/references/cut-craft.md +5 -0
- package/src/broll.ts +406 -0
- package/src/continuity.ts +355 -0
- package/src/contracts.ts +108 -1
- package/src/project.ts +58 -8
- package/src/workspace.ts +18 -4
package/README.md
CHANGED
|
@@ -71,33 +71,111 @@ talking_head_get {
|
|
|
71
71
|
|
|
72
72
|
只有调用这个工具时才会把这些证据放进当前会话上下文;安装 package 不会把整份转录常驻注入上下文。
|
|
73
73
|
|
|
74
|
-
### 3.
|
|
74
|
+
### 3. 先规划 B-roll 视觉连续性
|
|
75
|
+
|
|
76
|
+
在查找素材前,把最终 A-roll 和所有 B-roll 需求交给连续性规划工具:
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
talking_head_broll_plan {
|
|
80
|
+
projectId: "launch-video",
|
|
81
|
+
aroll: [
|
|
82
|
+
{ id: "hook", sourceStartMs: 50, sourceEndMs: 4120 },
|
|
83
|
+
{ id: "answer", sourceStartMs: 4860, sourceEndMs: 13200 }
|
|
84
|
+
],
|
|
85
|
+
needs: [
|
|
86
|
+
{
|
|
87
|
+
id: "product-a",
|
|
88
|
+
outputStartMs: 1000,
|
|
89
|
+
outputEndMs: 3000,
|
|
90
|
+
speechText: "第一步打开设置",
|
|
91
|
+
purpose: "demonstrate",
|
|
92
|
+
searchTerms: ["设置", "打开"],
|
|
93
|
+
reason: "展示第一步"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "product-b",
|
|
97
|
+
outputStartMs: 3300,
|
|
98
|
+
outputEndMs: 5200,
|
|
99
|
+
speechText: "第二步选择设备",
|
|
100
|
+
purpose: "demonstrate",
|
|
101
|
+
searchTerms: ["设备", "选择"],
|
|
102
|
+
reason: "展示第二步"
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
cutCoverBeforeMs: 250,
|
|
106
|
+
cutCoverAfterMs: 500
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
规划结果同时返回 `continuityPlanReceipt`,把当前项目 revision、A-roll、规划后的 B-roll 区间和跳点审阅结果绑定在一起。后续 `talking_head_apply` 会重新计算并核对它,不能跳过规划或把已经衔接的区间手动缩短。
|
|
111
|
+
|
|
112
|
+
规划结果处理两类问题:
|
|
113
|
+
|
|
114
|
+
- **B-roll 闪屏**:两个 B-roll 之间只露出不超过 500ms 的 A-roll 时,`plan.needs` 会把前一个需求延长到后一个需求的起点。后续分别选段后,两段 B-roll 会直接交接,不再闪回 A-roll。
|
|
115
|
+
- **气口剪辑跳转**:A-roll 相邻片段的源时间不连续时,会生成 `jumpCuts`。工具检查建议遮盖区间是否已被 B-roll 连续覆盖;未覆盖项标为 `needs-broll`,Agent 应结合口播语义补充 `purpose: "mask-cut"` 的需求,再重新规划。
|
|
116
|
+
|
|
117
|
+
规划只提供时间轴证据,不会假定每个剪辑点都必须加 B-roll。是否遮盖仍需结合实际画面判断。
|
|
118
|
+
|
|
119
|
+
### 4. 文件名优先筛选 B-roll
|
|
120
|
+
|
|
121
|
+
使用 `plan.needs` 中已经调整过的完整区间,再扫描指定素材目录:
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
talking_head_broll_match {
|
|
125
|
+
projectId: "launch-video",
|
|
126
|
+
assetDirectory: "assets/broll",
|
|
127
|
+
recursive: true,
|
|
128
|
+
maxFiles: 1000,
|
|
129
|
+
maxEntries: 20000,
|
|
130
|
+
maxDepth: 12,
|
|
131
|
+
maxCandidates: 5,
|
|
132
|
+
candidateOffset: 0,
|
|
133
|
+
need: plan.needs[0]
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
该工具只读取目录项和文件名,不解码、不探测、不哈希视频。它最多返回限定数量的候选,并给出三种结果:
|
|
138
|
+
|
|
139
|
+
- `filename-direct`:一个文件名唯一且明确命中,只检查这一条素材。
|
|
140
|
+
- `filename-shortlist`:多个名字可能匹配,只检查返回的 shortlist。
|
|
141
|
+
- `visual-fallback`:文件名没有有效语义,再对限定 shortlist 使用低成本联络表。
|
|
142
|
+
|
|
143
|
+
扫描同时受 `maxFiles`、`maxEntries` 和 `maxDepth` 约束并支持取消。完整扫描时,若当前 shortlist 都不合格,可使用非空的 `nextCandidateOffset` 读取下一批。结果一旦截断,工具不会声称唯一命中,也不会返回可复用的分页游标;此时应缩小素材目录后重扫,避免文件系统枚举顺序造成候选漂移。
|
|
144
|
+
|
|
145
|
+
确定素材后才调用 `media_probe` 和 `media_contact_sheet`。长素材先低密度定位大致范围,再只对候选范围高密度抽帧;必须使用 `contact_sheet_manifest.json` 的真实时间戳,不能从 PNG 猜时间。找到连续可用且覆盖完整成片窗口的片段后,验证并生成 placement:
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
talking_head_broll_select {
|
|
149
|
+
projectId: "launch-video",
|
|
150
|
+
need: { /* 与 match 时相同 */ },
|
|
151
|
+
assetPath: "assets/broll/mouse-demo.mp4",
|
|
152
|
+
manifestPath: "analysis/mouse-demo/contact_sheet_manifest.json",
|
|
153
|
+
selectedStartMs: 12400,
|
|
154
|
+
evidenceTimestampsMs: [12400, 13900, 15400],
|
|
155
|
+
fit: "cover"
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
该工具会验证素材 SHA-256、manifest 分析范围、起始帧和覆盖片段尾部的证据时间戳,返回可直接交给 `talking_head_apply` 的完整 placement。placement 内含选择凭证;不要手写或删除其中字段。
|
|
160
|
+
|
|
161
|
+
### 5. 写入人工确认后的时间线
|
|
75
162
|
|
|
76
163
|
```js
|
|
77
164
|
talking_head_apply {
|
|
78
165
|
projectId: "launch-video",
|
|
79
166
|
expectedRevision: 1,
|
|
80
|
-
|
|
167
|
+
aroll: [
|
|
81
168
|
{ id: "hook", sourceStartMs: 50, sourceEndMs: 4120 },
|
|
82
169
|
{ id: "answer", sourceStartMs: 4860, sourceEndMs: 13200 }
|
|
83
170
|
],
|
|
84
|
-
broll: [
|
|
85
|
-
|
|
86
|
-
assetPath: "assets/product-demo.mp4",
|
|
87
|
-
outputStartMs: 5200,
|
|
88
|
-
outputEndMs: 7900,
|
|
89
|
-
assetStartMs: 0,
|
|
90
|
-
fit: "cover",
|
|
91
|
-
audio: "keep-primary",
|
|
92
|
-
query: "产品界面操作特写",
|
|
93
|
-
reason: "具体展示口播中提到的三步操作"
|
|
94
|
-
}]
|
|
171
|
+
broll: [selectionA.placement, selectionB.placement],
|
|
172
|
+
continuityPlanReceipt
|
|
95
173
|
}
|
|
96
174
|
```
|
|
97
175
|
|
|
98
|
-
B-roll
|
|
176
|
+
B-roll 使用成片时间轴定位,`assetStartMs` 来自联络表 manifest,并永远保留主口播音轨。`talking_head_apply` 会重新校验连续性规划凭证、选段凭证、素材与 manifest 的 SHA-256;规划区间或时间点被手改、素材被替换都会拒绝写入新修订。若两个 B-roll 之间仍存在不超过 500ms 的 A-roll,也会拒绝写入并要求重新规划。当前不支持 B-roll 相互重叠,因为未定义 z-order。
|
|
99
177
|
|
|
100
|
-
###
|
|
178
|
+
### 6. 交给 pi-media 渲染
|
|
101
179
|
|
|
102
180
|
先用同一个源文件创建 `pi-media` 项目,再把上一步的 `mediaOperation` 原样传入:
|
|
103
181
|
|
|
@@ -125,8 +203,11 @@ review { path: "out/launch-final.mp4" }
|
|
|
125
203
|
| --- | --- |
|
|
126
204
|
| `talking_head_create` | 从视频和词级转录建立 revision 1,分析句子、语气词、重复和停顿并生成默认 EDL |
|
|
127
205
|
| `talking_head_get` | 读取指定 revision,分页返回整句与编辑候选,可选导出 pi-media EDL |
|
|
206
|
+
| `talking_head_broll_plan` | 衔接相邻 B-roll、识别 A-roll 跳点并报告尚未遮盖的剪辑区间 |
|
|
207
|
+
| `talking_head_broll_match` | 只用文件名和目录名匹配本地 B-roll,返回受限 shortlist 与视觉升级建议 |
|
|
208
|
+
| `talking_head_broll_select` | 用 pi-media 联络表 manifest 验证具体源时间段并生成 placement |
|
|
128
209
|
| `talking_head_apply` | 写入新的不可变口播 revision,并返回 pi-media EDL |
|
|
129
210
|
|
|
130
211
|
## 当前边界
|
|
131
212
|
|
|
132
|
-
|
|
213
|
+
当前版本不负责语音转录、声学情绪识别、联网素材搜索、字幕、画面理解或渲染。它提供整句文本、时间轴和本地素材名称层面的编辑证据;需要依赖真实语气、呼吸、表演意图或画面内容的决定,必须由 Agent 结合原音频、联络表和画面复核。最终 B-roll 仍写入同一份 `broll` 数据并由 `pi-media` 渲染。
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
+
import { matchWorkspaceBrollAssets, selectBrollWindow } from "../../src/broll.ts";
|
|
4
|
+
import { createBrollContinuityPlanReceipt, planBrollContinuity } from "../../src/continuity.ts";
|
|
3
5
|
import { toMediaTimelineOperation } from "../../src/edl.ts";
|
|
4
6
|
import {
|
|
5
7
|
applyTimeline,
|
|
@@ -22,7 +24,7 @@ const stableId = Type.String({
|
|
|
22
24
|
pattern: "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$",
|
|
23
25
|
});
|
|
24
26
|
|
|
25
|
-
const
|
|
27
|
+
const arollSegment = Type.Object({
|
|
26
28
|
id: stableId,
|
|
27
29
|
sourceStartMs: Type.Number({ minimum: 0 }),
|
|
28
30
|
sourceEndMs: Type.Number({ exclusiveMinimum: 0 }),
|
|
@@ -33,11 +35,64 @@ const brollPlacement = Type.Object({
|
|
|
33
35
|
assetPath: Type.String({ description: "Workspace-relative B-roll video path." }),
|
|
34
36
|
outputStartMs: Type.Number({ minimum: 0 }),
|
|
35
37
|
outputEndMs: Type.Number({ exclusiveMinimum: 0 }),
|
|
36
|
-
assetStartMs: Type.
|
|
38
|
+
assetStartMs: Type.Number({ minimum: 0, description: "Required manifest-backed source timestamp selected from the B-roll asset." }),
|
|
37
39
|
fit: Type.Union([Type.Literal("cover"), Type.Literal("contain")]),
|
|
38
40
|
audio: Type.Literal("keep-primary", { description: "B-roll never replaces the talking-head audio." }),
|
|
39
41
|
query: Type.Optional(Type.String({ maxLength: 500 })),
|
|
40
42
|
reason: Type.Optional(Type.String({ maxLength: 1_000 })),
|
|
43
|
+
selectionReceipt: Type.Object({
|
|
44
|
+
assetBytes: Type.Integer({ minimum: 0 }),
|
|
45
|
+
assetSha256: Type.String({ pattern: "^[a-f0-9]{64}$" }),
|
|
46
|
+
manifestPath: Type.String({ minLength: 1 }),
|
|
47
|
+
manifestSha256: Type.String({ pattern: "^[a-f0-9]{64}$" }),
|
|
48
|
+
selectedEndMs: Type.Number({ minimum: 0 }),
|
|
49
|
+
evidenceTimestampsMs: Type.Array(Type.Number({ minimum: 0 }), { minItems: 1, maxItems: 100 }),
|
|
50
|
+
}, { additionalProperties: false }),
|
|
51
|
+
}, { additionalProperties: false });
|
|
52
|
+
|
|
53
|
+
const brollNeed = Type.Object({
|
|
54
|
+
id: stableId,
|
|
55
|
+
outputStartMs: Type.Number({ minimum: 0 }),
|
|
56
|
+
outputEndMs: Type.Number({ exclusiveMinimum: 0 }),
|
|
57
|
+
speechText: Type.String({ minLength: 1, maxLength: 2_000 }),
|
|
58
|
+
purpose: Type.Union([
|
|
59
|
+
Type.Literal("demonstrate"),
|
|
60
|
+
Type.Literal("explain"),
|
|
61
|
+
Type.Literal("evidence"),
|
|
62
|
+
Type.Literal("establish"),
|
|
63
|
+
Type.Literal("transition"),
|
|
64
|
+
Type.Literal("mask-cut"),
|
|
65
|
+
]),
|
|
66
|
+
searchTerms: Type.Array(Type.String({ minLength: 1, maxLength: 100 }), { minItems: 1, maxItems: 20 }),
|
|
67
|
+
reason: Type.String({ minLength: 1, maxLength: 1_000 }),
|
|
68
|
+
}, { additionalProperties: false });
|
|
69
|
+
|
|
70
|
+
const arollJumpCut = Type.Object({
|
|
71
|
+
fromSegmentId: stableId,
|
|
72
|
+
toSegmentId: stableId,
|
|
73
|
+
outputTimeMs: Type.Number({ minimum: 0 }),
|
|
74
|
+
sourceDeltaMs: Type.Number(),
|
|
75
|
+
suggestedOutputStartMs: Type.Number({ minimum: 0 }),
|
|
76
|
+
suggestedOutputEndMs: Type.Number({ minimum: 0 }),
|
|
77
|
+
coveredByNeedIds: Type.Array(stableId, { maxItems: 500 }),
|
|
78
|
+
status: Type.Union([Type.Literal("covered"), Type.Literal("needs-broll")]),
|
|
79
|
+
}, { additionalProperties: false });
|
|
80
|
+
|
|
81
|
+
const continuityPlanReceipt = Type.Object({
|
|
82
|
+
schemaVersion: Type.Literal(1),
|
|
83
|
+
projectId: stableId,
|
|
84
|
+
revision: Type.Integer({ minimum: 1 }),
|
|
85
|
+
arollSha256: Type.String({ pattern: "^[a-f0-9]{64}$" }),
|
|
86
|
+
shortGapMs: Type.Integer({ minimum: 0, maximum: 2_000 }),
|
|
87
|
+
cutCoverBeforeMs: Type.Integer({ minimum: 0, maximum: 2_000 }),
|
|
88
|
+
cutCoverAfterMs: Type.Integer({ minimum: 0, maximum: 2_000 }),
|
|
89
|
+
needs: Type.Array(Type.Object({
|
|
90
|
+
id: stableId,
|
|
91
|
+
outputStartMs: Type.Number({ minimum: 0 }),
|
|
92
|
+
outputEndMs: Type.Number({ exclusiveMinimum: 0 }),
|
|
93
|
+
}, { additionalProperties: false }), { maxItems: 500 }),
|
|
94
|
+
jumpCuts: Type.Array(arollJumpCut, { maxItems: 999 }),
|
|
95
|
+
planSha256: Type.String({ pattern: "^[a-f0-9]{64}$" }),
|
|
41
96
|
}, { additionalProperties: false });
|
|
42
97
|
|
|
43
98
|
export default function talkingHead(pi: ExtensionAPI): void {
|
|
@@ -53,7 +108,7 @@ export default function talkingHead(pi: ExtensionAPI): void {
|
|
|
53
108
|
headPaddingMs: Type.Optional(Type.Number({ minimum: 30, maximum: 200 })),
|
|
54
109
|
tailPaddingMs: Type.Optional(Type.Number({ minimum: 30, maximum: 200 })),
|
|
55
110
|
}, { additionalProperties: false }),
|
|
56
|
-
async execute(_toolCallId, params,
|
|
111
|
+
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
57
112
|
const policy = {
|
|
58
113
|
...(params.cutThresholdMs === undefined ? {} : { cutThresholdMs: params.cutThresholdMs }),
|
|
59
114
|
...(params.headPaddingMs === undefined ? {} : { headPaddingMs: params.headPaddingMs }),
|
|
@@ -142,19 +197,128 @@ export default function talkingHead(pi: ExtensionAPI): void {
|
|
|
142
197
|
},
|
|
143
198
|
});
|
|
144
199
|
|
|
200
|
+
pi.registerTool({
|
|
201
|
+
name: "talking_head_broll_plan",
|
|
202
|
+
label: "Plan B-roll visual continuity",
|
|
203
|
+
description: "Plan B-roll windows before asset matching. Bridges brief A-roll flashes between neighboring B-roll needs and reports A-roll source jump cuts that still need a mask-cut B-roll.",
|
|
204
|
+
parameters: Type.Object({
|
|
205
|
+
projectId: stableId,
|
|
206
|
+
revision: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
207
|
+
aroll: Type.Array(arollSegment, { minItems: 1, maxItems: 1_000 }),
|
|
208
|
+
needs: Type.Array(brollNeed, { maxItems: 500 }),
|
|
209
|
+
cutCoverBeforeMs: Type.Optional(Type.Integer({ minimum: 0, maximum: 2_000, default: 250 })),
|
|
210
|
+
cutCoverAfterMs: Type.Optional(Type.Integer({ minimum: 0, maximum: 2_000, default: 500 })),
|
|
211
|
+
}, { additionalProperties: false }),
|
|
212
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
213
|
+
const { snapshot } = await getTalkingHeadProject(ctx.cwd, params.projectId, params.revision);
|
|
214
|
+
const plan = planBrollContinuity({
|
|
215
|
+
aroll: params.aroll,
|
|
216
|
+
needs: params.needs,
|
|
217
|
+
...(params.cutCoverBeforeMs === undefined ? {} : { cutCoverBeforeMs: params.cutCoverBeforeMs }),
|
|
218
|
+
...(params.cutCoverAfterMs === undefined ? {} : { cutCoverAfterMs: params.cutCoverAfterMs }),
|
|
219
|
+
});
|
|
220
|
+
return result({
|
|
221
|
+
projectId: params.projectId,
|
|
222
|
+
revision: snapshot.revision,
|
|
223
|
+
plan,
|
|
224
|
+
continuityPlanReceipt: createBrollContinuityPlanReceipt(
|
|
225
|
+
params.projectId,
|
|
226
|
+
snapshot.revision,
|
|
227
|
+
params.aroll,
|
|
228
|
+
plan,
|
|
229
|
+
),
|
|
230
|
+
nextStep: plan.jumpCuts.some((cut) => cut.status === "needs-broll")
|
|
231
|
+
? "Create purpose=mask-cut needs for uncovered jump cuts, then run this planner again before asset matching."
|
|
232
|
+
: "Use plan.needs for B-roll asset matching and source-window selection.",
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
pi.registerTool({
|
|
238
|
+
name: "talking_head_broll_match",
|
|
239
|
+
label: "Match local B-roll assets",
|
|
240
|
+
description: "Filename-first B-roll matching for one approved output window. Scans only directory metadata, returns a bounded shortlist, and tells the Agent whether to inspect one selected asset, inspect an ambiguous shortlist, or fall back to low-cost visual screening. It never decodes, probes, or hashes video contents.",
|
|
241
|
+
parameters: Type.Object({
|
|
242
|
+
projectId: stableId,
|
|
243
|
+
revision: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
244
|
+
assetDirectory: Type.String({ minLength: 1, description: "Workspace-relative directory containing candidate B-roll videos." }),
|
|
245
|
+
recursive: Type.Optional(Type.Boolean()),
|
|
246
|
+
maxFiles: Type.Optional(Type.Integer({ minimum: 1, maximum: 5_000 })),
|
|
247
|
+
maxEntries: Type.Optional(Type.Integer({ minimum: 1, maximum: 100_000 })),
|
|
248
|
+
maxDepth: Type.Optional(Type.Integer({ minimum: 0, maximum: 50 })),
|
|
249
|
+
maxCandidates: Type.Optional(Type.Integer({ minimum: 1, maximum: 20 })),
|
|
250
|
+
candidateOffset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
251
|
+
need: brollNeed,
|
|
252
|
+
}, { additionalProperties: false }),
|
|
253
|
+
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
254
|
+
const { snapshot } = await getTalkingHeadProject(ctx.cwd, params.projectId, params.revision);
|
|
255
|
+
if (params.need.outputEndMs > snapshot.outputDurationMs) {
|
|
256
|
+
throw new Error(`B-roll need ${params.need.id} exceeds output duration ${snapshot.outputDurationMs}ms`);
|
|
257
|
+
}
|
|
258
|
+
const match = await matchWorkspaceBrollAssets(ctx.cwd, {
|
|
259
|
+
assetDirectory: params.assetDirectory,
|
|
260
|
+
...(params.recursive === undefined ? {} : { recursive: params.recursive }),
|
|
261
|
+
...(params.maxFiles === undefined ? {} : { maxFiles: params.maxFiles }),
|
|
262
|
+
...(params.maxEntries === undefined ? {} : { maxEntries: params.maxEntries }),
|
|
263
|
+
...(params.maxDepth === undefined ? {} : { maxDepth: params.maxDepth }),
|
|
264
|
+
...(params.maxCandidates === undefined ? {} : { maxCandidates: params.maxCandidates }),
|
|
265
|
+
...(params.candidateOffset === undefined ? {} : { candidateOffset: params.candidateOffset }),
|
|
266
|
+
need: params.need,
|
|
267
|
+
...(signal === undefined ? {} : { signal }),
|
|
268
|
+
});
|
|
269
|
+
return result({
|
|
270
|
+
projectId: params.projectId,
|
|
271
|
+
revision: snapshot.revision,
|
|
272
|
+
match,
|
|
273
|
+
...(match.truncated ? { warning: `The bounded scan stopped after ${match.scannedEntryCount} entries and ${match.scannedFileCount} video filenames; filename-direct is disabled until the asset directory is narrowed or fully scanned.` } : {}),
|
|
274
|
+
});
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
pi.registerTool({
|
|
279
|
+
name: "talking_head_broll_select",
|
|
280
|
+
label: "Select B-roll source window",
|
|
281
|
+
description: "Validate one exact B-roll source window against a pi-media contact_sheet_manifest.json. Verifies the selected asset hash, analyzed range, and manifest-backed evidence timestamps, then returns a placement ready for talking_head_apply.",
|
|
282
|
+
parameters: Type.Object({
|
|
283
|
+
projectId: stableId,
|
|
284
|
+
revision: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
285
|
+
need: brollNeed,
|
|
286
|
+
assetPath: Type.String({ minLength: 1 }),
|
|
287
|
+
manifestPath: Type.String({ minLength: 1 }),
|
|
288
|
+
selectedStartMs: Type.Number({ minimum: 0 }),
|
|
289
|
+
evidenceTimestampsMs: Type.Array(Type.Number({ minimum: 0 }), { minItems: 1, maxItems: 100 }),
|
|
290
|
+
fit: Type.Union([Type.Literal("cover"), Type.Literal("contain")]),
|
|
291
|
+
}, { additionalProperties: false }),
|
|
292
|
+
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
293
|
+
const { snapshot } = await getTalkingHeadProject(ctx.cwd, params.projectId, params.revision);
|
|
294
|
+
if (params.need.outputEndMs > snapshot.outputDurationMs) {
|
|
295
|
+
throw new Error(`B-roll need ${params.need.id} exceeds output duration ${snapshot.outputDurationMs}ms`);
|
|
296
|
+
}
|
|
297
|
+
return result({
|
|
298
|
+
projectId: params.projectId,
|
|
299
|
+
revision: snapshot.revision,
|
|
300
|
+
selection: await selectBrollWindow(ctx.cwd, {
|
|
301
|
+
...params,
|
|
302
|
+
...(signal === undefined ? {} : { signal }),
|
|
303
|
+
}),
|
|
304
|
+
});
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
|
|
145
308
|
pi.registerTool({
|
|
146
309
|
name: "talking_head_apply",
|
|
147
310
|
label: "Apply talking-head timeline",
|
|
148
|
-
description: "Create a new immutable talking-head revision from word-boundary A-roll ranges and optional B-roll placements. Returns a generic pi-media timeline operation ready for edit_apply.",
|
|
311
|
+
description: "Create a new immutable talking-head revision from word-boundary A-roll ranges and optional B-roll placements. B-roll requires the matching continuity plan receipt; brief A-roll flashes, unplanned ranges, and overlapping B-roll are rejected. Returns a generic pi-media timeline operation ready for edit_apply.",
|
|
149
312
|
parameters: Type.Object({
|
|
150
313
|
projectId: stableId,
|
|
151
314
|
expectedRevision: Type.Integer({ minimum: 1 }),
|
|
152
|
-
aroll: Type.Array(
|
|
315
|
+
aroll: Type.Array(arollSegment, { minItems: 1, maxItems: 1_000 }),
|
|
153
316
|
broll: Type.Array(brollPlacement, { maxItems: 500 }),
|
|
317
|
+
continuityPlanReceipt: Type.Optional(continuityPlanReceipt),
|
|
154
318
|
}, { additionalProperties: false }),
|
|
155
|
-
async execute(_toolCallId, params,
|
|
319
|
+
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
156
320
|
const current = await getTalkingHeadProject(ctx.cwd, params.projectId);
|
|
157
|
-
const snapshot = await applyTimeline(ctx.cwd, params);
|
|
321
|
+
const snapshot = await applyTimeline(ctx.cwd, params, signal);
|
|
158
322
|
return result({
|
|
159
323
|
projectId: params.projectId,
|
|
160
324
|
snapshot,
|
package/package.json
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
description: Tighten a talking-head video without destroying natural speech rhythm
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
Use the `talking-head-edit` skill to review full-sentence context, word-level pauses, filler words, adjacent repetitions, and low-confidence delivery cues;
|
|
5
|
+
Use the `talking-head-edit` skill to review full-sentence context, word-level pauses, filler words, adjacent repetitions, and low-confidence delivery cues; stabilize A-roll, plan B-roll continuity to bridge brief A-roll flashes and mask objectionable jump cuts, match B-roll by filename before escalating through paged contact-sheet batches, validate the selected manifest-backed source window, and export a generic pi-media EDL for this request: $@
|
|
6
6
|
|
|
7
7
|
Show the proposed rhythm before writing a new revision. Never overwrite the source or an existing render.
|
|
@@ -12,8 +12,17 @@ Use `pi-speech` for word evidence, this package for editorial decisions, and `pi
|
|
|
12
12
|
3. Inspect bounded `talking_head_get` pages. Review the full sentence context, filler candidates, and repetition candidates together with pauses. Treat `safe` and every recommendation as evidence, not an instruction. Preserve pauses that carry emphasis, emotion, topic boundaries, or a deliberate breath.
|
|
13
13
|
4. Never delete a filler token automatically. Decide whether `啊`, `额`, `嗯`, or a repeated token is a false start, a discourse marker, or intentional emphasis from its sentence context. A text-only delivery cue is low-confidence evidence; review audio and picture before relying on emotion or performance intent.
|
|
14
14
|
5. Before changing the revision, summarize the proposed rhythm: what words and gaps will be removed, which pauses or fillers will remain, and why. Get the user's approval unless they explicitly delegated editorial judgment.
|
|
15
|
-
6.
|
|
16
|
-
7.
|
|
15
|
+
6. Stabilize A-roll before B-roll. For every B-roll window, record the output range, complete spoken text, one purpose (`demonstrate`, `explain`, `evidence`, `establish`, `transition`, or `mask-cut`), 1-20 concise search terms, and a concrete reason.
|
|
16
|
+
7. Call `talking_head_broll_plan` with the final proposed A-roll and all semantic B-roll needs before matching assets. Keep its `continuityPlanReceipt` unchanged. Use the returned `plan.needs`: it extends the previous B-roll across A-roll gaps of 500ms or less so neighboring B-roll clips hand off directly. Review every reported A-roll jump cut. Add a `purpose: mask-cut` need over each visually objectionable uncovered cut, using the suggested output range, then rerun the plan. Do not create meaningless B-roll solely because a cut exists; picture review remains the editorial gate.
|
|
17
|
+
8. Call `talking_head_broll_match` before generating contact sheets. Follow its bounded result:
|
|
18
|
+
- `filename-direct`: probe and visually inspect only the selected asset to choose its source window. Do not call `media_contact_sheet` for unselected assets.
|
|
19
|
+
- `filename-shortlist`: inspect only the returned shortlist and stop as soon as one asset satisfies the need. If none does and `nextCandidateOffset` is non-null, request that next page; do not repeat the first batch.
|
|
20
|
+
- `visual-fallback`: use low-cost contact sheets on the bounded shortlist because filenames supplied no useful evidence. Exhaust that batch before requesting a non-null `nextCandidateOffset`.
|
|
21
|
+
- If the scan is truncated, do not paginate it: narrow the asset directory and rescan so the candidate inventory is stable.
|
|
22
|
+
9. After selecting one asset, call `media_probe`, then use `media_contact_sheet` only as densely as timing requires: one high-density pass for a short ambiguous clip, medium for a normal clip, or low over a long clip followed by high density over the narrowed range. Read `contact_sheet_manifest.json` timestamps instead of guessing times from the PNG. Verify a continuous source window at least as long as the planned output window, preferably with 500ms handles on both sides.
|
|
23
|
+
10. Call `talking_head_broll_select` with each planned need, selected asset, manifest path, exact source start, and the manifest timestamps actually reviewed. Use its complete returned `placement`, including `selectionReceipt`; do not shorten bridged output ranges or hand-author selection fields.
|
|
24
|
+
11. Call `talking_head_apply` using the same planned A-roll, every validated B-roll placement, and the unchanged `continuityPlanReceipt`. The tool rejects unplanned ranges, B-roll overlaps, and A-roll flashes of 500ms or less. Every B-roll window must have a concrete visual purpose in `reason`; keep `audio: keep-primary`.
|
|
25
|
+
12. Create/read a `pi-media` project for the same source. Pass the returned `mediaOperation` unchanged to `edit_apply`, then `render` the exact new revision and call `review`.
|
|
17
26
|
|
|
18
27
|
Never overwrite source media or outputs. If a revision conflict occurs, re-read both projects and reconcile intent. If the source, transcript, or B-roll hash changed, stop and ask whether to create a new project rather than silently adopting new bytes.
|
|
19
28
|
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
|
|
20
20
|
- Place B-roll on the output timeline after A-roll cuts have stabilized.
|
|
21
21
|
- Use it to show the object, action, place, comparison, or evidence currently being discussed—not as random decoration.
|
|
22
|
+
- Treat a filename match as asset-level evidence, never as proof that a particular source window is usable. Inspect continuous motion before selecting `assetStartMs`.
|
|
23
|
+
- Start with filename and directory metadata. Generate contact sheets only for the selected asset, a bounded ambiguous shortlist, or a bounded fallback batch whose names carry no meaning.
|
|
24
|
+
- For a long selected asset, locate a broad range cheaply and then generate a denser contact sheet only for that range. Use manifest timestamps, not visual timestamp transcription.
|
|
25
|
+
- Ensure the selected source window covers the complete spoken beat. Prefer extra source handles so a later timing adjustment does not require rescanning.
|
|
26
|
+
- If neighboring B-roll windows expose 500ms or less of A-roll, plan a direct handoff by extending the previous B-roll need before source-window selection. Do not let a few frames of A-roll flash between overlays.
|
|
22
27
|
- Cover visible jump cuts when appropriate, but do not hide continuity errors that change meaning.
|
|
23
28
|
- Keep the primary voice track. B-roll audio replacement is outside the current contract.
|
|
24
29
|
- Record the search query and editorial reason so a later agent can replace the asset without guessing intent.
|