mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-26 18:04:31 +01:00
feat(design-motion): new /design-motion skill: showcase MP4 and GIF loops from a design, adapted from Elaya design-to-motion (GSTA-92 phase 2)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
975e836382
commit
c922ec74f5
32 files changed
+2314
-5
No files matched your search
@@ -46,8 +46,17 @@ import { skillCensus } from './helpers/skill-census';
|
||||
* New-skill ratchet: previous ceiling 1,194 + ceil(10 / 4) = 1,197
|
||||
* token-equivalents (4,788 bytes), leaving 2 bytes. Existing descriptions
|
||||
* are unchanged.
|
||||
* ref design-motion addition on 975e836 (2026-10-25), Garry 2026-10-25
|
||||
* 'Do it' (GSTA-92 plan item 15)
|
||||
* result pre-addition aggregate 4,786 bytes; design-motion adds 99 bytes
|
||||
* (name + the trimmed lead "animate an approved design into a
|
||||
* seamless MP4 and GIF loop"), yielding 4,885 bytes = 1,222
|
||||
* token-equivalents including the root router alias.
|
||||
* New-skill ratchet: previous ceiling 1,197 + ceil(99 / 4) = 1,222
|
||||
* token-equivalents (4,888 bytes), the measured size. Existing descriptions
|
||||
* are unchanged.
|
||||
*/
|
||||
const CATALOG_BUDGET_TOKEN_EQUIVALENTS = 1_197;
|
||||
const CATALOG_BUDGET_TOKEN_EQUIVALENTS = 1_222;
|
||||
|
||||
// Largest today: design-consultation at 229 bytes. A description that needs
|
||||
// more than 260 bytes is a body paragraph, not a catalog entry.
|
||||
|
||||
Vendored
+1
@@ -16,6 +16,7 @@
|
||||
"cso": 4660,
|
||||
"design-consultation": 16188,
|
||||
"design-html": 14380,
|
||||
"design-motion": 10409,
|
||||
"design-review": 35808,
|
||||
"design-shotgun": 14901,
|
||||
"deslop-shared-libs": 3411,
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Ledgerline weekly summary</title>
|
||||
<style>
|
||||
html, body { margin: 0; background: #f4f1ea; }
|
||||
.frame { position: relative; width: 640px; height: 400px; font: 500 15px/1.35 Georgia, serif; color: #1f1c17; }
|
||||
.card { position: absolute; top: 48px; width: 272px; height: 304px; border-radius: 16px; background: #fffdf8;
|
||||
box-shadow: 0 8px 20px rgba(31, 28, 23, 0.08); overflow: hidden; }
|
||||
.revenue { left: 32px; }
|
||||
.queue { left: 336px; }
|
||||
h2 { margin: 22px 22px 4px; font-size: 15px; font-weight: 600; }
|
||||
.value { margin: 0 22px; font-size: 30px; font-variant-numeric: tabular-nums; }
|
||||
.bars { position: absolute; left: 22px; right: 22px; bottom: 26px; height: 120px; display: flex; align-items: flex-end; gap: 10px; }
|
||||
.bars span { flex: 1; border-radius: 4px 4px 0 0; background: #3f6b5c; }
|
||||
.rows { margin: 18px 22px 0; padding: 0; list-style: none; }
|
||||
.rows li { display: flex; justify-content: space-between; padding: 11px 0; border-top: 1px solid #ece6da; }
|
||||
.rows b { font-weight: 600; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main class="frame">
|
||||
<section class="card revenue">
|
||||
<h2>Collected this week</h2>
|
||||
<p class="value">$48,120</p>
|
||||
<div class="bars"><span style="height:42%"></span><span style="height:61%"></span><span style="height:55%"></span><span style="height:78%"></span><span style="height:70%"></span><span style="height:92%"></span></div>
|
||||
</section>
|
||||
<section class="card queue">
|
||||
<h2>Invoices due</h2>
|
||||
<ul class="rows">
|
||||
<li><span>Harbor Dental</span><b>$2,340</b></li>
|
||||
<li><span>Pinecrest Studio</span><b>$1,180</b></li>
|
||||
<li><span>Okafor & Lane</span><b>$4,905</b></li>
|
||||
<li><span>Mill Street Bakery</span><b>$612</b></li>
|
||||
</ul>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -791,6 +791,42 @@ do not launch the downstream skill or open a browser.`,
|
||||
mustContain: ["Don't make me think", "Users scan, they don't read", 'trunk test', '44px minimum'],
|
||||
},
|
||||
|
||||
// ── GSTA-92 plan item 15 (Garry 2026-10-25 "Do it"): /design-motion ──
|
||||
// Fidelity, motion and the optional Figma path are lazy; the doctrine, the
|
||||
// capture/check/export steps and their bins stay always loaded. The paid
|
||||
// design-motion-showcase case drives a fixture page through the whole flow
|
||||
// and asserts the fidelity and motion reads.
|
||||
'design-motion': {
|
||||
skill: 'design-motion',
|
||||
expectedSections: ['fidelity.md', 'motion.md', 'figma.md'],
|
||||
requiredReads: ['fidelity.md', 'motion.md'],
|
||||
scenario:
|
||||
'Covered by the design-motion-showcase case in test/skill-e2e-design.test.ts: a finalized.html fixture is rebuilt into a page with the capture contract, captured, checked and exported.',
|
||||
staticInvariants: {
|
||||
mustStayInSkeleton: [
|
||||
'## Motion doctrine',
|
||||
'one authored motion moment per page',
|
||||
'## Step 5: Capture',
|
||||
'## Step 6: Motion checks (before any export)',
|
||||
'gstack-motion-encode check',
|
||||
'## Step 7: Export and report',
|
||||
'## Important Rules',
|
||||
],
|
||||
mustMoveToSection: [
|
||||
'### Loading choreography',
|
||||
'### Stories: one per visual',
|
||||
'### Page architecture and the capture contract',
|
||||
'### Layer export',
|
||||
],
|
||||
gateAfterStop: undefined,
|
||||
},
|
||||
behavioral: 'external',
|
||||
externalTest: 'test/skill-e2e-design.test.ts',
|
||||
maxSkeletonBytes: 39_900, // new skill (GSTA-92 plan item 15, Garry 2026-10-25 "Do it"); measured skeleton 39,836 (2026-10-25)
|
||||
minUnionBytes: 57_500, // measured union 58,666 (2026-10-25)
|
||||
mustContain: ['window.__start()', 'window.__tick(dt)', 'whole milliseconds averaging 1000/60', 'Content never hides behind animation timing'],
|
||||
},
|
||||
|
||||
// ── Multi-agent wave PR D3 (2026-10-10): investigate recipes carve ──
|
||||
// Five lazy recipes (flake, polluter, race, eval-bisect, backlog) read when
|
||||
// the Phase 2 pattern or the --backlog argument matches; Phases 1–5, the
|
||||
|
||||
@@ -73,6 +73,13 @@ export const IDENTIFIER_PLACEHOLDERS: Record<string, IdentifierGrammar> = {
|
||||
'<slug>': { grammar: ID, what: 'slug' },
|
||||
'<dimension>': { grammar: ID, what: 'design dimension slug' },
|
||||
'<dim>': { grammar: ID, what: 'profile dimension name' },
|
||||
// /design-motion (GSTA-92 plan item 15): capture and export arguments the skill's plan fixes.
|
||||
'<frame-size>': { grammar: /^[0-9]+x[0-9]+$/, what: 'design frame size in CSS pixels, WxH' },
|
||||
'<cycle-seconds>': { grammar: NUMBER, what: 'loop cycle length in seconds' },
|
||||
'<app|cards>': { grammar: oneOf('app', 'cards'), what: 'motion layout: joined app surfaces or separate cards' },
|
||||
'<hex-color>': { grammar: /^#[0-9A-Fa-f]{3,8}$/, what: 'page background colour as hex', quoted: true },
|
||||
'<figma-file-key>': { grammar: ID, what: 'Figma file key from the link' },
|
||||
'<figma-node-id>': { grammar: /^[0-9]+[:-][0-9]+$/, what: 'Figma node id from the link' },
|
||||
'<new_value>': { grammar: NUMBER, what: 'profile dimension value' },
|
||||
'<Q1_VALUE>': { grammar: NUMBER, what: 'profile answer value' },
|
||||
'<Q2_VALUE>': { grammar: NUMBER, what: 'profile answer value' },
|
||||
|
||||
@@ -857,6 +857,7 @@ export const E2E_TOUCHFILES: Record<string, string[]> = {
|
||||
'scripts/resolvers/testing.ts', 'test/helpers/aside-available.ts', 'test/helpers/llm-judge.ts', 'test/helpers/office-hours-attempt.ts'],
|
||||
'design-review-plugin-handoff': ['bin/gstack-state-root.sh', 'lib/state-root.ts', 'design-review/**', 'scripts/resolvers/design.ts', 'scripts/resolvers/outside-voice.ts', 'scripts/resolvers/testing.ts', 'lib/design-catalog.ts', 'lib/design-detect-contract.ts', 'bin/gstack-design-detect.ts', 'test/helpers/hermetic-env.ts', 'test/helpers/fake-impeccable.ts', 'test/fixtures/fake-impeccable.ts', 'test/fixtures/impeccable-detect-sample.json', 'test/fixtures/review-eval-design-slop.html', 'test/fixtures/review-eval-design-slop.css', 'test/skill-e2e-design.test.ts', 'test/helpers/aside-available.ts', 'test/helpers/llm-judge.ts', 'test/helpers/office-hours-attempt.ts'],
|
||||
'design-html-slop-gate': ['bin/gstack-state-root.sh', 'lib/state-root.ts', 'design-html/**', 'scripts/resolvers/design.ts', 'scripts/resolvers/outside-voice.ts', 'lib/design-detect-contract.ts', 'bin/gstack-design-detect.ts', 'test/helpers/fake-impeccable.ts', 'test/fixtures/fake-impeccable.ts', 'test/fixtures/impeccable-detect-sample.json', 'test/skill-e2e-design.test.ts', 'test/fixtures/review-eval-design-slop.html', 'test/fixtures/review-eval-design-slop.css', 'test/helpers/aside-available.ts', 'test/helpers/llm-judge.ts', 'test/helpers/office-hours-attempt.ts'],
|
||||
'design-motion-showcase': ['design-motion/**', 'bin/gstack-motion-capture.ts', 'bin/gstack-motion-encode', 'lib/motion-capture.ts', 'lib/motion-encode.ts', 'test/fixtures/design-motion-finalized.html', 'bin/gstack-browser-ensure', 'bin/gstack-state-root.sh', 'lib/state-root.ts', 'test/skill-e2e-design.test.ts', 'test/helpers/fake-impeccable.ts', 'test/fixtures/fake-impeccable.ts', 'test/fixtures/review-eval-design-slop.html', 'test/fixtures/review-eval-design-slop.css', 'test/helpers/aside-available.ts', 'test/helpers/llm-judge.ts', 'test/helpers/office-hours-attempt.ts'],
|
||||
|
||||
// /diagram (diagram-render bundle consumers). Triplet = deterministic
|
||||
// functional (gate); authoring quality = LLM-judged benchmark (periodic).
|
||||
@@ -1448,6 +1449,7 @@ export const E2E_TIERS: Record<string, 'gate' | 'periodic' | 'marathon'> = {
|
||||
'design-review-detector-shim-dom': 'gate', // same shim, DOM mode through the browse binary's dump; self-skips when the binary is absent
|
||||
'design-review-plugin-handoff': 'gate',
|
||||
'design-html-slop-gate': 'periodic', // one-pass gate behavior is a judgment call on a fake engine's fixed output
|
||||
'design-motion-showcase': 'periodic', // a showcase capture is a judgment-heavy creative run; it needs ffmpeg and Chromium
|
||||
|
||||
// /diagram — triplet is deterministic functional (gstack-render falls back
|
||||
// to the browse daemon, so CI runs it); judge is a quality benchmark
|
||||
@@ -1856,6 +1858,7 @@ export const E2E_KINDS: Record<string, 'rule' | 'behavior' | 'judge'> = {
|
||||
'design-review-detector-shim-dom': 'rule',
|
||||
'design-review-plugin-handoff': 'rule',
|
||||
'design-html-slop-gate': 'behavior',
|
||||
'design-motion-showcase': 'behavior',
|
||||
'diagram-triplet': 'rule',
|
||||
'diagram-authoring-quality': 'rule',
|
||||
'gstack-upgrade-happy-path': 'rule',
|
||||
@@ -1980,6 +1983,8 @@ export const BEHAVIOR_WHY: Record<string, string> = {
|
||||
"Avoiding neutral posture and naming a because-reason is live formatting of one question.",
|
||||
'design-html-slop-gate':
|
||||
"How many scan passes the one-pass slop gate takes on a fake engine's fixed output is a judgment call.",
|
||||
'design-motion-showcase':
|
||||
"The stories and the number of check-fix rounds vary per run; reading the sections, running check before export and a clean result stay the contract.",
|
||||
'scrape-match-path':
|
||||
"The /scrape fallback no longer prescribes the browser-skills match flow, so taking it is prompt compliance.",
|
||||
'dx-error-contract-review':
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import * as path from 'path';
|
||||
import {
|
||||
captureScale, clockMs, maskCss, parseCaptureArgs, planCapture, stepMs, withMode, type CaptureOptions,
|
||||
} from '../lib/motion-capture';
|
||||
|
||||
const ROOT = path.resolve(import.meta.dir, '..');
|
||||
const BIN = path.join(ROOT, 'bin', 'gstack-motion-capture.ts');
|
||||
|
||||
describe('capture timing', () => {
|
||||
test('steps are whole milliseconds averaging 1000/60', () => {
|
||||
expect(Array.from({ length: 6 }, (_, i) => stepMs(i))).toEqual([17, 16, 17, 17, 16, 17]);
|
||||
const steps = Array.from({ length: 720 }, (_, i) => stepMs(i));
|
||||
expect(steps.every(s => s === 16 || s === 17)).toBe(true);
|
||||
expect(steps.slice(0, 60).reduce((a, b) => a + b, 0)).toBe(1000);
|
||||
expect(steps.reduce((a, b) => a + b, 0)).toBe(12_000);
|
||||
});
|
||||
|
||||
test('the page clock is 0 before the start and sums the steps from PRE on', () => {
|
||||
expect(clockMs(0, 15)).toBe(0);
|
||||
expect(clockMs(14, 15)).toBe(0);
|
||||
expect(clockMs(15, 15)).toBe(stepMs(15));
|
||||
let sum = 0;
|
||||
for (let i = 15; i < 200; i++) {
|
||||
sum += stepMs(i);
|
||||
expect(clockMs(i, 15)).toBe(sum);
|
||||
}
|
||||
});
|
||||
|
||||
test('the seam frame lands exactly one cycle after the window start for any PRE and cycle', () => {
|
||||
for (const cycle of [4, 6, 12, 12.5, 15]) {
|
||||
for (let pre = 2; pre <= 30; pre++) {
|
||||
const plan = planCapture({ cycleSeconds: cycle, pre });
|
||||
expect(clockMs(plan.windowStart, pre)).toBe(0);
|
||||
expect(clockMs(plan.windowStart + plan.windowFrames, pre)).toBe(cycle * 1000);
|
||||
expect(plan.frames).toBeGreaterThan(plan.windowStart + plan.windowFrames);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('a default 12 s plan records PRE, one cycle from PRE - 1, and 10 frames past it', () => {
|
||||
expect(planCapture({ cycleSeconds: 12 })).toEqual({ pre: 15, windowStart: 14, windowFrames: 720, tail: 10, frames: 744 });
|
||||
});
|
||||
|
||||
test('the scale puts the long side on 1920x1200', () => {
|
||||
expect(captureScale(1440, 990)).toBeCloseTo(1200 / 990, 10);
|
||||
expect(Math.floor(1440 * captureScale(1440, 990))).toBe(1745);
|
||||
expect(captureScale(1920, 1080)).toBe(1);
|
||||
expect(captureScale(600, 400)).toBe(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('capture arguments', () => {
|
||||
test('a capture and a still parse', () => {
|
||||
expect(parseCaptureArgs(['page.html', '--size', '1440x990', '--cycle', '12', '--out', 'cap', '--mask', '.card'])).toEqual({
|
||||
target: 'page.html', width: 1440, height: 990, out: 'cap', still: undefined, cycle: 12, scale: undefined, pre: 15, tail: 10, mask: '.card',
|
||||
} satisfies CaptureOptions);
|
||||
const still = parseCaptureArgs(['https://example.com/a', '--size', '640x400', '--still', 'ref.png', '--scale', '2']) as CaptureOptions;
|
||||
expect([still.still, still.scale, still.out]).toEqual(['ref.png', 2, undefined]);
|
||||
});
|
||||
|
||||
test('each bad invocation names its problem', () => {
|
||||
const err = (argv: string[]) => (parseCaptureArgs(argv) as { error: string }).error;
|
||||
expect(err(['--size', '10x10'])).toContain('name the page');
|
||||
expect(err(['p.html', '--cycle', '12', '--out', 'c'])).toContain('--size');
|
||||
expect(err(['p.html', '--size', '640x400', '--out', 'c'])).toContain('--cycle');
|
||||
expect(err(['p.html', '--size', '640x400', '--cycle', '4'])).toContain('--out');
|
||||
expect(err(['p.html', '--size', '640x400', '--cycle', '4', '--out', 'c', '--still', 's.png'])).toContain('not both');
|
||||
expect(err(['p.html', '--size', '640x400', '--cycle', '4', '--out', 'c', '--pre', '1'])).toContain('--pre');
|
||||
expect(err(['p.html', '--size', '640x400', '--cycle', 'abc', '--out', 'c'])).toContain('positive number');
|
||||
expect(err(['p.html', '--size', '640x400', '--still', 's.jpg'])).toContain('.png');
|
||||
expect(err(['p.html', '--size', '640x400', '--still', 's.png', '--mask', '.card'])).toContain('--mask');
|
||||
expect(err(['p.html', '--size', '640x400', '--cycle', '4', '--out', 'c', '--scale', '2'])).toContain('--scale');
|
||||
expect(err(['p.html', '--size', '640x400', '--fps', '30'])).toContain("unknown option '--fps'");
|
||||
expect(err(['p.html', 'q.html', '--size', '640x400'])).toContain("unexpected argument 'q.html'");
|
||||
expect(err(['p.html', '--size'])).toContain('needs a value');
|
||||
});
|
||||
|
||||
test('modes keep the existing query and fragment', () => {
|
||||
expect(withMode('file:///tmp/page.html', 'capture')).toBe('file:///tmp/page.html?capture');
|
||||
expect(withMode('https://x.dev/y?a=1#top', 'still')).toBe('https://x.dev/y?a=1&still#top');
|
||||
});
|
||||
|
||||
test('the mask paints only the matched containers white', () => {
|
||||
const css = maskCss('.card, .panel');
|
||||
expect(css).toContain('* { visibility: hidden !important;');
|
||||
expect(css).toContain('.card, .panel { visibility: visible !important; background: #fff !important;');
|
||||
expect(css).toContain('box-shadow: none !important');
|
||||
});
|
||||
});
|
||||
|
||||
describe('gstack-motion-capture CLI', () => {
|
||||
test('a usage error exits 2 before any browser starts', () => {
|
||||
const r = Bun.spawnSync([BIN, 'page.html', '--size', '640x400'], { stdout: 'pipe', stderr: 'pipe', timeout: 30_000 });
|
||||
expect(r.exitCode).toBe(2);
|
||||
expect(r.stderr.toString()).toContain('--out <dir> is required');
|
||||
expect(r.stderr.toString()).toContain('Usage:');
|
||||
});
|
||||
|
||||
test('a missing page file exits 2', () => {
|
||||
const r = Bun.spawnSync([BIN, path.join(ROOT, 'no-such-page.html'), '--size', '640x400', '--still', '/tmp/x.png'], { stdout: 'pipe', stderr: 'pipe', timeout: 30_000 });
|
||||
expect(r.exitCode).toBe(2);
|
||||
expect(r.stderr.toString()).toContain('does not exist');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,179 @@
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import { clockMs, planCapture } from '../lib/motion-capture';
|
||||
import {
|
||||
compareArgs, contactSheetArgs, cropError, judgeCheck, loopGifArgs, mp4Args, parsePsnrStats, planChecks, psnrArgs,
|
||||
resolveFfmpeg, smallGifArgs, FFMPEG_MISSING, type CaptureManifest, type CheckJob, type CheckOptions,
|
||||
} from '../lib/motion-encode';
|
||||
|
||||
const ROOT = path.resolve(import.meta.dir, '..');
|
||||
const BIN = path.join(ROOT, 'bin', 'gstack-motion-encode');
|
||||
const QUIET = ['-hide_banner', '-loglevel', 'error', '-nostdin', '-y'];
|
||||
|
||||
function manifest(cycle = 12, mask = true): CaptureManifest {
|
||||
const plan = planCapture({ cycleSeconds: cycle });
|
||||
return {
|
||||
schema: 1, target: 'page.html', width: 1440, height: 990, scale: 1200 / 990, fps: 60, cycle,
|
||||
pre: plan.pre, windowStart: plan.windowStart, windowFrames: plan.windowFrames, frames: plan.frames,
|
||||
clockMs: Array.from({ length: plan.frames }, (_, i) => clockMs(i, plan.pre)),
|
||||
loopTime: [], still: 'still.png', ...(mask ? { mask: 'mask.png' } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
const OPTS: CheckOptions = { dissolveAt: 11, emptyFrom: 11.6, introEnd: 2.4, layout: 'cards', maskGrow: 2 };
|
||||
|
||||
describe('export recipes', () => {
|
||||
const m = manifest();
|
||||
|
||||
test('MP4 for X: H.264 yuv420p, 60 fps, CRF 15, preset slow, faststart, even crop, one cycle from the window start', () => {
|
||||
expect(mp4Args(m, '/c', '/c/n-x.mp4')).toEqual([...QUIET,
|
||||
'-start_number', '14', '-framerate', '60', '-i', '/c/frames/%05d.png', '-frames:v', '720',
|
||||
'-vf', 'crop=trunc(iw/2)*2:trunc(ih/2)*2', '-c:v', 'libx264', '-preset', 'slow', '-crf', '15',
|
||||
'-pix_fmt', 'yuv420p', '-movflags', '+faststart', '/c/n-x.mp4']);
|
||||
});
|
||||
|
||||
test('loop GIF: trim to the cycle, 20 fps, 960 wide lanczos, 192-colour diff palette, bayer 4, loop forever', () => {
|
||||
const args = loopGifArgs(m, '/c', '/c/n-loop.gif');
|
||||
expect(args.slice(args.indexOf('-filter_complex') + 1)).toEqual([
|
||||
'trim=end_frame=720,fps=20,scale=960:-2:flags=lanczos,split[a][b];[a]palettegen=max_colors=192:stats_mode=diff[p];[b][p]paletteuse=dither=bayer:bayer_scale=4:diff_mode=rectangle',
|
||||
'-loop', '0', '/c/n-loop.gif']);
|
||||
});
|
||||
|
||||
test('800x500 GIF: optional content crop, fit, pad with the page background', () => {
|
||||
const args = smallGifArgs(m, '/c', '/c/n.gif', { crop: '1600:1000:72:100', pad: '#f4f1ea', fps: 12 });
|
||||
const filter = args[args.indexOf('-filter_complex') + 1]!;
|
||||
expect(filter.startsWith('trim=end_frame=720,fps=12,crop=1600:1000:72:100,scale=800:500:force_original_aspect_ratio=decrease:flags=lanczos,pad=800:500:(ow-iw)/2:(oh-ih)/2:color=0xf4f1ea,split[a][b];')).toBe(true);
|
||||
expect(smallGifArgs(m, '/c', '/c/n.gif').join(' ')).toContain('fps=20,scale=800:500');
|
||||
});
|
||||
|
||||
test('a crop must be 1.6:1', () => {
|
||||
expect(cropError('1600:1000:0:0')).toBeNull();
|
||||
expect(cropError('801:500:0:0')).toBeNull();
|
||||
expect(cropError('1000:1000:0:0')).toContain('width 1600');
|
||||
expect(cropError('1600x1000')).toContain('w:h:x:y');
|
||||
});
|
||||
|
||||
test('the contact sheet tiles twelve frames from the first to the last of the window', () => {
|
||||
const args = contactSheetArgs(m, '/c', '/c/sheet.png');
|
||||
const vf = args[args.indexOf('-vf') + 1]!;
|
||||
expect(vf).toContain(String.raw`eq(n\,0)+`);
|
||||
expect(vf).toContain(String.raw`eq(n\,719)'`);
|
||||
expect(vf).toContain('tile=4x3');
|
||||
});
|
||||
});
|
||||
|
||||
describe('check planning', () => {
|
||||
test('seam, empty beat, rest and overflow compare the right frames', () => {
|
||||
const m = manifest();
|
||||
const jobs = planChecks(m, '/c', OPTS) as CheckJob[];
|
||||
expect(jobs.map(j => j.id)).toEqual(['seam', 'empty-beat', 'rest', 'overflow']);
|
||||
const [seam, empty, rest, overflow] = jobs;
|
||||
expect(seam!.what).toBe('frame 14 vs 734');
|
||||
expect(seam!.args).toContain('/c/frames/00014.png');
|
||||
expect(seam!.args).toContain('/c/frames/00734.png');
|
||||
// Empty beat: clock in [11.6 s, 12 s) inside the window, compared with the pre-start frame.
|
||||
const emptyFrames = Array.from({ length: m.frames }, (_, i) => i)
|
||||
.filter(i => i > 14 && i < 734 && m.clockMs[i]! >= 11_600);
|
||||
expect(empty!.expected).toBe(emptyFrames.length);
|
||||
expect(empty!.what).toBe(`frames ${emptyFrames[0]}-733 vs 14`);
|
||||
expect(empty!.args.slice(empty!.args.indexOf('-start_number'), empty!.args.indexOf('-start_number') + 2)).toEqual(['-start_number', String(emptyFrames[0])]);
|
||||
// Rest: the last frame whose clock is still before the dissolve.
|
||||
const restFrame = Math.max(...Array.from({ length: 734 }, (_, i) => i).filter(i => i > 14 && m.clockMs[i]! < 11_000));
|
||||
expect(rest!.what).toBe(`frame ${restFrame} vs still.png`);
|
||||
expect(m.clockMs[restFrame + 1]).toBeGreaterThanOrEqual(11_000);
|
||||
// Cards overflow: story frames (intro landed .. dissolve) against the still, through the mask.
|
||||
expect(overflow!.what).toContain('story frames');
|
||||
expect(overflow!.args.join(' ')).toContain('/c/mask.png');
|
||||
expect(overflow!.args.join(' ')).toContain('/c/still.png');
|
||||
});
|
||||
|
||||
test('an app frame compares every window frame with the empty first frame', () => {
|
||||
const jobs = planChecks(manifest(), '/c', { ...OPTS, layout: 'app' }) as CheckJob[];
|
||||
const overflow = jobs.find(j => j.id === 'overflow')!;
|
||||
expect(overflow.expected).toBe(720);
|
||||
expect(overflow.what).toBe('every window frame vs 14, outside the mask');
|
||||
});
|
||||
|
||||
test('no mask, no overflow job; bad phases and a short tail are refused', () => {
|
||||
expect((planChecks(manifest(12, false), '/c', OPTS) as CheckJob[]).map(j => j.id)).toEqual(['seam', 'empty-beat', 'rest']);
|
||||
expect((planChecks(manifest(), '/c', { ...OPTS, dissolveAt: 12.5 }) as { error: string }).error).toContain('intro-end < dissolve-at');
|
||||
const short = { ...manifest(), frames: 734 };
|
||||
expect((planChecks(short, '/c', OPTS) as { error: string }).error).toContain('--tail');
|
||||
});
|
||||
|
||||
test('the mask is grown by one dilation per pixel and blacks out the containers on both sides', () => {
|
||||
const args = psnrArgs({ first: '/c/frames/%05d.png', start: 20, count: 5, reference: '/c/still.png', mask: '/c/mask.png', maskGrow: 3 });
|
||||
const graph = args[args.indexOf('-filter_complex') + 1]!;
|
||||
expect(graph).toContain('format=gray,dilation,dilation,dilation,format=gbrp,split[m1][m2]');
|
||||
expect(graph).toContain("[f][m1]blend=all_expr='if(gt(B,127),0,A)'[fa]");
|
||||
expect(graph).toContain('[fa][ra]psnr=stats_file=-');
|
||||
expect(graph).toContain('trim=end_frame=5');
|
||||
});
|
||||
|
||||
test('compare crops and blurs both sides the same way', () => {
|
||||
const args = compareArgs('a.png', 'b.png', { blur: 1.2, crop: '100:100:10:10' });
|
||||
expect(args[args.indexOf('-filter_complex') + 1]).toBe('[0:v]format=gbrp,crop=100:100:10:10,gblur=sigma=1.2[a];[1:v]format=gbrp,crop=100:100:10:10,gblur=sigma=1.2[b];[a][b]psnr=stats_file=-');
|
||||
});
|
||||
});
|
||||
|
||||
describe('PSNR parsing and verdicts', () => {
|
||||
const STATS = [
|
||||
'n:1 mse_avg:0.00 mse_r:0.00 mse_g:0.00 mse_b:0.00 psnr_avg:inf psnr_r:inf psnr_g:inf psnr_b:inf',
|
||||
'n:2 mse_avg:1.53 mse_r:1.40 mse_g:1.60 mse_b:1.59 psnr_avg:46.28 psnr_r:46.67 psnr_g:46.09 psnr_b:46.12',
|
||||
'garbage line',
|
||||
'n:3 mse_avg:0.00 mse_r:0.00 mse_g:0.00 mse_b:0.00 psnr_avg:inf psnr_r:inf psnr_g:inf psnr_b:inf',
|
||||
].join('\n');
|
||||
const job: CheckJob = { id: 'empty-beat', what: 'frames 711-733 vs 14', args: [], expected: 3 };
|
||||
|
||||
test('inf becomes Infinity and junk lines are skipped', () => {
|
||||
expect(parsePsnrStats(STATS)).toEqual([{ n: 1, psnr: Infinity }, { n: 2, psnr: 46.28 }, { n: 3, psnr: Infinity }]);
|
||||
expect(parsePsnrStats('')).toEqual([]);
|
||||
});
|
||||
|
||||
test('identical frames pass; one differing frame fails with its worst value', () => {
|
||||
const allInf = parsePsnrStats(STATS.replace('psnr_avg:46.28', 'psnr_avg:inf'));
|
||||
expect(judgeCheck(job, allInf)).toEqual({ id: 'empty-beat', pass: true, line: 'MOTION_CHECK: empty-beat pass (frames 711-733 vs 14)' });
|
||||
const v = judgeCheck(job, parsePsnrStats(STATS));
|
||||
expect(v.pass).toBe(false);
|
||||
expect(v.line).toBe('MOTION_CHECK: empty-beat fail 1 frame(s) differ, worst 46.28 dB at compared frame 2 (frames 711-733 vs 14)');
|
||||
expect(judgeCheck(job, parsePsnrStats(STATS), 45).pass).toBe(true);
|
||||
});
|
||||
|
||||
test('fewer compared frames than planned is a failure, never a pass', () => {
|
||||
const v = judgeCheck({ ...job, expected: 23 }, parsePsnrStats(STATS.replace('psnr_avg:46.28', 'psnr_avg:inf')));
|
||||
expect(v.pass).toBe(false);
|
||||
expect(v.line).toContain('compared 3 of 23 frames');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ffmpeg is optional and named when missing', () => {
|
||||
test('resolution prefers GSTACK_FFMPEG, refuses a missing override, else uses PATH', () => {
|
||||
const which = (b: string) => (b === 'ffmpeg' ? '/usr/bin/ffmpeg' : null);
|
||||
expect(resolveFfmpeg({ GSTACK_FFMPEG: '/opt/ff' }, which, p => p === '/opt/ff')).toBe('/opt/ff');
|
||||
expect(resolveFfmpeg({ GSTACK_FFMPEG: '/opt/ff' }, which, () => false)).toBeNull();
|
||||
expect(resolveFfmpeg({}, which, () => true)).toBe('/usr/bin/ffmpeg');
|
||||
expect(resolveFfmpeg({}, () => null, () => true)).toBeNull();
|
||||
});
|
||||
|
||||
test('the CLI prints FFMPEG_MISSING with install hints and exits 3', () => {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'motion-encode-'));
|
||||
try {
|
||||
const r = Bun.spawnSync([BIN, 'check', dir], { stdout: 'pipe', stderr: 'pipe', timeout: 30_000, env: { ...process.env, GSTACK_FFMPEG: path.join(dir, 'no-ffmpeg') } });
|
||||
expect(r.exitCode).toBe(3);
|
||||
expect(r.stdout.toString().trim()).toBe(FFMPEG_MISSING);
|
||||
expect(FFMPEG_MISSING).toContain('brew install ffmpeg');
|
||||
expect(FFMPEG_MISSING).toContain('apt-get install -y ffmpeg');
|
||||
expect(FFMPEG_MISSING).toContain('winget install');
|
||||
} finally {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('a usage error exits 2 without touching ffmpeg', () => {
|
||||
const r = Bun.spawnSync([BIN, 'encode'], { stdout: 'pipe', stderr: 'pipe', timeout: 30_000, env: { ...process.env, GSTACK_FFMPEG: '/nonexistent/ffmpeg' } });
|
||||
expect(r.exitCode).toBe(2);
|
||||
expect(r.stderr.toString()).toContain('Usage: gstack-motion-encode check');
|
||||
});
|
||||
});
|
||||
@@ -1342,3 +1342,87 @@ Write ${workDir}/gate-output.md listing what you fixed and every remaining findi
|
||||
expect(out).toContain('accepted');
|
||||
}, CAPTURE_MS);
|
||||
});
|
||||
|
||||
describeIfSelected('Design motion showcase E2E', ['design-motion-showcase'], () => {
|
||||
let workDir: string;
|
||||
let gstackHome: string;
|
||||
|
||||
beforeAll(() => {
|
||||
workDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-motion-'));
|
||||
gstackHome = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-motion-home-'));
|
||||
const run = (cmd: string, args: string[]) => spawnSync(cmd, args, { cwd: workDir, stdio: 'pipe', timeout: 5000 });
|
||||
run('git', ['init', '-b', 'main']);
|
||||
run('git', ['config', 'user.email', 'test@test.com']);
|
||||
run('git', ['config', 'user.name', 'Test']);
|
||||
fs.copyFileSync(path.join(ROOT, 'test', 'fixtures', 'design-motion-finalized.html'), path.join(workDir, 'finalized.html'));
|
||||
run('git', ['add', '.']);
|
||||
run('git', ['commit', '-m', 'finalized page']);
|
||||
const full = fs.readFileSync(path.join(ROOT, 'design-motion', 'SKILL.md'), 'utf-8');
|
||||
const text = full.slice(full.indexOf('# /design-motion:'))
|
||||
.replaceAll('$HOME/.claude/skills/gstack', ROOT).replaceAll('~/.claude/skills/gstack', ROOT);
|
||||
fs.writeFileSync(path.join(workDir, 'design-motion.md'), text);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
for (const d of [workDir, gstackHome]) { try { fs.rmSync(d, { recursive: true, force: true }); } catch {} }
|
||||
});
|
||||
|
||||
testConcurrentIfSelected('design-motion-showcase', async () => {
|
||||
const result = await runSkillTest({
|
||||
prompt: `Read design-motion.md: the /design-motion skill. Run it on finalized.html in this directory, the user's /design-html page, as the source.
|
||||
Settled answers, so do not use AskUserQuestion: showcase context; separate cards (the two .card sections); stories: the bars breathe and settle on the design heights, a soft highlight steps down the invoice rows; no camera; a 6 second cycle instead of 12 (scale the phases to it); name "ledgerline"; the frame is 640x400.
|
||||
Read each section the skill points to before its step. Build page.html with the capture contract, verify the still, capture with a mask on the cards, run the motion checks, fix and recheck until they pass, then export. Do not open a browser window and do not install anything.
|
||||
Finally write ${workDir}/motion-report.md with every MOTION_CHECK line, the MOTION_RESULT line, and each EXPORT_OK line exactly as printed.`,
|
||||
workingDirectory: workDir,
|
||||
maxTurns: 60,
|
||||
timeout: CAPTURE_LONG_MS,
|
||||
testName: 'design-motion-showcase',
|
||||
runId,
|
||||
env: { GSTACK_HOME: gstackHome },
|
||||
});
|
||||
|
||||
logCost('/design-motion showcase', result);
|
||||
recordE2E(evalCollector, '/design-motion showcase', 'Design motion showcase E2E', result);
|
||||
expect(result.exitReason).toBe('success');
|
||||
const sectionRead = (name: string) => {
|
||||
if (result.toolCalls.some(c => c.tool === 'Read' && String(c.input?.file_path ?? '').endsWith(`/design-motion/sections/${name}`))) return true;
|
||||
const printed = result.toolCalls
|
||||
.filter(c => c.tool === 'Bash' && String(c.input?.command ?? '').includes(`design-motion/sections/${name}`))
|
||||
.map(c => String(c.output ?? '')).join('\n');
|
||||
const lines = fs.readFileSync(path.join(ROOT, 'design-motion', 'sections', name), 'utf-8').split('\n').map(l => l.trimEnd()).filter(Boolean);
|
||||
return lines.every(line => printed.includes(line));
|
||||
};
|
||||
expect(sectionRead('fidelity.md')).toBe(true);
|
||||
expect(sectionRead('motion.md')).toBe(true);
|
||||
const commands = result.toolCalls.filter(c => c.tool === 'Bash').map(c => String(c.input?.command ?? '')).join('\n');
|
||||
const after = (re: RegExp, from: number) => { const i = commands.slice(from).search(re); return i < 0 ? -1 : from + i; };
|
||||
const capture = after(/gstack-motion-capture\.ts\b[^\n]*--out\b/, 0);
|
||||
expect(capture).toBeGreaterThanOrEqual(0);
|
||||
const check = after(/gstack-motion-encode['"]?\s+check\b/, capture);
|
||||
expect(check).toBeGreaterThan(capture);
|
||||
expect(after(/gstack-motion-encode['"]?\s+export\b/, check)).toBeGreaterThan(check);
|
||||
|
||||
const designs = path.join(gstackHome, 'projects');
|
||||
const motionDirs = fs.existsSync(designs)
|
||||
? fs.readdirSync(designs).flatMap(slug => {
|
||||
const d = path.join(designs, slug, 'designs');
|
||||
return fs.existsSync(d) ? fs.readdirSync(d).filter(n => n.includes('-motion-')).map(n => path.join(d, n)) : [];
|
||||
})
|
||||
: [];
|
||||
expect(motionDirs.length).toBe(1);
|
||||
const page = fs.readFileSync(path.join(motionDirs[0]!, 'page.html'), 'utf-8');
|
||||
expect(page).toContain('__start');
|
||||
expect(page).toContain('__tick');
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(motionDirs[0]!, 'cap', 'capture.json'), 'utf-8'));
|
||||
expect(manifest.windowFrames).toBe(360);
|
||||
expect(manifest.mask).toBe('mask.png');
|
||||
|
||||
const report = fs.readFileSync(path.join(workDir, 'motion-report.md'), 'utf-8');
|
||||
for (const id of ['seam', 'empty-beat', 'rest', 'overflow']) expect(report).toContain(`MOTION_CHECK: ${id} pass`);
|
||||
expect(report).toContain('MOTION_RESULT: clean');
|
||||
for (const file of ['ledgerline-x.mp4', 'ledgerline-loop.gif', 'ledgerline-800x500.gif']) {
|
||||
expect(report).toContain(file);
|
||||
expect(fs.statSync(path.join(motionDirs[0]!, 'cap', file)).size).toBeGreaterThan(10_000);
|
||||
}
|
||||
}, CAPTURE_LONG_MS);
|
||||
});
|
||||
Reference in new issue
Block a user