davinci-resolve-mcp 2.23.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/AGENTS.md +85 -0
- package/CHANGELOG.md +802 -0
- package/CLAUDE.md +15 -0
- package/LICENSE +21 -0
- package/README.md +159 -0
- package/SECURITY.md +53 -0
- package/bin/davinci-resolve-mcp.mjs +376 -0
- package/docs/README.md +56 -0
- package/docs/SKILL.md +1145 -0
- package/docs/authoring/fuse-dctl-authoring.md +242 -0
- package/docs/authoring/script-plugin-authoring.md +195 -0
- package/docs/contributing.md +82 -0
- package/docs/guides/color-decision-guide.md +387 -0
- package/docs/guides/editorial-decision-guide.md +136 -0
- package/docs/guides/media-analysis-guide.md +615 -0
- package/docs/guides/multicam-setup-guide.md +138 -0
- package/docs/install.md +198 -0
- package/docs/integrations/workflow-integrations.md +120 -0
- package/docs/kernels/README.md +28 -0
- package/docs/kernels/audio-fairlight-kernel.md +86 -0
- package/docs/kernels/color-grade-kernel.md +103 -0
- package/docs/kernels/extension-authoring-kernel.md +101 -0
- package/docs/kernels/fusion-composition-kernel.md +91 -0
- package/docs/kernels/media-pool-ingest-kernel.md +147 -0
- package/docs/kernels/project-lifecycle-kernel.md +120 -0
- package/docs/kernels/render-deliver-kernel.md +92 -0
- package/docs/kernels/review-annotation-kernel.md +110 -0
- package/docs/kernels/timeline-conform-interchange-kernel.md +99 -0
- package/docs/kernels/timeline-edit-kernel.md +189 -0
- package/docs/notes/codec-plugin-notes.md +136 -0
- package/docs/notes/dctl-notes.md +234 -0
- package/docs/notes/fusion-template-notes.md +136 -0
- package/docs/notes/lut-notes.md +136 -0
- package/docs/notes/openfx-notes.md +120 -0
- package/docs/process/release-process.md +152 -0
- package/docs/reference/api-coverage.md +488 -0
- package/docs/reference/resolve_scripting_api.txt +1012 -0
- package/examples/README.md +53 -0
- package/examples/markers/README.md +81 -0
- package/examples/media/README.md +94 -0
- package/examples/timeline/README.md +98 -0
- package/install.py +1196 -0
- package/package.json +52 -0
- package/scripts/audit_api_parity.py +275 -0
- package/scripts/live_media_analysis_polish_probe.py +65 -0
- package/src/__init__.py +3 -0
- package/src/analysis_dashboard.py +4936 -0
- package/src/control_panel.py +13 -0
- package/src/granular/__init__.py +17 -0
- package/src/granular/common.py +727 -0
- package/src/granular/folder.py +287 -0
- package/src/granular/gallery.py +306 -0
- package/src/granular/graph.py +309 -0
- package/src/granular/media_pool.py +679 -0
- package/src/granular/media_pool_item.py +852 -0
- package/src/granular/media_storage.py +179 -0
- package/src/granular/project.py +1594 -0
- package/src/granular/resolve_control.py +521 -0
- package/src/granular/timeline.py +1074 -0
- package/src/granular/timeline_item.py +2251 -0
- package/src/resolve_mcp_server.py +43 -0
- package/src/server.py +15691 -0
- package/src/utils/__init__.py +3 -0
- package/src/utils/app_control.py +319 -0
- package/src/utils/audio_fairlight_live_probe.py +263 -0
- package/src/utils/cdl.py +20 -0
- package/src/utils/cloud_operations.py +192 -0
- package/src/utils/color_grade_live_probe.py +444 -0
- package/src/utils/dctl_templates.py +368 -0
- package/src/utils/extension_authoring_live_probe.py +292 -0
- package/src/utils/fuse_templates.py +1968 -0
- package/src/utils/fusion_composition_live_probe.py +284 -0
- package/src/utils/layout_presets.py +333 -0
- package/src/utils/mcp_stdio.py +32 -0
- package/src/utils/media_analysis.py +3618 -0
- package/src/utils/media_analysis_jobs.py +796 -0
- package/src/utils/media_pool_ingest_live_probe.py +592 -0
- package/src/utils/multicam.py +393 -0
- package/src/utils/object_inspection.py +287 -0
- package/src/utils/platform.py +157 -0
- package/src/utils/project_lifecycle_live_probe.py +376 -0
- package/src/utils/project_properties.py +601 -0
- package/src/utils/render_deliver_live_probe.py +384 -0
- package/src/utils/resolve_connection.py +77 -0
- package/src/utils/review_annotation_live_probe.py +352 -0
- package/src/utils/script_templates.py +1193 -0
- package/src/utils/sync_detection.py +887 -0
- package/src/utils/timeline_conform_live_probe.py +280 -0
- package/src/utils/timeline_kernel_live_probe.py +1091 -0
- package/src/utils/timeline_kernel_probe.py +185 -0
- package/src/utils/timeline_title_text.py +87 -0
- package/src/utils/update_check.py +610 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Boilerplate generators for DCTL files (DaVinci Color Transform Language).
|
|
3
|
+
|
|
4
|
+
DCTL is a C-like, GPU-compiled pixel shader language used by Resolve as
|
|
5
|
+
programmable color transforms, the ResolveFX DCTL plugin, DCTL transitions,
|
|
6
|
+
and custom ACES IDT/ODT transforms. See docs/notes/dctl-notes.md for the full
|
|
7
|
+
spec; this module just emits ready-to-install source.
|
|
8
|
+
|
|
9
|
+
After installing a DCTL, call project_settings(action='refresh_luts') to make
|
|
10
|
+
Resolve re-scan its LUT directory. ACES DCTLs are scanned only at startup.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from typing import Any, Dict, List, Optional
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def header(name: str, kind: str) -> str:
|
|
17
|
+
"""Marker comment used by the dctl tool's `list` action."""
|
|
18
|
+
return (
|
|
19
|
+
f"// @mcp-dctl name={name} kind={kind}\n"
|
|
20
|
+
"// Generated by davinci-resolve-mcp. The marker above only affects\n"
|
|
21
|
+
"// how `dctl list` reports this file.\n\n"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# UI-parameter type → pretty-printed DCTL keyword.
|
|
26
|
+
DCTL_UI_TYPES = {
|
|
27
|
+
"float": "DCTLUI_SLIDER_FLOAT",
|
|
28
|
+
"int": "DCTLUI_SLIDER_INT",
|
|
29
|
+
"value": "DCTLUI_VALUE_BOX",
|
|
30
|
+
"checkbox": "DCTLUI_CHECK_BOX",
|
|
31
|
+
"combo": "DCTLUI_COMBO_BOX",
|
|
32
|
+
"color": "DCTLUI_COLOR_PICKER",
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _render_ui_params(params: List[Dict[str, Any]]) -> str:
|
|
37
|
+
"""Render a list of param dicts as a `DEFINE_UI_PARAMS` block per param.
|
|
38
|
+
|
|
39
|
+
Each dict supports:
|
|
40
|
+
name (required) — identifier referenced inside transform()
|
|
41
|
+
label (optional, defaults to name)
|
|
42
|
+
type 'float'|'int'|'value'|'checkbox'|'combo'|'color' (default 'float')
|
|
43
|
+
default, min, max, step numeric defaults appropriate per type
|
|
44
|
+
tooltip optional string
|
|
45
|
+
"""
|
|
46
|
+
if not params:
|
|
47
|
+
return ""
|
|
48
|
+
lines = []
|
|
49
|
+
for prm in params:
|
|
50
|
+
pname = prm["name"]
|
|
51
|
+
label = prm.get("label", pname)
|
|
52
|
+
ptype = prm.get("type", "float")
|
|
53
|
+
if ptype not in DCTL_UI_TYPES:
|
|
54
|
+
raise ValueError(f"Invalid DCTL UI type '{ptype}'. "
|
|
55
|
+
f"Valid: {sorted(DCTL_UI_TYPES.keys())}")
|
|
56
|
+
kw = DCTL_UI_TYPES[ptype]
|
|
57
|
+
|
|
58
|
+
if ptype in ("float", "int", "value"):
|
|
59
|
+
default = prm.get("default", 1.0)
|
|
60
|
+
pmin = prm.get("min", 0.0)
|
|
61
|
+
pmax = prm.get("max", 4.0)
|
|
62
|
+
step = prm.get("step", 0.01 if ptype != "int" else 1)
|
|
63
|
+
lines.append(
|
|
64
|
+
f"DEFINE_UI_PARAMS({pname}, {label}, {kw}, "
|
|
65
|
+
f"{default}, {pmin}, {pmax}, {step})"
|
|
66
|
+
)
|
|
67
|
+
elif ptype == "checkbox":
|
|
68
|
+
default = int(bool(prm.get("default", 0)))
|
|
69
|
+
lines.append(f"DEFINE_UI_PARAMS({pname}, {label}, {kw}, {default})")
|
|
70
|
+
elif ptype == "combo":
|
|
71
|
+
default = prm.get("default", 0)
|
|
72
|
+
options = prm.get("options", [])
|
|
73
|
+
opts = ", ".join(options)
|
|
74
|
+
lines.append(f"DEFINE_UI_PARAMS({pname}, {label}, {kw}, {default}, {opts})")
|
|
75
|
+
elif ptype == "color":
|
|
76
|
+
r = prm.get("r", 1.0)
|
|
77
|
+
g = prm.get("g", 1.0)
|
|
78
|
+
b = prm.get("b", 1.0)
|
|
79
|
+
lines.append(f"DEFINE_UI_PARAMS({pname}, {label}, {kw}, {r}, {g}, {b})")
|
|
80
|
+
|
|
81
|
+
if "tooltip" in prm:
|
|
82
|
+
lines.append(f'DEFINE_UI_TOOLTIP({pname}, "{prm["tooltip"]}")')
|
|
83
|
+
return "\n".join(lines) + "\n\n"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def transform(name: str, options: Optional[Dict[str, Any]] = None) -> str:
|
|
87
|
+
"""Per-pixel transform DCTL with optional UI sliders.
|
|
88
|
+
|
|
89
|
+
options:
|
|
90
|
+
params: list of UI param dicts (see _render_ui_params).
|
|
91
|
+
Default exposes a single Gain slider.
|
|
92
|
+
body: transform body. Receives p_R, p_G, p_B and any UI params by
|
|
93
|
+
their declared name. Default: applies Gain uniformly.
|
|
94
|
+
|
|
95
|
+
The generated DCTL uses the float3 entry point (no alpha).
|
|
96
|
+
"""
|
|
97
|
+
options = options or {}
|
|
98
|
+
params = options.get("params")
|
|
99
|
+
if params is None:
|
|
100
|
+
params = [{"name": "p_Gain", "label": "Gain", "type": "float",
|
|
101
|
+
"default": 1.0, "min": 0.0, "max": 4.0, "step": 0.01}]
|
|
102
|
+
body = options.get("body") or (
|
|
103
|
+
" return make_float3(p_R * p_Gain, p_G * p_Gain, p_B * p_Gain);"
|
|
104
|
+
)
|
|
105
|
+
ui_block = _render_ui_params(params)
|
|
106
|
+
return header(name, "transform") + f'''{ui_block}__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y,
|
|
107
|
+
float p_R, float p_G, float p_B)
|
|
108
|
+
{{
|
|
109
|
+
{body}
|
|
110
|
+
}}
|
|
111
|
+
'''
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def transform_alpha(name: str, options: Optional[Dict[str, Any]] = None) -> str:
|
|
115
|
+
"""Per-pixel transform DCTL with alpha (Resolve 19.1+).
|
|
116
|
+
|
|
117
|
+
options:
|
|
118
|
+
params: list of UI param dicts (default: empty)
|
|
119
|
+
alpha_mode: 'straight' | 'premultiply' (default 'straight')
|
|
120
|
+
body: transform body returning a float4. Default passes through.
|
|
121
|
+
|
|
122
|
+
Sets the appropriate `DEFINE_DCTL_ALPHA_MODE_*` tag.
|
|
123
|
+
"""
|
|
124
|
+
options = options or {}
|
|
125
|
+
params = options.get("params") or []
|
|
126
|
+
alpha_mode = options.get("alpha_mode", "straight")
|
|
127
|
+
if alpha_mode not in ("straight", "premultiply"):
|
|
128
|
+
raise ValueError(f"Invalid alpha_mode '{alpha_mode}'. "
|
|
129
|
+
"Valid: straight, premultiply")
|
|
130
|
+
mode_tag = ("DEFINE_DCTL_ALPHA_MODE_STRAIGHT"
|
|
131
|
+
if alpha_mode == "straight"
|
|
132
|
+
else "DEFINE_DCTL_ALPHA_MODE_PREMULTIPLY")
|
|
133
|
+
body = options.get("body") or (
|
|
134
|
+
" return make_float4(p_R, p_G, p_B, p_A);"
|
|
135
|
+
)
|
|
136
|
+
ui_block = _render_ui_params(params)
|
|
137
|
+
return header(name, "transform_alpha") + f'''{ui_block}{mode_tag}
|
|
138
|
+
|
|
139
|
+
__DEVICE__ float4 transform(int p_Width, int p_Height, int p_X, int p_Y,
|
|
140
|
+
float p_R, float p_G, float p_B, float p_A)
|
|
141
|
+
{{
|
|
142
|
+
{body}
|
|
143
|
+
}}
|
|
144
|
+
'''
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def transition(name: str, options: Optional[Dict[str, Any]] = None) -> str:
|
|
148
|
+
"""DCTL transition. Blends From and To clips using TRANSITION_PROGRESS.
|
|
149
|
+
|
|
150
|
+
options:
|
|
151
|
+
body: transition body returning a float4. Default linear cross-dissolve.
|
|
152
|
+
|
|
153
|
+
The generated DCTL uses texture-based From and To inputs and reads the
|
|
154
|
+
global TRANSITION_PROGRESS value (0.0 to 1.0).
|
|
155
|
+
"""
|
|
156
|
+
options = options or {}
|
|
157
|
+
body = options.get("body") or ''' float fromR = _tex2D(p_FromTexR, p_X, p_Y);
|
|
158
|
+
float fromG = _tex2D(p_FromTexG, p_X, p_Y);
|
|
159
|
+
float fromB = _tex2D(p_FromTexB, p_X, p_Y);
|
|
160
|
+
float fromA = _tex2D(p_FromTexA, p_X, p_Y);
|
|
161
|
+
float toR = _tex2D(p_ToTexR, p_X, p_Y);
|
|
162
|
+
float toG = _tex2D(p_ToTexG, p_X, p_Y);
|
|
163
|
+
float toB = _tex2D(p_ToTexB, p_X, p_Y);
|
|
164
|
+
float toA = _tex2D(p_ToTexA, p_X, p_Y);
|
|
165
|
+
|
|
166
|
+
float t = TRANSITION_PROGRESS;
|
|
167
|
+
return make_float4(
|
|
168
|
+
fromR * (1.0f - t) + toR * t,
|
|
169
|
+
fromG * (1.0f - t) + toG * t,
|
|
170
|
+
fromB * (1.0f - t) + toB * t,
|
|
171
|
+
fromA * (1.0f - t) + toA * t);'''
|
|
172
|
+
return header(name, "transition") + f'''__DEVICE__ float4 transition(
|
|
173
|
+
int p_Width, int p_Height, int p_X, int p_Y,
|
|
174
|
+
__TEXTURE__ p_FromTexR, __TEXTURE__ p_FromTexG,
|
|
175
|
+
__TEXTURE__ p_FromTexB, __TEXTURE__ p_FromTexA,
|
|
176
|
+
__TEXTURE__ p_ToTexR, __TEXTURE__ p_ToTexG,
|
|
177
|
+
__TEXTURE__ p_ToTexB, __TEXTURE__ p_ToTexA)
|
|
178
|
+
{{
|
|
179
|
+
{body}
|
|
180
|
+
}}
|
|
181
|
+
'''
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def matrix(name: str, options: Optional[Dict[str, Any]] = None) -> str:
|
|
185
|
+
"""3x3 color matrix transform.
|
|
186
|
+
|
|
187
|
+
options:
|
|
188
|
+
matrix: nested 3x3 list of floats. Default = identity.
|
|
189
|
+
Order: [[Rr, Rg, Rb], [Gr, Gg, Gb], [Br, Bg, Bb]]
|
|
190
|
+
|
|
191
|
+
Embeds the matrix as constants and applies it as `out = M * in`.
|
|
192
|
+
"""
|
|
193
|
+
options = options or {}
|
|
194
|
+
m = options.get("matrix") or [[1.0, 0.0, 0.0],
|
|
195
|
+
[0.0, 1.0, 0.0],
|
|
196
|
+
[0.0, 0.0, 1.0]]
|
|
197
|
+
if (not isinstance(m, list) or len(m) != 3
|
|
198
|
+
or any(not isinstance(row, list) or len(row) != 3 for row in m)):
|
|
199
|
+
raise ValueError("matrix option must be a 3x3 nested list")
|
|
200
|
+
rows = ",\n ".join(
|
|
201
|
+
f"{{{', '.join(_f(x) for x in row)}}}" for row in m
|
|
202
|
+
)
|
|
203
|
+
return header(name, "matrix") + f'''__CONSTANT__ float M[3][3] = {{
|
|
204
|
+
{rows}
|
|
205
|
+
}};
|
|
206
|
+
|
|
207
|
+
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y,
|
|
208
|
+
float p_R, float p_G, float p_B)
|
|
209
|
+
{{
|
|
210
|
+
float r = M[0][0] * p_R + M[0][1] * p_G + M[0][2] * p_B;
|
|
211
|
+
float g = M[1][0] * p_R + M[1][1] * p_G + M[1][2] * p_B;
|
|
212
|
+
float b = M[2][0] * p_R + M[2][1] * p_G + M[2][2] * p_B;
|
|
213
|
+
return make_float3(r, g, b);
|
|
214
|
+
}}
|
|
215
|
+
'''
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def lut_apply(name: str, options: Optional[Dict[str, Any]] = None) -> str:
|
|
219
|
+
"""DCTL that loads an external .cube LUT and applies it.
|
|
220
|
+
|
|
221
|
+
options:
|
|
222
|
+
lut_path: relative or absolute path to a .cube file. The path is
|
|
223
|
+
resolved relative to the .dctl file's location.
|
|
224
|
+
Default: 'YourLut.cube' (placeholder — user must edit).
|
|
225
|
+
params: optional UI param list (mix amount, etc.).
|
|
226
|
+
body: transform body. Default applies the LUT directly.
|
|
227
|
+
|
|
228
|
+
Reference: docs/notes/dctl-notes.md → "LUTs Inside DCTL". Use APPLY_LUT(r, g, b,
|
|
229
|
+
name) to apply either an external cube or an inline DEFINE_CUBE_LUT.
|
|
230
|
+
"""
|
|
231
|
+
options = options or {}
|
|
232
|
+
lut_path = options.get("lut_path", "YourLut.cube")
|
|
233
|
+
params = options.get("params") or [
|
|
234
|
+
{"name": "p_Mix", "label": "Mix", "type": "float",
|
|
235
|
+
"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}
|
|
236
|
+
]
|
|
237
|
+
body = options.get("body") or ''' float lutR = p_R, lutG = p_G, lutB = p_B;
|
|
238
|
+
APPLY_LUT(lutR, lutG, lutB, ExternalLut);
|
|
239
|
+
return make_float3(
|
|
240
|
+
p_R + (lutR - p_R) * p_Mix,
|
|
241
|
+
p_G + (lutG - p_G) * p_Mix,
|
|
242
|
+
p_B + (lutB - p_B) * p_Mix);'''
|
|
243
|
+
ui_block = _render_ui_params(params)
|
|
244
|
+
return header(name, "lut_apply") + f'''DEFINE_LUT(ExternalLut, {lut_path})
|
|
245
|
+
|
|
246
|
+
{ui_block}__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y,
|
|
247
|
+
float p_R, float p_G, float p_B)
|
|
248
|
+
{{
|
|
249
|
+
{body}
|
|
250
|
+
}}
|
|
251
|
+
'''
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def aces_idt(name: str, options: Optional[Dict[str, Any]] = None) -> str:
|
|
255
|
+
"""ACES Input Device Transform. Installs to ACES Transforms/IDT/.
|
|
256
|
+
|
|
257
|
+
options:
|
|
258
|
+
parametric: bool — if true, emits the V1 parametric template stub
|
|
259
|
+
(DEFINE_ACES_PARAM). If false, non-parametric stub.
|
|
260
|
+
Default false.
|
|
261
|
+
body: transform body. Default passes through.
|
|
262
|
+
|
|
263
|
+
ACES DCTLs are scanned at Resolve startup, NOT through RefreshLUTList().
|
|
264
|
+
Install requires a Resolve restart. See docs/notes/dctl-notes.md → "DCTL And ACES".
|
|
265
|
+
"""
|
|
266
|
+
options = options or {}
|
|
267
|
+
parametric = bool(options.get("parametric", False))
|
|
268
|
+
body = options.get("body") or (
|
|
269
|
+
" return make_float3(p_R, p_G, p_B);"
|
|
270
|
+
)
|
|
271
|
+
aces_def = (
|
|
272
|
+
"DEFINE_ACES_PARAM(IS_PARAMETRIC_ACES_TRANSFORM: 1)"
|
|
273
|
+
if parametric
|
|
274
|
+
else "DEFINE_ACES_PARAM(IS_PARAMETRIC_ACES_TRANSFORM: 0)"
|
|
275
|
+
)
|
|
276
|
+
return header(name, "aces_idt") + f'''{aces_def}
|
|
277
|
+
|
|
278
|
+
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y,
|
|
279
|
+
float p_R, float p_G, float p_B)
|
|
280
|
+
{{
|
|
281
|
+
{body}
|
|
282
|
+
}}
|
|
283
|
+
'''
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def aces_odt(name: str, options: Optional[Dict[str, Any]] = None) -> str:
|
|
287
|
+
"""ACES Output Device Transform. Installs to ACES Transforms/ODT/.
|
|
288
|
+
|
|
289
|
+
Identical structure to aces_idt; the directory placement is what tells
|
|
290
|
+
Resolve which side of the pipeline this transform belongs to.
|
|
291
|
+
"""
|
|
292
|
+
options = options or {}
|
|
293
|
+
parametric = bool(options.get("parametric", False))
|
|
294
|
+
body = options.get("body") or (
|
|
295
|
+
" return make_float3(p_R, p_G, p_B);"
|
|
296
|
+
)
|
|
297
|
+
aces_def = (
|
|
298
|
+
"DEFINE_ACES_PARAM(IS_PARAMETRIC_ACES_TRANSFORM: 1)"
|
|
299
|
+
if parametric
|
|
300
|
+
else "DEFINE_ACES_PARAM(IS_PARAMETRIC_ACES_TRANSFORM: 0)"
|
|
301
|
+
)
|
|
302
|
+
return header(name, "aces_odt") + f'''{aces_def}
|
|
303
|
+
|
|
304
|
+
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y,
|
|
305
|
+
float p_R, float p_G, float p_B)
|
|
306
|
+
{{
|
|
307
|
+
{body}
|
|
308
|
+
}}
|
|
309
|
+
'''
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def kernel(name: str, options: Optional[Dict[str, Any]] = None) -> str:
|
|
313
|
+
"""Bare-bones DCTL with structured TODO comments.
|
|
314
|
+
|
|
315
|
+
Useful when the user wants to write the DCTL by hand but wants the
|
|
316
|
+
boilerplate (header, signature, alpha note) generated for them.
|
|
317
|
+
"""
|
|
318
|
+
options = options or {}
|
|
319
|
+
return header(name, "kernel") + f'''// TODO: Replace with your transform implementation.
|
|
320
|
+
// Reference: docs/notes/dctl-notes.md
|
|
321
|
+
//
|
|
322
|
+
// Useful globals:
|
|
323
|
+
// __RESOLVE_VER_MAJOR__, __RESOLVE_VER_MINOR__
|
|
324
|
+
// DEVICE_IS_CUDA / DEVICE_IS_OPENCL / DEVICE_IS_METAL
|
|
325
|
+
// TIMELINE_FRAME_INDEX (defaults to 1 when used as a LUT)
|
|
326
|
+
//
|
|
327
|
+
// Float literals must use the `f` suffix: 1.2f not 1.2
|
|
328
|
+
|
|
329
|
+
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y,
|
|
330
|
+
float p_R, float p_G, float p_B)
|
|
331
|
+
{{
|
|
332
|
+
// TODO
|
|
333
|
+
return make_float3(p_R, p_G, p_B);
|
|
334
|
+
}}
|
|
335
|
+
'''
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
def _f(x: float) -> str:
|
|
339
|
+
"""Format a float with the trailing 'f' suffix DCTL requires."""
|
|
340
|
+
s = f"{float(x):.6g}"
|
|
341
|
+
if "." not in s and "e" not in s and "n" not in s:
|
|
342
|
+
s += ".0"
|
|
343
|
+
return s + "f"
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
TEMPLATES = {
|
|
347
|
+
"transform": transform,
|
|
348
|
+
"transform_alpha": transform_alpha,
|
|
349
|
+
"transition": transition,
|
|
350
|
+
"matrix": matrix,
|
|
351
|
+
"kernel": kernel,
|
|
352
|
+
"lut_apply": lut_apply,
|
|
353
|
+
"aces_idt": aces_idt,
|
|
354
|
+
"aces_odt": aces_odt,
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
# Maps each template kind to the install category, which the dctl tool uses
|
|
358
|
+
# to pick the right install directory (regular LUT vs. ACES Transforms).
|
|
359
|
+
KIND_CATEGORY = {
|
|
360
|
+
"transform": "lut",
|
|
361
|
+
"transform_alpha": "lut",
|
|
362
|
+
"transition": "lut",
|
|
363
|
+
"matrix": "lut",
|
|
364
|
+
"kernel": "lut",
|
|
365
|
+
"lut_apply": "lut",
|
|
366
|
+
"aces_idt": "aces_idt",
|
|
367
|
+
"aces_odt": "aces_odt",
|
|
368
|
+
}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Live Extension Authoring boundary probe."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
import platform
|
|
8
|
+
import shutil
|
|
9
|
+
import sys
|
|
10
|
+
import tempfile
|
|
11
|
+
import time
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Any, Dict, Optional
|
|
14
|
+
|
|
15
|
+
from src.utils.timeline_kernel_probe import ProbeRecorder, render_markdown_report, utc_timestamp
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _require_success(label: str, result: Dict[str, Any]) -> Dict[str, Any]:
|
|
19
|
+
if not isinstance(result, dict):
|
|
20
|
+
raise AssertionError(f"{label}: expected dict, got {result!r}")
|
|
21
|
+
if result.get("error"):
|
|
22
|
+
raise AssertionError(f"{label}: {result['error']}")
|
|
23
|
+
if "success" in result and result["success"] is not True:
|
|
24
|
+
raise AssertionError(f"{label}: expected success=True, got {result!r}")
|
|
25
|
+
return result
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _record_tool_result(
|
|
29
|
+
recorder: ProbeRecorder,
|
|
30
|
+
category: str,
|
|
31
|
+
name: str,
|
|
32
|
+
result: Dict[str, Any],
|
|
33
|
+
*,
|
|
34
|
+
expected_status: Optional[str] = None,
|
|
35
|
+
) -> None:
|
|
36
|
+
if not isinstance(result, dict):
|
|
37
|
+
recorder.record(category, name, "error", details={"reason": "non-dict result", "result": repr(result)})
|
|
38
|
+
return
|
|
39
|
+
if result.get("error"):
|
|
40
|
+
recorder.record(category, name, expected_status or "error", details={"reason": result.get("error")}, evidence=result)
|
|
41
|
+
return
|
|
42
|
+
if "success" in result and result["success"] is not True:
|
|
43
|
+
recorder.record(
|
|
44
|
+
category,
|
|
45
|
+
name,
|
|
46
|
+
expected_status or "partially_supported",
|
|
47
|
+
details={"reason": "success returned false"},
|
|
48
|
+
evidence=result,
|
|
49
|
+
)
|
|
50
|
+
return
|
|
51
|
+
recorder.record(category, name, expected_status or "supported", evidence=result)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _record_nested_success(
|
|
55
|
+
recorder: ProbeRecorder,
|
|
56
|
+
category: str,
|
|
57
|
+
name: str,
|
|
58
|
+
result: Dict[str, Any],
|
|
59
|
+
keys: list[str],
|
|
60
|
+
*,
|
|
61
|
+
expected_status: Optional[str] = None,
|
|
62
|
+
) -> None:
|
|
63
|
+
evidence: Dict[str, Any] = {}
|
|
64
|
+
failures = []
|
|
65
|
+
for key in keys:
|
|
66
|
+
value = result.get(key)
|
|
67
|
+
evidence[key] = value
|
|
68
|
+
if isinstance(value, dict):
|
|
69
|
+
if value.get("error"):
|
|
70
|
+
failures.append(f"{key}: {value['error']}")
|
|
71
|
+
elif "success" in value and value["success"] is not True:
|
|
72
|
+
failures.append(f"{key}: success returned false")
|
|
73
|
+
elif value is None:
|
|
74
|
+
failures.append(f"{key}: missing")
|
|
75
|
+
if failures:
|
|
76
|
+
recorder.record(category, name, expected_status or "partially_supported", details={"reason": "; ".join(failures)}, evidence=evidence)
|
|
77
|
+
else:
|
|
78
|
+
recorder.record(category, name, expected_status or "supported", evidence=evidence)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def run_probe(server, output_dir: Path, keep_open: bool = False) -> Dict[str, Any]:
|
|
82
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
|
83
|
+
work_dir = Path(tempfile.mkdtemp(prefix="mcp_extension_authoring_probe_"))
|
|
84
|
+
timestamp = int(time.time())
|
|
85
|
+
project_name = f"_mcp_extension_authoring_probe_{timestamp}"
|
|
86
|
+
recorder = ProbeRecorder()
|
|
87
|
+
cleanup_project = False
|
|
88
|
+
delete_result: Optional[Dict[str, Any]] = None
|
|
89
|
+
|
|
90
|
+
names = {
|
|
91
|
+
"fuse": f"_mcp_fuse_lifecycle_{timestamp}",
|
|
92
|
+
"dctl_lut": f"_mcp_dctl_lut_{timestamp}",
|
|
93
|
+
"dctl_aces": f"_mcp_dctl_aces_{timestamp}",
|
|
94
|
+
"script_py": f"_mcp_script_py_{timestamp}",
|
|
95
|
+
"script_lua": f"_mcp_script_lua_{timestamp}",
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
metadata: Dict[str, Any] = {
|
|
99
|
+
"title": "Extension Authoring Kernel Capability Probe",
|
|
100
|
+
"timestamp_utc": utc_timestamp(),
|
|
101
|
+
"python": sys.version,
|
|
102
|
+
"platform": platform.platform(),
|
|
103
|
+
"output_dir": str(output_dir),
|
|
104
|
+
"work_dir": str(work_dir),
|
|
105
|
+
"project_name": project_name,
|
|
106
|
+
"extension_names": names,
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
try:
|
|
110
|
+
version = _require_success("resolve_control.get_version", server.resolve_control("get_version"))
|
|
111
|
+
metadata.update(
|
|
112
|
+
{
|
|
113
|
+
"product": version.get("product"),
|
|
114
|
+
"version": version.get("version"),
|
|
115
|
+
"version_string": version.get("version_string"),
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
print(f"Connected to {metadata['product']} {metadata['version_string']}")
|
|
119
|
+
|
|
120
|
+
create = server.project_manager("safe_project_create", {"name": project_name})
|
|
121
|
+
_require_success("project_manager.safe_project_create", create)
|
|
122
|
+
cleanup_project = True
|
|
123
|
+
print(f"Created disposable project: {project_name}")
|
|
124
|
+
|
|
125
|
+
_record_tool_result(recorder, "project", "safe_project_create", create)
|
|
126
|
+
_record_tool_result(recorder, "capabilities", "extension_capabilities", server.script_plugin("extension_capabilities"))
|
|
127
|
+
for extension_type, category in [
|
|
128
|
+
("fuse", None),
|
|
129
|
+
("dctl", "lut"),
|
|
130
|
+
("dctl", "aces_idt"),
|
|
131
|
+
("dctl", "aces_odt"),
|
|
132
|
+
("script", "Utility"),
|
|
133
|
+
]:
|
|
134
|
+
params = {"extension_type": extension_type}
|
|
135
|
+
if category:
|
|
136
|
+
params["category"] = category
|
|
137
|
+
_record_tool_result(
|
|
138
|
+
recorder,
|
|
139
|
+
"lifecycle",
|
|
140
|
+
f"refresh_or_restart_required_{extension_type}_{category or 'default'}",
|
|
141
|
+
server.script_plugin("refresh_or_restart_required", params),
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
fuse_probe = server.script_plugin("probe_fuse_lifecycle", {
|
|
145
|
+
"name": names["fuse"],
|
|
146
|
+
"kind": "color_matrix",
|
|
147
|
+
"install": True,
|
|
148
|
+
"cleanup": True,
|
|
149
|
+
"overwrite": True,
|
|
150
|
+
})
|
|
151
|
+
_record_nested_success(recorder, "fuse", "probe_fuse_lifecycle_install_read_list_remove", fuse_probe, ["install", "read", "list", "remove"])
|
|
152
|
+
|
|
153
|
+
dctl_lut_probe = server.script_plugin("probe_dctl_lifecycle", {
|
|
154
|
+
"name": names["dctl_lut"],
|
|
155
|
+
"kind": "transform",
|
|
156
|
+
"category": "lut",
|
|
157
|
+
"subdir": "MCP",
|
|
158
|
+
"install": True,
|
|
159
|
+
"refresh_luts": True,
|
|
160
|
+
"cleanup": True,
|
|
161
|
+
"overwrite": True,
|
|
162
|
+
})
|
|
163
|
+
_record_nested_success(
|
|
164
|
+
recorder,
|
|
165
|
+
"dctl",
|
|
166
|
+
"probe_dctl_lut_lifecycle_install_refresh_remove",
|
|
167
|
+
dctl_lut_probe,
|
|
168
|
+
["install", "read", "list", "refresh_luts", "remove"],
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
dctl_aces_probe = server.script_plugin("probe_dctl_lifecycle", {
|
|
172
|
+
"name": names["dctl_aces"],
|
|
173
|
+
"kind": "aces_idt",
|
|
174
|
+
"category": "aces_idt",
|
|
175
|
+
"subdir": "MCP",
|
|
176
|
+
"install": True,
|
|
177
|
+
"cleanup": True,
|
|
178
|
+
"overwrite": True,
|
|
179
|
+
})
|
|
180
|
+
_record_nested_success(
|
|
181
|
+
recorder,
|
|
182
|
+
"dctl",
|
|
183
|
+
"probe_dctl_aces_lifecycle_install_remove",
|
|
184
|
+
dctl_aces_probe,
|
|
185
|
+
["install", "read", "list", "remove"],
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
script_py_probe = server.script_plugin("probe_script_lifecycle", {
|
|
189
|
+
"name": names["script_py"],
|
|
190
|
+
"kind": "scaffold",
|
|
191
|
+
"language": "py",
|
|
192
|
+
"category": "Utility",
|
|
193
|
+
"install": True,
|
|
194
|
+
"execute": True,
|
|
195
|
+
"cleanup": True,
|
|
196
|
+
"overwrite": True,
|
|
197
|
+
"timeout": 120,
|
|
198
|
+
})
|
|
199
|
+
_record_nested_success(
|
|
200
|
+
recorder,
|
|
201
|
+
"script",
|
|
202
|
+
"probe_script_python_lifecycle_install_execute_remove",
|
|
203
|
+
script_py_probe,
|
|
204
|
+
["install", "read", "list", "execute", "remove"],
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
script_lua_probe = server.script_plugin("probe_script_lifecycle", {
|
|
208
|
+
"name": names["script_lua"],
|
|
209
|
+
"kind": "scaffold",
|
|
210
|
+
"language": "lua",
|
|
211
|
+
"category": "Utility",
|
|
212
|
+
"install": True,
|
|
213
|
+
"execute": True,
|
|
214
|
+
"cleanup": True,
|
|
215
|
+
"overwrite": True,
|
|
216
|
+
"timeout": 120,
|
|
217
|
+
})
|
|
218
|
+
_record_nested_success(
|
|
219
|
+
recorder,
|
|
220
|
+
"script",
|
|
221
|
+
"probe_script_lua_lifecycle_install_execute_remove",
|
|
222
|
+
script_lua_probe,
|
|
223
|
+
["install", "read", "list", "execute", "remove"],
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
_record_tool_result(
|
|
227
|
+
recorder,
|
|
228
|
+
"script",
|
|
229
|
+
"run_inline_python_stdout",
|
|
230
|
+
server.script_plugin("run_inline", {"language": "py", "source": "print('extension inline py ok')", "timeout": 60}),
|
|
231
|
+
)
|
|
232
|
+
_record_tool_result(
|
|
233
|
+
recorder,
|
|
234
|
+
"script",
|
|
235
|
+
"run_inline_lua_stdout_result",
|
|
236
|
+
server.script_plugin("run_inline", {"language": "lua", "source": "print('extension inline lua ok')\nreturn 'lua-result'", "timeout": 60}),
|
|
237
|
+
)
|
|
238
|
+
_record_tool_result(
|
|
239
|
+
recorder,
|
|
240
|
+
"guards",
|
|
241
|
+
"safe_install_rejects_unmarked_source",
|
|
242
|
+
server.script_plugin("safe_install_extension", {
|
|
243
|
+
"extension_type": "script",
|
|
244
|
+
"name": f"_mcp_unmarked_{timestamp}",
|
|
245
|
+
"source": "print('missing marker')",
|
|
246
|
+
"language": "py",
|
|
247
|
+
"category": "Utility",
|
|
248
|
+
"dry_run": True,
|
|
249
|
+
}),
|
|
250
|
+
expected_status="unsupported",
|
|
251
|
+
)
|
|
252
|
+
_record_tool_result(
|
|
253
|
+
recorder,
|
|
254
|
+
"report",
|
|
255
|
+
"extension_boundary_report",
|
|
256
|
+
server.script_plugin("extension_boundary_report", {"include_template_matrix": True}),
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
if keep_open:
|
|
260
|
+
server.project_manager("save")
|
|
261
|
+
cleanup_project = False
|
|
262
|
+
print(f"LEFT PROJECT OPEN FOR INSPECTION: {project_name}")
|
|
263
|
+
|
|
264
|
+
finally:
|
|
265
|
+
if cleanup_project:
|
|
266
|
+
server.project_manager("save")
|
|
267
|
+
server.project_manager("close")
|
|
268
|
+
delete_result = server.project_manager("safe_project_delete", {"name": project_name})
|
|
269
|
+
print(f"Deleted disposable project: {delete_result}")
|
|
270
|
+
|
|
271
|
+
metadata["cleanup"] = {"project": delete_result}
|
|
272
|
+
report = recorder.to_report(
|
|
273
|
+
metadata,
|
|
274
|
+
{
|
|
275
|
+
"json": str(output_dir / "extension-authoring-probe.json"),
|
|
276
|
+
"markdown": str(output_dir / "extension-authoring-probe.md"),
|
|
277
|
+
},
|
|
278
|
+
)
|
|
279
|
+
json_path = output_dir / "extension-authoring-probe.json"
|
|
280
|
+
markdown_path = output_dir / "extension-authoring-probe.md"
|
|
281
|
+
json_path.write_text(json.dumps(report, indent=2, sort_keys=True), encoding="utf-8")
|
|
282
|
+
markdown_path.write_text(render_markdown_report(report), encoding="utf-8")
|
|
283
|
+
print(f"Wrote JSON report: {json_path}")
|
|
284
|
+
print(f"Wrote Markdown report: {markdown_path}")
|
|
285
|
+
print(f"Counts: {json.dumps(report['counts'], sort_keys=True)}")
|
|
286
|
+
if not keep_open:
|
|
287
|
+
shutil.rmtree(work_dir, ignore_errors=True)
|
|
288
|
+
print(f"Removed extension authoring work directory: {work_dir}")
|
|
289
|
+
|
|
290
|
+
if delete_result and delete_result.get("success") is not True:
|
|
291
|
+
raise AssertionError(f"Cleanup failed for {project_name}: {delete_result!r}")
|
|
292
|
+
return report
|