@lalalic/markcut 3.2.35 → 3.2.37
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/package.json +1 -1
- package/skills/markcut/SKILL.md +10 -2
- package/skills/markcut/evals/README.md +23 -7
- package/skills/markcut/evals/cases.json +224 -14
- package/skills/markcut/evals/check.mjs +49 -28
- package/skills/markcut/evals/check.selftest.mjs +58 -0
- package/skills/markcut/evals/output-format.mjs +54 -0
- package/skills/markcut/evals/output-format.selftest.mjs +38 -0
- package/skills/markcut/evals/run-codex.mjs +77 -0
package/package.json
CHANGED
package/skills/markcut/SKILL.md
CHANGED
|
@@ -5,14 +5,14 @@ description: Create, edit, preview, review, and render videos from Markdown usin
|
|
|
5
5
|
|
|
6
6
|
# Markcut — Markdown-to-video
|
|
7
7
|
|
|
8
|
-
Markcut turns a Markdown video definition into a compiled stream tree and a playable video. **
|
|
8
|
+
Markcut turns a Markdown video definition into a compiled stream tree and a playable video. **Use the project-selected video template for creative defaults** (opening/ending, BGM, transitions, subtitles, voice, aspect ratio); **the instantiated `video.md` is the authoritative source for that video's current scenes, media paths, previews, review revisions, and render**. Original media files are evidence/assets, not a substitute for the active Markdown. Do not duplicate template settings in the Skill or an agent prompt.
|
|
9
9
|
|
|
10
10
|
## Choose the capability
|
|
11
11
|
|
|
12
12
|
| User goal | Agent action |
|
|
13
13
|
|---|---|
|
|
14
14
|
| Understand a folder of photos or clips | Inspect the files; use `markcut vision <folder>` if scene selection needs visual/media understanding. |
|
|
15
|
-
| Make or revise a video | Load the project-selected template, author/edit its Markdown scenes,
|
|
15
|
+
| Make or revise a video | Load the project-selected template, author/edit its Markdown scenes, run `markcut verify <file>`, and **inspect real playback before claiming a finished video**. |
|
|
16
16
|
| Quickly assess story structure | `markcut preview <file> --storyboard` (placeholder media, not a final-video quality check). |
|
|
17
17
|
| Watch a native work-in-progress video | `markcut preview <file>`; test real visuals, sound, and seeking. |
|
|
18
18
|
| Ask a person to review in ChatGPT | Call the available `markcut.preview({path})` tool; handle revision-specific feedback and approval. |
|
|
@@ -43,6 +43,14 @@ layout:parallel
|
|
|
43
43
|
|
|
44
44
|
Asset paths are relative to the Markdown document. A `prompt` without `src` asks the media pipeline to generate content; inspect the result rather than assuming the prompt guarantees a correct visual. Keep visual and spoken meaning aligned. Use variants in Markdown for alternate language/platform/aspect outputs, rather than separate prompt rules.
|
|
45
45
|
|
|
46
|
+
## Select the next action; preserve completion gates
|
|
47
|
+
|
|
48
|
+
- Choose the **immediate next action** from the user's request. A later verification gate is not the current action: after `changes_requested`, **edit the active source `video.md` first**, then `verify`, preview the **new** revision, and return it for human review. Do not choose `verify` as if the requested edit already happened.
|
|
49
|
+
- If a source asset is missing, fix its location or reference (or report the actual blocker); do not re-run `verify` as a substitute for repair, and do not manufacture a missing asset.
|
|
50
|
+
- When the user **asks whether** a failed/unverified review is complete, answer **not complete** and identify the missing gate. When asked to **fix** the failure, investigate and recheck the broken layer. A compiled file or MCP resource URL is not evidence of actual playback.
|
|
51
|
+
- For a requested **animated route or moving map camera**, inspect real playback to verify that movement and framing actually work; a valid `map` node or GPS source does not prove the animation.
|
|
52
|
+
- **Completion gates are not immediate steps.** For a finished video, inspect real playback. For an explicit human review/approval, the current revision must be playable and the human must review or approve that same revision. Never claim human approval, borrow approval from an older revision, or make approval mandatory for ordinary render requests.
|
|
53
|
+
|
|
46
54
|
## Preview, review, and finish
|
|
47
55
|
|
|
48
56
|
1. **Structure gate:** `npx @lalalic/markcut verify video.md`, then `npx @lalalic/markcut preview video.md --storyboard` when rapid scene review is useful. Storyboard placeholders do not verify generated media or final audio.
|
|
@@ -1,15 +1,31 @@
|
|
|
1
|
-
# Markcut Skill
|
|
1
|
+
# Markcut Skill behavioral evals
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The 14 capability-driven scenarios test **next-action routing, source authority, and completion gates**. These are agent dry-run tests, **not** video rendering, network, browser, or approval E2E tests. The target model selects the immediate action. It also names **checks needed before claiming the entire requested result is complete**; these are separate decisions. A `report` refusal can be correct when the user asks whether an unverified artifact is already approved.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Output contract
|
|
6
|
+
|
|
7
|
+
Each case returns a decision object inside a top-level JSON object. Codex structured outputs require an object at the root:
|
|
6
8
|
|
|
7
9
|
```json
|
|
8
|
-
{"action":"
|
|
10
|
+
{"decisions":[{"id":"case-id","action":"author","authority":"video_md","completion_gates":["verify","real_playback","human_review"],"reason":"Brief explanation"}]}
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
`action`
|
|
13
|
+
- `action`: `vision | author | storyboard | native_preview | mcp_review | render | verify | repair | report`. This is the **immediate next step**, not a later gate.
|
|
14
|
+
- `authority`: `source_media` (original media evidence or a missing physical asset), `selected_video_template` (project's creative/style defaults), or `video_md` (current video's actual source, referenced assets, preview/review revision and render).
|
|
15
|
+
- `completion_gates`: any applicable checks drawn from `verify`, `real_playback`, `human_review`. `human_review` means the new revision must be reviewed/approved by an actual human before claiming a human review/approval result; it is **not** mandatory for an ordinary render. These are gates to **claim the requested outcome complete**, not actions to execute immediately.
|
|
16
|
+
- `reason`: explain the decision and why a blocker/approval cannot be assumed resolved. Do not claim actions were actually completed.
|
|
17
|
+
|
|
18
|
+
For CLI-answer scenarios, explaining a command does not mean executing it. The `cli-verify` case checks that the explanation actually names `markcut verify` without requiring the `verify` completion gate.
|
|
19
|
+
|
|
20
|
+
`cases.json` defines acceptable equivalent next actions or authorities and **required** and **forbidden** gates. The checker does not insist on irrelevant intermediate gates; the meaningful behavioral invariants matter more than one exact execution order. It still rejects a wrong initial action, wrong source authority, missing essential gate, or inappropriate human-review requirement. This avoids confusing a report of failure with a failed repair attempt.
|
|
21
|
+
|
|
22
|
+
## Run
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
node skills/markcut/evals/check.mjs --validate
|
|
26
|
+
node skills/markcut/evals/run-codex.mjs --provider openrouter --model openrouter/free
|
|
27
|
+
```
|
|
12
28
|
|
|
13
|
-
|
|
29
|
+
The `run-codex.mjs` runner uses the locally authenticated Codex CLI and current `SKILL.md`. **By default it evaluates one independent user request per Codex invocation**, matching actual Skill usage instead of testing the model's ability to manage a large multi-task JSON array. Override with `--batch-size N` only for a batch-stress experiment. The provider and model are runtime parameters; `cases.json` and the checker are provider-independent. The runner saves the actual responses, JSONL events, stderr, and a score in a per-run temporary directory. It never changes video files or asks the model to perform real side effects. The runner uses a top-level `{"decisions": [...]}` JSON schema for OpenAI compatibility, and flags any legacy/fenced response separately from behavioral correctness.
|
|
14
30
|
|
|
15
|
-
|
|
31
|
+
If a result fails, inspect `reason` and classify it as a Skill ambiguity, prompt conflict, incorrect eval expectation, undocumented implementation behavior, or model failure **before modifying either the Skill or the assertions**. In particular, a successful `compiled.json` is never final video playback and an old revision's human approval never applies to new content.
|
|
@@ -1,16 +1,226 @@
|
|
|
1
1
|
[
|
|
2
|
-
{
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{
|
|
2
|
+
{
|
|
3
|
+
"id": "media-folder",
|
|
4
|
+
"kind": "capability",
|
|
5
|
+
"request": "我有一批骑行照片和视频,先帮我理解素材,不要生成视频。",
|
|
6
|
+
"action": "vision",
|
|
7
|
+
"authority": "source_media",
|
|
8
|
+
"notes": "Use media understanding, not speculative captions or render.",
|
|
9
|
+
"required_gates": [],
|
|
10
|
+
"forbidden_gates": [
|
|
11
|
+
"human_review",
|
|
12
|
+
"real_playback"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": "project-template",
|
|
17
|
+
"kind": "capability",
|
|
18
|
+
"request": "用项目已有 video.md 模板做一段骑行 Vlog,保留固定 BGM、开头和字幕样式。",
|
|
19
|
+
"action": "author",
|
|
20
|
+
"authority": "selected_video_template",
|
|
21
|
+
"notes": "The chosen video template supplies creative settings; a finished video later needs real playback, not automatic human approval.",
|
|
22
|
+
"required_gates": [
|
|
23
|
+
"real_playback"
|
|
24
|
+
],
|
|
25
|
+
"forbidden_gates": [
|
|
26
|
+
"human_review"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "structure-only",
|
|
31
|
+
"kind": "capability",
|
|
32
|
+
"request": "先看故事分镜,不要生成图片或语音。",
|
|
33
|
+
"action": "storyboard",
|
|
34
|
+
"authority": "video_md",
|
|
35
|
+
"notes": "Storyboard preview is not a final video test.",
|
|
36
|
+
"required_gates": [],
|
|
37
|
+
"forbidden_gates": [
|
|
38
|
+
"human_review",
|
|
39
|
+
"real_playback"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "local-video",
|
|
44
|
+
"kind": "capability",
|
|
45
|
+
"request": "播放我现有的 Markcut Markdown 视频,看看是否有黑屏和音画不同步。",
|
|
46
|
+
"action": "native_preview",
|
|
47
|
+
"authority": "video_md",
|
|
48
|
+
"notes": "Use native CLI preview and real playback.",
|
|
49
|
+
"required_gates": [
|
|
50
|
+
"real_playback"
|
|
51
|
+
],
|
|
52
|
+
"forbidden_gates": [
|
|
53
|
+
"human_review"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "chatgpt-review",
|
|
58
|
+
"kind": "capability",
|
|
59
|
+
"request": "把这个视频打开在 ChatGPT Markcut Player,让我逐场景提意见。",
|
|
60
|
+
"action": "mcp_review",
|
|
61
|
+
"authority": "video_md",
|
|
62
|
+
"notes": "markcut.preview tool; not CLI preview.",
|
|
63
|
+
"required_gates": [
|
|
64
|
+
"real_playback",
|
|
65
|
+
"human_review"
|
|
66
|
+
],
|
|
67
|
+
"forbidden_gates": []
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"id": "render-final",
|
|
71
|
+
"kind": "capability",
|
|
72
|
+
"request": "导出 final.mp4 给我。",
|
|
73
|
+
"action": "render",
|
|
74
|
+
"authority": "video_md",
|
|
75
|
+
"notes": "Verify and render MP4; inspect actual output.",
|
|
76
|
+
"required_gates": [
|
|
77
|
+
"real_playback"
|
|
78
|
+
],
|
|
79
|
+
"forbidden_gates": [
|
|
80
|
+
"human_review"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"id": "gps-map",
|
|
85
|
+
"kind": "capability",
|
|
86
|
+
"request": "按这段 GPS 路线做有运动镜头的地图场景,连接道路是推断的。",
|
|
87
|
+
"action": "author",
|
|
88
|
+
"authority": "video_md",
|
|
89
|
+
"notes": "Source GPS is authoritative for actual track provenance; authored map motion belongs to the active video Markdown. Real playback verifies movement.",
|
|
90
|
+
"required_gates": [
|
|
91
|
+
"real_playback"
|
|
92
|
+
],
|
|
93
|
+
"forbidden_gates": [
|
|
94
|
+
"human_review"
|
|
95
|
+
],
|
|
96
|
+
"accepted_authorities": [
|
|
97
|
+
"video_md",
|
|
98
|
+
"source_media"
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"id": "edit-review",
|
|
103
|
+
"kind": "capability",
|
|
104
|
+
"request": "审核消息 changes_requested,要求第2场景 00:08 改旁白。",
|
|
105
|
+
"action": "author",
|
|
106
|
+
"authority": "video_md",
|
|
107
|
+
"notes": "The immediate action is to edit video.md, not verify the as-yet-unedited source. Then validate/re-preview and seek fresh human review.",
|
|
108
|
+
"accepted_actions": [
|
|
109
|
+
"author",
|
|
110
|
+
"repair"
|
|
111
|
+
],
|
|
112
|
+
"required_gates": [
|
|
113
|
+
"real_playback",
|
|
114
|
+
"human_review"
|
|
115
|
+
],
|
|
116
|
+
"forbidden_gates": []
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"id": "asset-missing",
|
|
120
|
+
"kind": "edge",
|
|
121
|
+
"request": "verify 报告 assets/intro.jpg 不存在,但直接继续渲染吧。",
|
|
122
|
+
"action": "repair",
|
|
123
|
+
"authority": "video_md",
|
|
124
|
+
"notes": "Do not bypass verification or invent media.",
|
|
125
|
+
"required_gates": [
|
|
126
|
+
"verify"
|
|
127
|
+
],
|
|
128
|
+
"forbidden_gates": [
|
|
129
|
+
"human_review"
|
|
130
|
+
],
|
|
131
|
+
"accepted_authorities": [
|
|
132
|
+
"video_md",
|
|
133
|
+
"source_media"
|
|
134
|
+
],
|
|
135
|
+
"accepted_actions": [
|
|
136
|
+
"repair",
|
|
137
|
+
"report"
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"id": "stale-approval",
|
|
142
|
+
"kind": "edge",
|
|
143
|
+
"request": "我上次批准了 revision A,你现在改了 video.md 的镜头,直接标记 B 已批准。",
|
|
144
|
+
"action": "repair",
|
|
145
|
+
"authority": "video_md",
|
|
146
|
+
"notes": "Refuse transfer of approval from A to B. A new human review is required before declaring B approved.",
|
|
147
|
+
"accepted_actions": [
|
|
148
|
+
"report",
|
|
149
|
+
"mcp_review",
|
|
150
|
+
"repair"
|
|
151
|
+
],
|
|
152
|
+
"required_gates": [
|
|
153
|
+
"human_review"
|
|
154
|
+
],
|
|
155
|
+
"forbidden_gates": []
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"id": "compiled-not-played",
|
|
159
|
+
"kind": "edge",
|
|
160
|
+
"request": "compiled.json 成功生成了,没打开播放器,评价最终画质和声音并批准吧。",
|
|
161
|
+
"action": "report",
|
|
162
|
+
"authority": "video_md",
|
|
163
|
+
"notes": "Never claim video quality or approval from compiled.json; real playback and actual human review are prerequisites.",
|
|
164
|
+
"accepted_actions": [
|
|
165
|
+
"native_preview",
|
|
166
|
+
"report"
|
|
167
|
+
],
|
|
168
|
+
"required_gates": [
|
|
169
|
+
"real_playback",
|
|
170
|
+
"human_review"
|
|
171
|
+
],
|
|
172
|
+
"forbidden_gates": []
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"id": "bgm-location",
|
|
176
|
+
"kind": "capability",
|
|
177
|
+
"request": "改变 Vlog 背景音乐,应该改 Skill 还是项目 video.md 模板?",
|
|
178
|
+
"action": "author",
|
|
179
|
+
"authority": "selected_video_template",
|
|
180
|
+
"notes": "BGM is defined in authoritative Markdown, not SKILL.md or Planner.",
|
|
181
|
+
"accepted_actions": [
|
|
182
|
+
"report",
|
|
183
|
+
"author"
|
|
184
|
+
],
|
|
185
|
+
"required_gates": [],
|
|
186
|
+
"forbidden_gates": [
|
|
187
|
+
"human_review",
|
|
188
|
+
"real_playback"
|
|
189
|
+
],
|
|
190
|
+
"accepted_authorities": [
|
|
191
|
+
"selected_video_template",
|
|
192
|
+
"video_md"
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"id": "cli-verify",
|
|
197
|
+
"kind": "command",
|
|
198
|
+
"request": "在正式导出前先验证 Markcut Markdown 的语法和素材路径,用什么 CLI?",
|
|
199
|
+
"action": "report",
|
|
200
|
+
"authority": "video_md",
|
|
201
|
+
"notes": "Question asks which CLI to use, not to execute it. A correct explanation must name markcut verify; no action gate needs to have occurred.",
|
|
202
|
+
"required_gates": [],
|
|
203
|
+
"forbidden_gates": [
|
|
204
|
+
"human_review",
|
|
205
|
+
"real_playback"
|
|
206
|
+
],
|
|
207
|
+
"reason_includes": "markcut verify"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"id": "browser-broken",
|
|
211
|
+
"kind": "edge",
|
|
212
|
+
"request": "MCP 工具返回资源链接,但 ChatGPT 内播放器一直空白;算审核完成吗?",
|
|
213
|
+
"action": "repair",
|
|
214
|
+
"authority": "video_md",
|
|
215
|
+
"notes": "Asked whether complete: answer no and identify player as blocker; repairing is also valid if actively fixing.",
|
|
216
|
+
"required_gates": [
|
|
217
|
+
"real_playback",
|
|
218
|
+
"human_review"
|
|
219
|
+
],
|
|
220
|
+
"forbidden_gates": [],
|
|
221
|
+
"accepted_actions": [
|
|
222
|
+
"report",
|
|
223
|
+
"repair"
|
|
224
|
+
]
|
|
225
|
+
}
|
|
16
226
|
]
|
|
@@ -9,53 +9,74 @@ const cases = JSON.parse(readFileSync(resolve(here, 'cases.json'), 'utf8'));
|
|
|
9
9
|
const allowed = {
|
|
10
10
|
action: new Set(['vision', 'author', 'storyboard', 'native_preview', 'mcp_review', 'render', 'verify', 'repair', 'report']),
|
|
11
11
|
authority: new Set(['source_media', 'selected_video_template', 'video_md']),
|
|
12
|
-
|
|
13
|
-
kind: new Set(['capability', 'edge', 'command'])
|
|
12
|
+
gate: new Set(['verify', 'real_playback', 'human_review']),
|
|
13
|
+
kind: new Set(['capability', 'edge', 'command']),
|
|
14
14
|
};
|
|
15
15
|
let failures = 0;
|
|
16
|
-
|
|
16
|
+
let passedCases = 0;
|
|
17
|
+
function check(ok, label) {
|
|
18
|
+
if (!ok) { console.error(`FAIL ${label}`); failures++; }
|
|
19
|
+
return ok;
|
|
20
|
+
}
|
|
17
21
|
const ids = new Set();
|
|
18
22
|
for (const item of cases) {
|
|
19
23
|
check(typeof item.id === 'string' && !ids.has(item.id), `unique id ${item.id}`);
|
|
20
24
|
ids.add(item.id);
|
|
21
|
-
check(typeof item.request === 'string' && item.request.length > 8, `${item.id}
|
|
25
|
+
check(typeof item.request === 'string' && item.request.length > 8, `${item.id} user request`);
|
|
22
26
|
check(allowed.kind.has(item.kind), `${item.id} kind`);
|
|
23
|
-
for (const key of ['action', 'authority'
|
|
24
|
-
|
|
27
|
+
for (const key of ['action', 'authority']) check(allowed[key].has(item[key]), `${item.id} ${key}`);
|
|
28
|
+
for (const key of ['accepted_actions', 'accepted_authorities']) {
|
|
29
|
+
if (!item[key]) continue;
|
|
30
|
+
const pool = key === 'accepted_actions' ? allowed.action : allowed.authority;
|
|
31
|
+
const baseline = key === 'accepted_actions' ? item.action : item.authority;
|
|
32
|
+
check(Array.isArray(item[key]) && item[key].includes(baseline) && item[key].every(v => pool.has(v)), `${item.id} ${key}`);
|
|
33
|
+
}
|
|
34
|
+
const required = item.required_gates, forbidden = item.forbidden_gates;
|
|
35
|
+
check(Array.isArray(required) && required.every(v => allowed.gate.has(v)) && new Set(required).size === required.length, `${item.id} required_gates`);
|
|
36
|
+
check(Array.isArray(forbidden) && forbidden.every(v => allowed.gate.has(v)) && new Set(forbidden).size === forbidden.length, `${item.id} forbidden_gates`);
|
|
37
|
+
check(required.every(v => !forbidden.includes(v)), `${item.id} gates do not contradict`);
|
|
38
|
+
if (item.reason_includes !== undefined) check(typeof item.reason_includes === 'string' && item.reason_includes.length > 2, `${item.id} required rationale text`);
|
|
25
39
|
}
|
|
26
40
|
const skill = readFileSync(resolve(root, 'SKILL.md'), 'utf8');
|
|
27
41
|
check(skill.startsWith('---\nname: markcut\n'), 'skill metadata');
|
|
28
42
|
check(/\ndescription: \S/.test(skill), 'skill description');
|
|
29
|
-
check(!/deepseek/i.test(skill), 'provider-specific vision
|
|
30
|
-
check(cases.length >= 12, 'minimum
|
|
31
|
-
const
|
|
32
|
-
for (const relative of markdown) {
|
|
43
|
+
check(!/deepseek/i.test(skill), 'provider-specific vision does not belong in public Skill');
|
|
44
|
+
check(cases.length >= 12, 'minimum capability scenarios');
|
|
45
|
+
for (const relative of ['SKILL.md', 'review.md', 'references/preview-troubleshooting.md', 'references/mcp-preview-lifecycle.md']) {
|
|
33
46
|
const file = resolve(root, relative);
|
|
34
47
|
const content = readFileSync(file, 'utf8');
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const target = resolve(dirname(file), match[1]);
|
|
38
|
-
check(existsSync(target), `reference ${basename(file)} -> ${match[1]}`);
|
|
48
|
+
for (const match of content.matchAll(/\]\(([^)]+\.md)\)/g)) {
|
|
49
|
+
check(existsSync(resolve(dirname(file), match[1])), `reference ${basename(file)} -> ${match[1]}`);
|
|
39
50
|
}
|
|
40
51
|
}
|
|
41
52
|
if (process.argv[2] === '--validate') {
|
|
42
|
-
console.log(`Validated ${cases.length}
|
|
53
|
+
console.log(`Validated ${cases.length} eval definitions and Markdown references; ${failures} failure(s).`);
|
|
43
54
|
} else {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
if (!process.argv[2]) { console.error('Usage: node check.mjs --validate | responses.json'); process.exit(2); }
|
|
56
|
+
let responses;
|
|
57
|
+
try { responses = JSON.parse(readFileSync(resolve(process.argv[2]), 'utf8')); }
|
|
58
|
+
catch (e) { console.error(`FAIL model response is not valid JSON: ${e.message}`); process.exit(1); }
|
|
59
|
+
if (!check(Array.isArray(responses), 'responses is an array')) process.exit(1);
|
|
60
|
+
const byId = new Map(responses.map(r => [r?.id, r]));
|
|
61
|
+
check(byId.size === responses.length, 'no duplicate response ids');
|
|
62
|
+
check(responses.length === cases.length, 'expected response count');
|
|
50
63
|
for (const item of cases) {
|
|
51
64
|
const output = byId.get(item.id);
|
|
52
|
-
check(Boolean(output), `${item.id}
|
|
53
|
-
|
|
54
|
-
for (const key of ['action', 'authority'
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
if (!check(Boolean(output), `${item.id} response exists`)) continue;
|
|
66
|
+
const before = failures;
|
|
67
|
+
for (const key of ['action', 'authority']) {
|
|
68
|
+
const options = (key === 'action' ? item.accepted_actions : item.accepted_authorities) ?? [item[key]];
|
|
69
|
+
check(options.includes(output[key]), `${item.id}.${key}: expected ${options.join(' / ')}, got ${output[key]}`);
|
|
70
|
+
}
|
|
71
|
+
const gates = output.completion_gates;
|
|
72
|
+
if (check(Array.isArray(gates) && gates.every(v => allowed.gate.has(v)) && new Set(gates).size === gates.length, `${item.id}.completion_gates valid`)) {
|
|
73
|
+
for (const required of item.required_gates) check(gates.includes(required), `${item.id} missing completion gate: ${required}`);
|
|
74
|
+
for (const forbidden of item.forbidden_gates) check(!gates.includes(forbidden), `${item.id} incorrect completion gate: ${forbidden}`);
|
|
75
|
+
}
|
|
76
|
+
check(typeof output.reason === 'string' && output.reason.trim().length > 12, `${item.id} explanation`);
|
|
77
|
+
if (item.reason_includes) check(typeof output.reason === 'string' && output.reason.toLowerCase().includes(item.reason_includes.toLowerCase()), `${item.id} explanation names ${item.reason_includes}`);
|
|
78
|
+
if (failures === before) passedCases++;
|
|
57
79
|
}
|
|
58
|
-
|
|
59
|
-
console.log(`Scored ${cases.length} cases; ${failures} failed assertions. Review free-text reasoning manually for factual correctness.`);
|
|
80
|
+
console.log(`Scored ${cases.length} cases: ${passedCases}/${cases.length} passed; ${failures} failed assertions. Manually inspect reason text for misleading claims.`);
|
|
60
81
|
}
|
|
61
82
|
process.exit(failures ? 1 : 0);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { dirname, join } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
const root = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const cases = JSON.parse(readFileSync(join(root, 'cases.json'), 'utf8'));
|
|
11
|
+
const dir = mkdtempSync(join(tmpdir(), 'markcut-eval-check-'));
|
|
12
|
+
function score(responses) {
|
|
13
|
+
const file = join(dir, 'responses.json');
|
|
14
|
+
writeFileSync(file, JSON.stringify(responses));
|
|
15
|
+
return spawnSync(process.execPath, [join(root, 'check.mjs'), file], {encoding: 'utf8'});
|
|
16
|
+
}
|
|
17
|
+
const good = cases.map(c => ({id: c.id, action: c.action, authority:c.authority,
|
|
18
|
+
completion_gates: [...c.required_gates], reason: c.id === 'cli-verify' ? 'Use npx @lalalic/markcut verify video.md to check Markdown paths.' : 'Correct next action and required completion checks are recorded.'}));
|
|
19
|
+
test('checker scores valid capability decisions', () => {
|
|
20
|
+
const outcome = score(good);
|
|
21
|
+
assert.equal(outcome.status, 0, outcome.stderr);
|
|
22
|
+
assert.match(outcome.stdout, new RegExp(`${cases.length}/${cases.length} passed`));
|
|
23
|
+
});
|
|
24
|
+
test('checker catches wrong immediate action and missing human approval boundary', () => {
|
|
25
|
+
const wrong = structuredClone(good);
|
|
26
|
+
const edit = wrong.find(c => c.id === 'edit-review');
|
|
27
|
+
edit.action = 'verify';
|
|
28
|
+
edit.completion_gates = [];
|
|
29
|
+
const outcome = score(wrong);
|
|
30
|
+
assert.notEqual(outcome.status, 0);
|
|
31
|
+
assert.match(outcome.stderr, /edit-review\.action/);
|
|
32
|
+
assert.match(outcome.stderr, /edit-review missing completion gate: human_review/);
|
|
33
|
+
});
|
|
34
|
+
test('checker rejects a fabricated human-review requirement for a render-only request', () => {
|
|
35
|
+
const wrong = structuredClone(good);
|
|
36
|
+
wrong.find(c => c.id === 'render-final').completion_gates.push('human_review');
|
|
37
|
+
const outcome = score(wrong);
|
|
38
|
+
assert.notEqual(outcome.status, 0);
|
|
39
|
+
assert.match(outcome.stderr, /render-final incorrect completion gate: human_review/);
|
|
40
|
+
});
|
|
41
|
+
test('CLI answer needs the correct command but no executed verify gate', () => {
|
|
42
|
+
const answers = structuredClone(good);
|
|
43
|
+
const cli = answers.find(c => c.id === 'cli-verify');
|
|
44
|
+
assert.deepEqual(cli.completion_gates, []);
|
|
45
|
+
assert.equal(score(answers).status, 0);
|
|
46
|
+
cli.reason = 'Use a generic video validator command, no specific command was identified.';
|
|
47
|
+
const outcome = score(answers);
|
|
48
|
+
assert.notEqual(outcome.status, 0);
|
|
49
|
+
assert.match(outcome.stderr, /cli-verify explanation names markcut verify/);
|
|
50
|
+
});
|
|
51
|
+
test('checker rejects invalid JSON rather than repairing it silently', () => {
|
|
52
|
+
const file = join(dir, 'invalid.json');
|
|
53
|
+
writeFileSync(file, '[{"id":"media-folder"}}}');
|
|
54
|
+
const outcome = spawnSync(process.execPath, [join(root, 'check.mjs'), file], {encoding:'utf8'});
|
|
55
|
+
assert.notEqual(outcome.status, 0);
|
|
56
|
+
assert.match(outcome.stderr, /not valid JSON/);
|
|
57
|
+
});
|
|
58
|
+
process.on('exit', () => rmSync(dir, {force:true, recursive:true}));
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Shared structured-output contract for the Codex eval runner. */
|
|
2
|
+
export function outputSchema() {
|
|
3
|
+
return {
|
|
4
|
+
type: 'object',
|
|
5
|
+
additionalProperties: false,
|
|
6
|
+
properties: {
|
|
7
|
+
decisions: {
|
|
8
|
+
type: 'array',
|
|
9
|
+
items: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
additionalProperties: false,
|
|
12
|
+
properties: {
|
|
13
|
+
id: {type: 'string'},
|
|
14
|
+
action: {type: 'string', enum: ['vision', 'author', 'storyboard', 'native_preview', 'mcp_review', 'render', 'verify', 'repair', 'report']},
|
|
15
|
+
authority: {type: 'string', enum: ['source_media', 'selected_video_template', 'video_md']},
|
|
16
|
+
completion_gates: {type: 'array', items: {type: 'string', enum: ['verify', 'real_playback', 'human_review']}},
|
|
17
|
+
reason: {type: 'string'},
|
|
18
|
+
},
|
|
19
|
+
required: ['id', 'action', 'authority', 'completion_gates', 'reason'],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
required: ['decisions'],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Preserve the model's decisions; normalize only recognized legacy envelopes. */
|
|
28
|
+
export function parseOutput(raw, expectedIds) {
|
|
29
|
+
let parsed;
|
|
30
|
+
let schemaCompliant = true;
|
|
31
|
+
try { parsed = JSON.parse(raw); }
|
|
32
|
+
catch {
|
|
33
|
+
const fence = raw.trim().match(/^```(?:json)?\s*\n([\s\S]*?)\n```$/);
|
|
34
|
+
if (!fence) throw new Error('Response is neither JSON nor a single complete JSON code fence');
|
|
35
|
+
parsed = JSON.parse(fence[1]);
|
|
36
|
+
schemaCompliant = false;
|
|
37
|
+
}
|
|
38
|
+
let decisions;
|
|
39
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed) && Object.keys(parsed).length === 1 && Array.isArray(parsed.decisions)) {
|
|
40
|
+
decisions = parsed.decisions;
|
|
41
|
+
} else if (Array.isArray(parsed)) {
|
|
42
|
+
decisions = parsed;
|
|
43
|
+
schemaCompliant = false;
|
|
44
|
+
} else if (expectedIds.length === 1 && parsed && typeof parsed === 'object' && parsed.id === expectedIds[0]) {
|
|
45
|
+
decisions = [parsed];
|
|
46
|
+
schemaCompliant = false;
|
|
47
|
+
} else {
|
|
48
|
+
throw new Error('Response has no valid decisions array');
|
|
49
|
+
}
|
|
50
|
+
if (decisions.length !== expectedIds.length || decisions.some((decision, index) => decision?.id !== expectedIds[index])) {
|
|
51
|
+
throw new Error('Response count or case identifiers differ from the input');
|
|
52
|
+
}
|
|
53
|
+
return {decisions, schemaCompliant};
|
|
54
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import {outputSchema, parseOutput} from './output-format.mjs';
|
|
4
|
+
|
|
5
|
+
const decision = {id:'cli-verify', action:'report', authority:'video_md', completion_gates:[], reason:'Use markcut verify video.md to check paths.'};
|
|
6
|
+
test('OpenAI output schema has root object and required decisions', () => {
|
|
7
|
+
const s = outputSchema();
|
|
8
|
+
assert.equal(s.type, 'object');
|
|
9
|
+
assert.deepEqual(s.required, ['decisions']);
|
|
10
|
+
assert.equal(s.properties.decisions.type, 'array');
|
|
11
|
+
assert.equal(s.additionalProperties, false);
|
|
12
|
+
assert.deepEqual(s.properties.decisions.items.required, ['id','action','authority','completion_gates','reason']);
|
|
13
|
+
});
|
|
14
|
+
test('round-trip strict OpenAI envelope preserves every decision', () => {
|
|
15
|
+
const data = parseOutput(JSON.stringify({decisions:[decision]}), ['cli-verify']);
|
|
16
|
+
assert.equal(data.schemaCompliant,true);
|
|
17
|
+
assert.deepEqual(data.decisions,[decision]);
|
|
18
|
+
});
|
|
19
|
+
test('legacy array is accepted but flagged as noncompliant', () => {
|
|
20
|
+
const data = parseOutput(JSON.stringify([decision]), ['cli-verify']);
|
|
21
|
+
assert.equal(data.schemaCompliant,false);
|
|
22
|
+
assert.deepEqual(data.decisions,[decision]);
|
|
23
|
+
});
|
|
24
|
+
test('singleton legacy object is accepted only for one matching ID', () => {
|
|
25
|
+
const data=parseOutput(JSON.stringify(decision),['cli-verify']);
|
|
26
|
+
assert.equal(data.schemaCompliant,false);
|
|
27
|
+
assert.deepEqual(data.decisions,[decision]);
|
|
28
|
+
assert.throws(()=>parseOutput(JSON.stringify(decision),['another-id']),/valid decisions array/);
|
|
29
|
+
});
|
|
30
|
+
test('single fenced JSON is accepted without silently hiding envelope failure', () => {
|
|
31
|
+
const data=parseOutput('```json\n' + JSON.stringify({decisions:[decision]}) + '\n```',['cli-verify']);
|
|
32
|
+
assert.equal(data.schemaCompliant,false);
|
|
33
|
+
});
|
|
34
|
+
test('reject incomplete batches, bad identifiers and malformed data',()=>{
|
|
35
|
+
assert.throws(()=>parseOutput(JSON.stringify({decisions:[]}),['cli-verify']),/count or case identifiers/);
|
|
36
|
+
assert.throws(()=>parseOutput(JSON.stringify({decisions:[decision]}),['other-id']),/count or case identifiers/);
|
|
37
|
+
assert.throws(()=>parseOutput('not JSON', ['cli-verify']),/neither JSON nor/);
|
|
38
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Behavioral eval runner for Codex with an existing locally authenticated provider. */
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { dirname, join, resolve } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { outputSchema, parseOutput } from './output-format.mjs';
|
|
9
|
+
|
|
10
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const root = resolve(here, '..');
|
|
12
|
+
const cases = JSON.parse(readFileSync(join(here, 'cases.json'), 'utf8'));
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
let model = 'openrouter/free', provider = 'openrouter', batchSize = 1;
|
|
15
|
+
for (let i = 0; i < args.length; i++) {
|
|
16
|
+
if (args[i] === '--model' && args[i + 1]) model = args[++i];
|
|
17
|
+
else if (args[i] === '--provider' && args[i + 1]) provider = args[++i];
|
|
18
|
+
else if (args[i] === '--batch-size' && args[i + 1]) batchSize = Number(args[++i]);
|
|
19
|
+
else { console.error(`Unsupported option ${args[i]}. Usage: node run-codex.mjs [--provider openrouter] [--model openrouter/free] [--batch-size 1]`); process.exit(2); }
|
|
20
|
+
}
|
|
21
|
+
if (!/^[a-z][a-z0-9_-]*$/.test(provider) || !/^[\w./:-]+$/.test(model) || !Number.isInteger(batchSize) || batchSize < 1 || batchSize > cases.length) {
|
|
22
|
+
console.error('Invalid provider, model, or batch size'); process.exit(2);
|
|
23
|
+
}
|
|
24
|
+
const output = mkdtempSync(join(tmpdir(), 'markcut-skill-codex-eval-'));
|
|
25
|
+
const skill = readFileSync(join(root, 'SKILL.md'), 'utf8');
|
|
26
|
+
const decisions = [];
|
|
27
|
+
const run = {model, provider, batchSize, evidenceDir: output, batches: [], strictJsonFormat: true};
|
|
28
|
+
const promptIntro = `You are an agent using a Markcut Skill for a capability-decision test. This is a dry run. DO NOT execute tools, edit files, create videos or assert that tasks were completed. Use ONLY the Skill below as the behavioral contract.\n\nFor EACH independent user request, return one decision.\n\nFields:\n- id: exact request ID.\n- action: the IMMEDIATE next action, one of vision, author, storyboard, native_preview, mcp_review, render, verify, repair, report. After changes_requested, edit video.md BEFORE verifying; do not infer the edit happened. If asked a yes/no question, answer via report without executing anything.\n- authority: source_media (observations and physical assets), selected_video_template (creative/style defaults for new video), or video_md (current video source/edit/review revision/render).\n- completion_gates: zero or more checks needed BEFORE CLAIMING the user's entire requested goal complete: verify, real_playback, human_review. Gates are NOT the immediate next action. For a playable or moving-map result, real_playback matters; for explicit human review/approval, a real human must review the CURRENT revision. Do not require human_review for an ordinary MP4 render. For a factual answer about a setting, no playback is required.\n- reason: a short explanation of the action and important boundary.\n\nReturn ONLY a JSON object with one decisions array containing the decisions above (no Markdown fences or text outside JSON), matching the provided output schema.\n\nMARKCUT SKILL:\n${skill}\n\nUSER REQUESTS:\n`;
|
|
29
|
+
|
|
30
|
+
console.log(`Target: codex/${provider}/${model}; artifacts: ${output}; cases=${cases.length}; batch-size=${batchSize}`);
|
|
31
|
+
for (let offset = 0; offset < cases.length; offset += batchSize) {
|
|
32
|
+
const selected = cases.slice(offset, offset+batchSize);
|
|
33
|
+
const batchDir = join(output, `batch-${String(1+offset/batchSize).padStart(2,'0')}`);
|
|
34
|
+
mkdirSync(batchDir);
|
|
35
|
+
const prompt = promptIntro + JSON.stringify(selected.map(({id,request})=>({id,request})), null, 2) + '\n';
|
|
36
|
+
const schemaFile = join(batchDir,'schema.json');
|
|
37
|
+
const responseFile = join(batchDir,'raw-response.txt');
|
|
38
|
+
writeFileSync(join(batchDir,'prompt.txt'),prompt);
|
|
39
|
+
writeFileSync(schemaFile,JSON.stringify(outputSchema(),null,2));
|
|
40
|
+
const cmd=['exec','--ephemeral','--skip-git-repo-check','--ignore-rules','-s','read-only','-C',batchDir,
|
|
41
|
+
'-c',`model_provider="${provider}"`,'-m',model,'-c','model_reasoning_effort="low"',
|
|
42
|
+
'--json','--output-schema',schemaFile,'--output-last-message',responseFile,'-'];
|
|
43
|
+
const result=spawnSync('codex',cmd,{cwd:batchDir,input:prompt,encoding:'utf8',timeout:150_000,maxBuffer:12_000_000});
|
|
44
|
+
writeFileSync(join(batchDir,'codex-events.jsonl'),result.stdout??'');
|
|
45
|
+
writeFileSync(join(batchDir,'codex-stderr.txt'),result.stderr??'');
|
|
46
|
+
const meta={index:1+offset/batchSize,cases:selected.map(c=>c.id),exitCode:result.status,error:result.error?.message??null,
|
|
47
|
+
modelMetadataWarning:(result.stdout??'').includes('Model metadata for'),strictJsonFormat:true};
|
|
48
|
+
run.batches.push(meta);
|
|
49
|
+
writeFileSync(join(output,'run.json'),JSON.stringify(run,null,2));
|
|
50
|
+
if (result.status!==0) {console.error(`FAIL Codex batch ${meta.index} exit=${result.status} ${result.error?.message??(result.stderr??'').slice(-450)}`);process.exit(1);}
|
|
51
|
+
const raw = readFileSync(responseFile, 'utf8');
|
|
52
|
+
let response;
|
|
53
|
+
try {
|
|
54
|
+
const parsed = parseOutput(raw, selected.map(c => c.id));
|
|
55
|
+
response = parsed.decisions;
|
|
56
|
+
meta.schemaCompliant = parsed.schemaCompliant;
|
|
57
|
+
if (!parsed.schemaCompliant) {meta.strictJsonFormat = false; run.strictJsonFormat = false;}
|
|
58
|
+
} catch (error) {
|
|
59
|
+
meta.schemaCompliant = false;
|
|
60
|
+
writeFileSync(join(output,'run.json'),JSON.stringify(run,null,2));
|
|
61
|
+
console.error(`FAIL batch ${meta.index}: ${error.message}`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
writeFileSync(join(batchDir,'normalized-responses.json'),JSON.stringify(response,null,2)+'\n');
|
|
65
|
+
writeFileSync(join(output,'run.json'),JSON.stringify(run,null,2));
|
|
66
|
+
decisions.push(...response);
|
|
67
|
+
console.log(`Batch ${meta.index}: ${response.length} decisions; strict JSON: ${meta.strictJsonFormat?'yes':'NO (legacy envelope)'}`);
|
|
68
|
+
}
|
|
69
|
+
const combined=join(output,'responses.json');
|
|
70
|
+
writeFileSync(combined,JSON.stringify(decisions,null,2)+'\n');
|
|
71
|
+
const scoring=spawnSync(process.execPath,[join(here,'check.mjs'),combined],{encoding:'utf8',maxBuffer:4_000_000});
|
|
72
|
+
writeFileSync(join(output,'score.txt'),(scoring.stdout??'')+(scoring.stderr??''));
|
|
73
|
+
process.stdout.write(scoring.stdout??'');
|
|
74
|
+
process.stderr.write(scoring.stderr??'');
|
|
75
|
+
if (!run.strictJsonFormat) console.log('FORMAT WARNING: at least one batch did not follow the output schema; original response preserved.');
|
|
76
|
+
if (run.batches.some(b=>b.modelMetadataWarning)) console.log('Codex warning: missing model metadata; fallback metadata was used.');
|
|
77
|
+
process.exit(scoring.status??1);
|