Skip to content

majiayu000/spellbook / skills/repo-film

repo-film

Verified

把一个 git 仓库在一段时间里的真实提交做成 15–25 秒的炫酷短片:主线和各条分支按真实分叉、合并同时生长成流程图,越长越快再拉远看全景;仓库有 you-are-here 项目地图时,整张网会收拢成地图里的阻塞链,再沿地图讲卡点、当前位置和一句话总结,最后接可改的结尾卡片。一行命令出 MP4,基于 motion-stack 渲染器。当用户说「把这个仓库这周 / 昨晚做的事做成视频」「做个项目进展短片」「git 记录做成流程图动画」「给 you-are-here / 某项目做宣传视频」「像上次 Keepline 那个视频一样做一个」时使用。只在明确请求时触发,忽略顺带提及。

FileKindSize
SKILL.mdskill md5.6 KB
scripts/capture.mjsscript2.8 KB
scripts/lanes.pyscript5.0 KB
scripts/make.mjsscript6.8 KB
template/package.jsonmanifest224 B
template/scene.htmlother27.0 KB

scripts/make.mjs

View on GitHub
#!/usr/bin/env node
// repo-film: one command from a repo + time window to a finished MP4.
// usage: node make.mjs --repo <path> --since "2026-11-01 20:00" --until "2026-11-02 06:00"
//          [--out <dir>] [--branch main] [--map auto|none|<index.html>] [--config film.json] [--sheet-only]
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import { execFileSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';

const HERE = path.dirname(fileURLToPath(import.meta.url));
const SKILL = path.dirname(HERE);
// the motion-stack kit: $MOTION_KIT, else a sibling skill (same install), else the usual runtime folders
const KIT = [process.env.MOTION_KIT, path.join(SKILL, '..', 'motion-stack', 'kit'),
  ...['.claude/skills', '.codex/skills', '.agents/skills'].map(d => path.join(os.homedir(), d, 'motion-stack', 'kit'))]
  .find(k => k && fs.existsSync(path.join(k, 'render.mjs'))) || '';
const args = Object.fromEntries(process.argv.slice(2).reduce((a, x, i, all) => {
  if (x.startsWith('--')) a.push([x.slice(2), all[i + 1] && !all[i + 1].startsWith('--') ? all[i + 1] : true]); return a; }, []));
const die = m => { console.error('repo-film: ' + m); process.exit(1); };
if (!args.repo || !args.since || !args.until) die('need --repo, --since and --until');
if (!KIT) die('motion-stack kit not found: install the motion-stack skill next to this one, or set MOTION_KIT');
const repo = path.resolve(args.repo);
const name = path.basename(repo);
const out = path.resolve(args.out || path.join(os.homedir(), 'Videos/repo-film', `${name}-${String(args.since).slice(0, 10)}`));
if (!fs.existsSync(path.join(KIT, 'node_modules/playwright'))) die(`motion-stack kit is not set up: cd ${KIT} && PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install`);
const run = (cmd, a, opt = {}) => execFileSync(cmd, a, { stdio: ['ignore', 'pipe', 'inherit'], ...opt }).toString();

// 1. project folder from the template
const manifest = path.join(out, 'package.json');
if (fs.existsSync(out) && fs.readdirSync(out).length > 0) {
  let project;
  try { project = JSON.parse(fs.readFileSync(manifest, 'utf8')); }
  catch { die(`choose an empty output directory or one with a readable repo-film package.json: ${out}`); }
  if (project?.name !== 'repo-film') die(`choose an empty output directory: ${out}`);
}
const modules = path.join(out, 'node_modules');
const hadModules = fs.lstatSync(modules, { throwIfNoEntry: false });
const hasTone = fs.existsSync(path.join(modules, 'tone'));
if (hadModules && !hasTone) die(`existing dependencies lack Tone.js: install it in ${out} or choose a new output directory`);
fs.mkdirSync(path.join(out, 'assets'), { recursive: true });
fs.mkdirSync(path.join(out, 'out'), { recursive: true });
let backup;
for (const name of ['scene.html', 'package.json']) {
  const source = path.join(SKILL, 'template', name);
  const target = path.join(out, name);
  if (fs.lstatSync(target, { throwIfNoEntry: false })) {
    if (fs.readFileSync(source).equals(fs.readFileSync(target))) continue;
    backup ??= fs.mkdtempSync(path.join(out, 'template-backup-'));
    fs.renameSync(target, path.join(backup, name));
  }
  fs.copyFileSync(source, target, fs.constants.COPYFILE_EXCL);
}
if (backup) console.log(`previous templates → ${backup}`);
if (!hasTone) {
  const shared = path.join(KIT, '..', 'examples/drop/node_modules');
  if (fs.existsSync(path.join(shared, 'tone'))) fs.symlinkSync(shared, modules);
  else run('npm', ['install', '--silent', '--no-audit', '--no-fund'], { cwd: out });
}
fs.mkdirSync(path.join(out, 'fonts'), { recursive: true });
for (const [src, dst] of [['/System/Library/Fonts/SFNSMono.ttf', 'SFNSMono.ttf'], ['/System/Library/Fonts/SFNS.ttf', 'SFNS.ttf']])
  if (fs.existsSync(src) && !fs.existsSync(path.join(out, 'fonts', dst))) fs.copyFileSync(src, path.join(out, 'fonts', dst));

// 2. git lanes
const lanesArgs = [path.join(HERE, 'lanes.py'), repo, '--since', args.since, '--until', args.until];
if (args.branch) lanesArgs.push('--branch', args.branch);
const nightJson = run('python3', lanesArgs);
fs.writeFileSync(path.join(out, 'assets/night.json'), nightJson);
const night = JSON.parse(nightJson);
const N = night.commits.length, B = night.segments.length;

// 3. the you-are-here map, if there is one
let mapFile = null;
if (args.map !== 'none') {
  const cands = args.map && args.map !== 'auto' ? [path.resolve(args.map)]
    : ['index.public.html', 'index.html'].map(f => path.join(repo, '.project-map', f));
  mapFile = cands.find(f => fs.existsSync(f)) || null;
}
if (mapFile) {
  const html = fs.readFileSync(mapFile, 'utf8');
  if (/\/Users\/|\/home\/|[A-Z]:\\\\Users/.test(html)) console.warn(`repo-film: warning: ${mapFile} contains local paths; they will be visible in the film`);
  run('node', [path.join(HERE, 'capture.mjs'), mapFile, path.join(out, 'assets')], { env: { ...process.env, MOTION_KIT: KIT } });
}

// 4. words: defaults from the data, overridden by --config
const def = {
  hasMap: !!mapFile,
  sub: `${night.repo.toUpperCase()} · ${night.from} → ${night.to}`,
  startLabel: `${night.commits[0].t.slice(-5)} 开工`,
  captions: [
    ['你离开了。', 'You step away.'],
    ['agent 们接着干。', 'The agents keep going.'],
    B ? [`${N} 个提交,${B} 条分支。`, `${N} commits. ${B} branches.`] : [`${N} 个提交。`, `${N} commits.`],
    ...(mapFile ? [['回来,打开一页。', 'Come back. Open one page.']] : []),
  ],
  end: { title: night.repo, tagline: `${night.from} → ${night.to}`, taglineEn: `${N} commits · ${B} branches · ${night.merges} merges`, lines: [], meta: '' },
};
const cfg = args.config ? JSON.parse(fs.readFileSync(path.resolve(args.config), 'utf8')) : {};
const film = { ...def, ...cfg, end: { ...def.end, ...(cfg.end || {}) }, hasMap: def.hasMap };
fs.writeFileSync(path.join(out, 'assets/film.js'), 'window.FILM = ' + JSON.stringify(film, null, 1) + ';\n');

// 5. render: beat sheet first, then the purity check, then the film
const render = a => run('node', [path.join(KIT, 'render.mjs'), 'scene.html', ...a], { cwd: out, stdio: ['ignore', 'pipe', 'inherit'] });
const dur = mapFile ? 24 : 13.4;
const beats = mapFile ? [0.6, 2.5, 4.5, 6.5, 8.0, 10.2, 12.0, 14.0, 16.5, 18.8, 22.0] : [0.6, 2.5, 4.5, 6.5, 8.0, 9.0, 11.5];
render(['--sheet', beats.join(','), '--out', 'out/beats.png']);
console.log(`beats  → ${path.join(out, 'out/beats.png')}`);
if (!args['sheet-only']) {
  render(['--pure']);
  const final = path.join(out, 'out', `${night.repo}-film.mp4`);
  render(['--out', final]);                      // the kit brings the sound to -14 LUFS itself
  const m = JSON.parse(fs.readFileSync(final + '.manifest.json', 'utf8'));
  if (m.scene_errors?.length || m.remote_requests?.length) console.warn('repo-film: manifest has errors or remote requests:', m.scene_errors, m.remote_requests);
  console.log(`film   → ${final}  (${dur}s, ${N} commits, ${B} branches${mapFile ? ', with map' : ''})`);
}
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 323kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 323kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 323kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 323kUpdated Claude CodeCodexVerifiedInstall