@lifeaitools/rdc-skills 0.24.9 → 0.24.11

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rdc",
3
- "version": "0.24.9",
3
+ "version": "0.24.11",
4
4
  "description": "RDC typed-agent dispatch skill suite for Claude Code — plan, build, review, overnight unattended builds with work-item tracking and TDD enforcement.",
5
5
  "author": {
6
6
  "name": "LIFEAI",
package/git-sha.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "sha": "f5ae61c0f6b40783d69bb93f6c75a46ceeff6acc"
2
+ "sha": "34ba2dc6ccb7c153deff5ebfbf6039e6fab077c8"
3
3
  }
@@ -46,6 +46,24 @@ function hasHiddenIntent(command) {
46
46
  /\bCI\s*=\s*(1|true)\b/i.test(command);
47
47
  }
48
48
 
49
+ function hasExplicitWindowOverride(command) {
50
+ return /\bRDC_ALLOW_WINDOW_FOCUS\s*=\s*(1|true)\b/i.test(command) ||
51
+ /\bRDC_INTERACTIVE_WINDOW\s*=\s*(1|true)\b/i.test(command);
52
+ }
53
+
54
+ function checkWindowFocusApi(command) {
55
+ if (hasExplicitWindowOverride(command)) return;
56
+ const focusApi = /\b(SetForegroundWindow|SwitchToThisWindow|AppActivate|SetWindowPos|ShowWindowAsync?|BringWindowToTop)\b/i;
57
+ const broadWindowApi = /\b(EnumWindows|Get-Process\s+\|\s*Where-Object|GetWindow|FindWindow)\b/i;
58
+ const windowMutation = /\b(minimi[sz]e|restore|foreground|focus|activate|collapse)\b/i;
59
+ if (focusApi.test(command) || (broadWindowApi.test(command) && windowMutation.test(command))) {
60
+ block(
61
+ 'Window focus/restore/minimize/collapse operations are not allowed in agent-launched commands. Spawn helpers hidden/no-window instead; set RDC_ALLOW_WINDOW_FOCUS=1 only for an explicitly requested interactive recovery action.',
62
+ { kind: 'window-focus-api' },
63
+ );
64
+ }
65
+ }
66
+
49
67
  function checkPlaywright(command) {
50
68
  if (!/\b(playwright|@playwright\/test)\b/i.test(command)) return;
51
69
 
@@ -68,16 +86,16 @@ function checkPowerShell(command) {
68
86
  if (!/\bStart-Process\b/i.test(command)) return;
69
87
  if (hasHiddenIntent(command)) return;
70
88
  block(
71
- '`Start-Process` must include `-WindowStyle Hidden` or `-WindowStyle Minimized` for agent-launched node/cmd/ps1/test processes.',
89
+ '`Start-Process` must include `-WindowStyle Hidden` or `-WindowStyle Minimized` for agent-launched node/cmd/ps1/test processes. Focus/restore/collapse APIs remain blocked unless explicitly requested.',
72
90
  { kind: 'start-process' },
73
91
  );
74
92
  }
75
93
 
76
94
  function checkCmdStart(command) {
77
95
  if (!/\bcmd(?:\.exe)?\s+\/c\s+start\b/i.test(command)) return;
78
- if (/\bcmd(?:\.exe)?\s+\/c\s+start\s+(""|''|`"")?\s*\/(?:min|b)\b/i.test(command)) return;
96
+ if (/\bcmd(?:\.exe)?\s+\/c\s+start\s+(""|''|`"")?\s*\/b\b/i.test(command)) return;
79
97
  block(
80
- '`cmd /c start` must use `/min` for visible tools or `/b`/a hidden wrapper for background tools.',
98
+ '`cmd /c start` must use `/min` or `/b` for background tools. Focus/restore/collapse APIs remain blocked unless explicitly requested.',
81
99
  { kind: 'cmd-start' },
82
100
  );
83
101
  }
@@ -98,6 +116,7 @@ async function main() {
98
116
  const command = toolText(raw);
99
117
  if (!command) pass({ reason: 'no-command' });
100
118
 
119
+ checkWindowFocusApi(command);
101
120
  checkPlaywright(command);
102
121
  checkPowerShell(command);
103
122
  checkCmdStart(command);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifeaitools/rdc-skills",
3
- "version": "0.24.9",
3
+ "version": "0.24.11",
4
4
  "description": "RDC typed-agent dispatch skill suite for Claude Code - plan, build, review, overnight builds",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -35,6 +35,8 @@
35
35
  "rdc-design": "node scripts/rdc-design-cli.mjs",
36
36
  "test:hooks": "node scripts/test-rdc-hooks.mjs",
37
37
  "test:truth-gate": "node tests/run-evidence-gate.test.mjs && node tests/work-item-exit-gate-l2.test.mjs && node tests/work-item-exit-gate-l3.test.mjs && node tests/require-work-item-on-commit.test.mjs && node tests/harness-gates.test.mjs",
38
+ "test:acceptance": "node tests/acceptance.test.mjs",
39
+ "acceptance": "node scripts/acceptance.mjs --changed",
38
40
  "test:mcp": "node tests/mcp.test.mjs",
39
41
  "test:mcp:remote": "node tests/mcp.test.mjs --remote",
40
42
  "test:channel-formatter": "node tests/channel-formatter.contract.test.mjs",
@@ -0,0 +1,471 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Build acceptance runner for touched rdc:* skills.
4
+ *
5
+ * Runs one sandboxed agent fixture per selected skill, records all observable
6
+ * engine events/tool calls to JSONL, verifies manifest assertions, and writes a
7
+ * Markdown report with lessons learned / next build optimizations.
8
+ */
9
+
10
+ import { execFileSync } from 'node:child_process';
11
+ import { existsSync, mkdirSync, writeFileSync, appendFileSync } from 'node:fs';
12
+ import { basename, dirname, join, resolve } from 'node:path';
13
+ import { fileURLToPath } from 'node:url';
14
+
15
+ import { loadAllManifests } from './lib/manifest-schema.mjs';
16
+ import { runManifest } from './lib/runner.mjs';
17
+
18
+ const __dirname = dirname(fileURLToPath(import.meta.url));
19
+ const REPO_ROOT = resolve(__dirname, '..');
20
+ const REPORTS_DIR = join(REPO_ROOT, '.rdc', 'reports');
21
+
22
+ const args = process.argv.slice(2);
23
+ const arg = (name, fallback = null) => {
24
+ const i = args.indexOf(name);
25
+ return i >= 0 ? args[i + 1] || fallback : fallback;
26
+ };
27
+ const has = (name) => args.includes(name);
28
+
29
+ const ENGINE = arg('--engine', process.env.RDC_ACCEPTANCE_ENGINE || 'claude').toLowerCase();
30
+ const BASE = arg('--base', process.env.RDC_ACCEPTANCE_BASE || 'HEAD~1');
31
+ const PROJECT_CWD = resolve(arg('--project-root', process.env.REGEN_ROOT || process.cwd()));
32
+ const RUN_ID = arg('--run-id', `acceptance-${new Date().toISOString().replace(/[:.]/g, '-')}`);
33
+ const PARALLEL = Math.max(1, parseInt(arg('--parallel', '1'), 10) || 1);
34
+ const CHANGED = has('--changed');
35
+ const STRICT_RECORDING = has('--strict-recording');
36
+ const ONLY_SKILLS = args
37
+ .flatMap((v, i) => (v === '--skill' && args[i + 1] ? [args[i + 1]] : []))
38
+ .map(normalizeSkillName);
39
+
40
+ function normalizeSkillName(name) {
41
+ if (!name) return name;
42
+ return name.startsWith('rdc:') ? name : `rdc:${name.replace(/^rdc-/, '')}`;
43
+ }
44
+
45
+ function sh(cmd, cmdArgs, cwd = REPO_ROOT) {
46
+ return execFileSync(cmd, cmdArgs, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
47
+ }
48
+
49
+ function changedFiles(base) {
50
+ try {
51
+ const mergeBase = sh('git', ['merge-base', base, 'HEAD']);
52
+ const out = sh('git', ['diff', '--name-only', `${mergeBase}..HEAD`]);
53
+ return out ? out.split(/\r?\n/).filter(Boolean) : [];
54
+ } catch {
55
+ const out = sh('git', ['diff', '--name-only', base]);
56
+ return out ? out.split(/\r?\n/).filter(Boolean) : [];
57
+ }
58
+ }
59
+
60
+ function skillFromPath(file) {
61
+ const p = file.replace(/\\/g, '/');
62
+ const m = p.match(/^skills\/([^/]+)\//);
63
+ if (!m || m[1] === 'tests') return null;
64
+ return `rdc:${m[1]}`;
65
+ }
66
+
67
+ function touchedSkillsFromGit(base) {
68
+ const skills = new Set();
69
+ for (const file of changedFiles(base)) {
70
+ const skill = skillFromPath(file);
71
+ if (skill) skills.add(skill);
72
+ const test = file.replace(/\\/g, '/').match(/^skills\/tests\/rdc-(.+)\.test\.json$/);
73
+ if (test) skills.add(`rdc:${test[1]}`);
74
+ }
75
+ return [...skills].sort();
76
+ }
77
+
78
+ function parseJsonLines(text) {
79
+ const events = [];
80
+ for (const line of String(text || '').split(/\r?\n/)) {
81
+ const trimmed = line.trim();
82
+ if (!trimmed || !trimmed.startsWith('{')) continue;
83
+ try {
84
+ events.push(JSON.parse(trimmed));
85
+ } catch {
86
+ // Non-JSON output is still captured in stdout/stderr previews.
87
+ }
88
+ }
89
+ return events;
90
+ }
91
+
92
+ function findToolName(value) {
93
+ if (!value || typeof value !== 'object') return null;
94
+ if (typeof value.name === 'string') return value.name;
95
+ if (typeof value.tool_name === 'string') return value.tool_name;
96
+ if (typeof value.tool === 'string') return value.tool;
97
+ if (typeof value.server_name === 'string' && typeof value.tool_name === 'string') {
98
+ return `${value.server_name}.${value.tool_name}`;
99
+ }
100
+ return null;
101
+ }
102
+
103
+ function claudeToolCalls(stdout) {
104
+ const calls = [];
105
+ for (const event of parseJsonLines(stdout)) {
106
+ const type = event.type || event.event || event.kind || '';
107
+ const msg = event.message || event;
108
+ const content = Array.isArray(msg.content) ? msg.content : Array.isArray(event.content) ? event.content : [];
109
+ for (const item of content) {
110
+ if (item?.type === 'tool_use') {
111
+ calls.push({
112
+ engine: 'claude',
113
+ id: item.id || null,
114
+ name: item.name || null,
115
+ input: item.input || null,
116
+ raw_type: type || 'tool_use',
117
+ });
118
+ }
119
+ }
120
+ if (/tool/i.test(type)) {
121
+ const name = findToolName(event);
122
+ calls.push({
123
+ engine: 'claude',
124
+ id: event.id || event.tool_use_id || null,
125
+ name,
126
+ input: event.input || event.arguments || event.params || null,
127
+ raw_type: type,
128
+ });
129
+ }
130
+ }
131
+ return dedupeCalls(calls);
132
+ }
133
+
134
+ function assistantText(engine, stdout) {
135
+ if (engine !== 'claude') return String(stdout || '').trim();
136
+ const resultEvents = parseJsonLines(stdout).filter((event) => event.type === 'result' && typeof event.result === 'string');
137
+ if (resultEvents.length > 0) return resultEvents.at(-1).result.trim();
138
+ const chunks = [];
139
+ for (const event of parseJsonLines(stdout)) {
140
+ const msg = event.message || event;
141
+ const content = Array.isArray(msg.content) ? msg.content : Array.isArray(event.content) ? event.content : [];
142
+ for (const item of content) {
143
+ if (item?.type === 'text' && typeof item.text === 'string') chunks.push(item.text);
144
+ }
145
+ if (event.type === 'result' && typeof event.result === 'string') chunks.push(event.result);
146
+ }
147
+ return chunks.join('\n\n').trim();
148
+ }
149
+
150
+ function outputAssertionFailures(spec, rendered) {
151
+ const failures = [];
152
+ if (!spec || typeof spec !== 'object') return failures;
153
+ if (Array.isArray(spec.output_contains)) {
154
+ const missing = spec.output_contains.filter((s) => !rendered.includes(s));
155
+ if (missing.length > 0) {
156
+ failures.push({
157
+ predicate: 'acceptance.output_contains',
158
+ message: `missing output substrings: ${missing.map((s) => JSON.stringify(s)).join(', ')}`,
159
+ });
160
+ }
161
+ }
162
+ if (Array.isArray(spec.output_not_contains)) {
163
+ const present = spec.output_not_contains.filter((s) => rendered.includes(s));
164
+ if (present.length > 0) {
165
+ failures.push({
166
+ predicate: 'acceptance.output_not_contains',
167
+ message: `forbidden output substrings present: ${present.map((s) => JSON.stringify(s)).join(', ')}`,
168
+ });
169
+ }
170
+ }
171
+ return failures;
172
+ }
173
+
174
+ function toolCallAssertionFailures(spec, toolCalls) {
175
+ const failures = [];
176
+ if (!spec || typeof spec !== 'object') return failures;
177
+ const names = toolCalls.map((call) => call.name).filter(Boolean);
178
+ if (Array.isArray(spec.tool_calls_include_any) && spec.tool_calls_include_any.length > 0) {
179
+ const hit = spec.tool_calls_include_any.some((expected) => names.includes(expected));
180
+ if (!hit) {
181
+ failures.push({
182
+ predicate: 'acceptance.tool_calls_include_any',
183
+ message: `expected at least one tool call from: ${spec.tool_calls_include_any.join(', ')}; saw: ${names.join(', ') || '(none)'}`,
184
+ });
185
+ }
186
+ }
187
+ if (Array.isArray(spec.tool_calls_include_all) && spec.tool_calls_include_all.length > 0) {
188
+ const missing = spec.tool_calls_include_all.filter((expected) => !names.includes(expected));
189
+ if (missing.length > 0) {
190
+ failures.push({
191
+ predicate: 'acceptance.tool_calls_include_all',
192
+ message: `missing required tool calls: ${missing.join(', ')}; saw: ${names.join(', ') || '(none)'}`,
193
+ });
194
+ }
195
+ }
196
+ if (Array.isArray(spec.tool_calls_argument_matches) && spec.tool_calls_argument_matches.length > 0) {
197
+ for (const matcher of spec.tool_calls_argument_matches) {
198
+ const tools = Array.isArray(matcher.tools) ? matcher.tools : [];
199
+ const pattern = typeof matcher.pattern === 'string' ? matcher.pattern : '';
200
+ if (tools.length === 0 || !pattern) continue;
201
+ let re = null;
202
+ try {
203
+ re = new RegExp(pattern, 'i');
204
+ } catch {
205
+ failures.push({
206
+ predicate: 'acceptance.tool_calls_argument_matches',
207
+ message: `invalid matcher regex: ${pattern}`,
208
+ });
209
+ continue;
210
+ }
211
+ const hit = toolCalls.some((call) => tools.includes(call.name) && re.test(JSON.stringify(call.input || {})));
212
+ if (!hit) {
213
+ failures.push({
214
+ predicate: 'acceptance.tool_calls_argument_matches',
215
+ message: `expected one of ${tools.join(', ')} with arguments matching /${pattern}/`,
216
+ });
217
+ }
218
+ }
219
+ }
220
+ return failures;
221
+ }
222
+
223
+ function codexToolCalls(stdout) {
224
+ const calls = [];
225
+ for (const event of parseJsonLines(stdout)) {
226
+ const type = event.type || event.event || event.kind || '';
227
+ const name = findToolName(event) || findToolName(event.call) || findToolName(event.item);
228
+ if (/tool|function/i.test(type) || name) {
229
+ calls.push({
230
+ engine: 'codex',
231
+ id: event.id || event.call_id || event.item_id || null,
232
+ name,
233
+ input: event.input || event.arguments || event.params || event.call?.arguments || null,
234
+ raw_type: type || null,
235
+ });
236
+ }
237
+ }
238
+ return dedupeCalls(calls);
239
+ }
240
+
241
+ function dedupeCalls(calls) {
242
+ const seen = new Set();
243
+ const out = [];
244
+ for (const call of calls) {
245
+ const key = JSON.stringify([call.engine, call.id, call.name, call.raw_type, call.input]);
246
+ if (seen.has(key)) continue;
247
+ seen.add(key);
248
+ out.push(call);
249
+ }
250
+ return out;
251
+ }
252
+
253
+ function extractToolCalls(engine, observed) {
254
+ if (engine === 'claude') return claudeToolCalls(observed?.stdout || '');
255
+ if (engine === 'codex') return codexToolCalls(`${observed?.stdout || ''}\n${observed?.stderr || ''}`);
256
+ throw new Error(`unsupported engine: ${engine}`);
257
+ }
258
+
259
+ function writeJsonl(file, event) {
260
+ appendFileSync(file, `${JSON.stringify({ ts: new Date().toISOString(), ...event })}\n`);
261
+ }
262
+
263
+ function markdownReport({ runId, engine, selected, results, jsonlPath, artifactDir, startedAt, durationMs }) {
264
+ const passed = results.filter((r) => r.pass).length;
265
+ const failed = results.length - passed;
266
+ const lines = [
267
+ '---',
268
+ 'type: rdc-skill-acceptance-report',
269
+ `run_id: ${runId}`,
270
+ `engine: ${engine}`,
271
+ `created_at: ${new Date().toISOString()}`,
272
+ '---',
273
+ '',
274
+ `# RDC Skill Acceptance - ${runId}`,
275
+ '',
276
+ `Started: ${startedAt}`,
277
+ `Duration: ${durationMs} ms`,
278
+ `Evidence JSONL: ${jsonlPath}`,
279
+ `Artifacts: ${artifactDir}`,
280
+ '',
281
+ `Summary: ${passed} passed, ${failed} failed, ${results.length} total.`,
282
+ '',
283
+ '## Skills',
284
+ '',
285
+ ];
286
+ for (const r of results) {
287
+ const status = r.pass ? 'PASS' : 'FAIL';
288
+ lines.push(`- ${r.skill}: ${status}; tool calls=${r.tool_calls.length}; duration=${r.duration_ms || 0} ms`);
289
+ if (r.artifacts?.assistant_text) lines.push(` - output: ${r.artifacts.assistant_text}`);
290
+ if (r.artifacts?.stdout) lines.push(` - raw stream: ${r.artifacts.stdout}`);
291
+ if (r.failures?.length) {
292
+ for (const failure of r.failures) {
293
+ lines.push(` - ${failure.predicate || 'failure'}: ${failure.message || JSON.stringify(failure)}`);
294
+ }
295
+ }
296
+ }
297
+ lines.push('', '## Lessons Learned', '');
298
+ const noToolCalls = results.filter((r) => r.pass && r.tool_calls.length === 0);
299
+ if (noToolCalls.length > 0) {
300
+ lines.push(`- ${noToolCalls.map((r) => r.skill).join(', ')} passed without observable tool calls. That may be valid for pure formatting/read-only skills, but build acceptance should decide whether those skills need a stricter artifact assertion.`);
301
+ }
302
+ if (failed > 0) {
303
+ lines.push('- Failed skill runs should generate a focused fixture or assertion update before the next build wave is accepted.');
304
+ }
305
+ if (results.every((r) => r.tool_calls.length > 0)) {
306
+ lines.push('- All selected skills emitted observable tool calls in the engine stream.');
307
+ }
308
+ lines.push('', '## Next Build Optimizations', '');
309
+ lines.push('- Keep one fast manifest per rdc:* skill touched by a PR or build wave.');
310
+ lines.push('- Add engine-specific parsers as new event formats appear instead of weakening the acceptance gate.');
311
+ lines.push('- Promote recurring failure patterns into manifest assertions rather than relying on transcript review.');
312
+ lines.push('', '## Selected Skills', '');
313
+ for (const skill of selected) lines.push(`- ${skill}`);
314
+ lines.push('');
315
+ return lines.join('\n');
316
+ }
317
+
318
+ async function runPool(items, parallel, worker) {
319
+ const results = new Array(items.length);
320
+ let next = 0;
321
+ async function lane() {
322
+ while (next < items.length) {
323
+ const i = next++;
324
+ results[i] = await worker(items[i], i);
325
+ }
326
+ }
327
+ await Promise.all(Array.from({ length: Math.min(parallel, items.length) }, lane));
328
+ return results;
329
+ }
330
+
331
+ async function main() {
332
+ if (!['claude', 'codex'].includes(ENGINE)) {
333
+ console.error(`unsupported --engine ${ENGINE}; expected claude or codex`);
334
+ process.exit(2);
335
+ }
336
+ if (ENGINE === 'codex') {
337
+ console.error('codex acceptance adapter can parse Codex JSONL, but live Codex agent spawning is not wired in this repo yet.');
338
+ process.exit(2);
339
+ }
340
+
341
+ mkdirSync(REPORTS_DIR, { recursive: true });
342
+ const startedAt = new Date().toISOString();
343
+ const started = Date.now();
344
+ const jsonlPath = join(REPORTS_DIR, `${RUN_ID}.jsonl`);
345
+ const mdPath = join(REPORTS_DIR, `${RUN_ID}.md`);
346
+ const artifactDir = join(REPORTS_DIR, RUN_ID);
347
+ mkdirSync(artifactDir, { recursive: true });
348
+
349
+ const selected = new Set(ONLY_SKILLS);
350
+ if (CHANGED) for (const skill of touchedSkillsFromGit(BASE)) selected.add(skill);
351
+ if (selected.size === 0) {
352
+ console.error('no skills selected; pass --changed and/or --skill rdc:name');
353
+ process.exit(2);
354
+ }
355
+
356
+ const manifests = loadAllManifests();
357
+ const bySkill = new Map(manifests.filter((m) => m.ok && m.manifest).map((m) => [m.manifest.skill, m]));
358
+ const missing = [...selected].filter((skill) => !bySkill.has(skill));
359
+ for (const skill of missing) {
360
+ writeJsonl(jsonlPath, { kind: 'missing_manifest', run_id: RUN_ID, skill });
361
+ }
362
+ if (missing.length > 0) {
363
+ console.error(`missing acceptance manifest(s): ${missing.join(', ')}`);
364
+ console.error(`evidence: ${jsonlPath}`);
365
+ process.exit(1);
366
+ }
367
+
368
+ const selectedManifests = [...selected].sort().map((skill) => bySkill.get(skill).manifest);
369
+ writeJsonl(jsonlPath, {
370
+ kind: 'start',
371
+ run_id: RUN_ID,
372
+ engine: ENGINE,
373
+ selected: selectedManifests.map((m) => m.skill),
374
+ project_cwd: PROJECT_CWD,
375
+ });
376
+
377
+ const results = await runPool(selectedManifests, PARALLEL, async (manifest) => {
378
+ writeJsonl(jsonlPath, { kind: 'skill_start', run_id: RUN_ID, skill: manifest.skill, prompt: manifest.fixture?.prompt });
379
+ const result = await runManifest(manifest, {
380
+ runId: RUN_ID,
381
+ projectCwd: PROJECT_CWD,
382
+ });
383
+ const toolCalls = result.observed ? extractToolCalls(ENGINE, result.observed) : [];
384
+ const safeSkill = manifest.skill.replace(/[^a-z0-9-]+/gi, '-').replace(/^-+|-+$/g, '');
385
+ const stdoutPath = join(artifactDir, `${safeSkill}.stdout.jsonl`);
386
+ const stderrPath = join(artifactDir, `${safeSkill}.stderr.txt`);
387
+ const assistantPath = join(artifactDir, `${safeSkill}.assistant.md`);
388
+ const rendered = assistantText(ENGINE, result.observed?.stdout || '');
389
+ writeFileSync(stdoutPath, result.observed?.stdout || '');
390
+ writeFileSync(stderrPath, result.observed?.stderr || '');
391
+ writeFileSync(assistantPath, rendered || '');
392
+ const failures = [
393
+ ...(result.failures || []),
394
+ ...outputAssertionFailures(manifest.acceptance, rendered),
395
+ ...toolCallAssertionFailures(manifest.acceptance, toolCalls),
396
+ ];
397
+ const pass = failures.length === 0 && Boolean(result.pass) && (!STRICT_RECORDING || toolCalls.length > 0);
398
+ if (result.pass && STRICT_RECORDING && toolCalls.length === 0) {
399
+ failures.push({ predicate: 'tool_calls', message: 'strict recording requires at least one observable tool call' });
400
+ }
401
+ writeJsonl(jsonlPath, {
402
+ kind: 'skill_result',
403
+ run_id: RUN_ID,
404
+ skill: manifest.skill,
405
+ pass,
406
+ duration_ms: result.duration_ms,
407
+ tool_calls: toolCalls,
408
+ failures,
409
+ artifacts: {
410
+ stdout: stdoutPath,
411
+ stderr: stderrPath,
412
+ assistant_text: assistantPath,
413
+ },
414
+ assistant_preview: rendered.slice(0, 2000),
415
+ worktree: result.worktree || null,
416
+ observed: {
417
+ exit_code: result.observed?.exit_code,
418
+ timed_out: result.observed?.timed_out,
419
+ files_modified: result.observed?.files_modified || [],
420
+ commits: result.observed?.commits || [],
421
+ stdout_chars: result.observed?.stdout?.length || 0,
422
+ stderr_chars: result.observed?.stderr?.length || 0,
423
+ },
424
+ });
425
+ return {
426
+ ...result,
427
+ pass,
428
+ failures,
429
+ tool_calls: toolCalls,
430
+ artifacts: {
431
+ stdout: stdoutPath,
432
+ stderr: stderrPath,
433
+ assistant_text: assistantPath,
434
+ },
435
+ assistant_preview: rendered.slice(0, 2000),
436
+ };
437
+ });
438
+
439
+ const durationMs = Date.now() - started;
440
+ writeJsonl(jsonlPath, {
441
+ kind: 'end',
442
+ run_id: RUN_ID,
443
+ duration_ms: durationMs,
444
+ pass: results.filter((r) => r.pass).length,
445
+ fail: results.filter((r) => !r.pass).length,
446
+ });
447
+ writeFileSync(mdPath, markdownReport({
448
+ runId: RUN_ID,
449
+ engine: ENGINE,
450
+ selected: selectedManifests.map((m) => m.skill),
451
+ results,
452
+ jsonlPath,
453
+ artifactDir,
454
+ startedAt,
455
+ durationMs,
456
+ }));
457
+
458
+ const failed = results.filter((r) => !r.pass);
459
+ console.log(`rdc skill acceptance: ${results.length - failed.length} passed, ${failed.length} failed`);
460
+ console.log(`evidence: ${jsonlPath}`);
461
+ console.log(`report: ${mdPath}`);
462
+ if (failed.length > 0) {
463
+ for (const r of failed) console.log(`FAIL ${r.skill}: ${r.failures?.map((f) => f.message).join('; ') || r.error || 'unknown'}`);
464
+ process.exit(1);
465
+ }
466
+ }
467
+
468
+ main().catch((error) => {
469
+ console.error(error);
470
+ process.exit(1);
471
+ });