Skip to content

joeseesun/qiaomu-cut-skill

qiaomu-cut

Verified

把一句话需求转成可复现、可验收视频工程的乔木智能剪辑导演。Use when the user asks to create, plan, edit, remix, explain, narrate, subtitle, animate, composite, or render a video—including one-line requests such as “制作一个科普视频:介绍 LLM 中的 RL”. Builds English-learning movie mixes, person profiles, explainers, code-drawn motion graphics (UI morph loops, showreels, kinetic-type promos, line-art/pixel/Three.js animation, lyric MVs), product launch videos, cinematic shorts, social clips, course/PPT videos, AI image/video/TTS/music-assisted stories, stock-footage stories, or multi-source montage. Routes across 33台词, ClipSeek/open media, local files, ListenHub, image generation, HTML/SVG/Canvas motion graphics with beat-grid storyboards and determinism probes, Manim, ffmpeg-full, captions, sound design, frame-0 video covers with YouTube thumbnails, and release checks.

FileKindSize
SKILL.mdskill md54.0 KB
agents/interface.yamlconfig17.2 KB
agents/openai.yamlconfig323 B
assets/explainer-social/base.cssother24.9 KB
assets/explainer-social/component-runtime.jsscript41.1 KB
assets/explainer-social/scene-shell.htmlother829 B
assets/motion-kit/qiaocut-motion.jsscript8.2 KB
assets/qiaomu-profile/qiaomu_avatar.jpegbinary5.6 MB
assets/qiaomu-profile/qiaomu_reward_qr.pngbinary515.9 KB
assets/qiaomu-profile/qiaomu_wechat_public_account_qr.jpgbinary8.3 KB
references/ad-concept-library.mdmarkdown6.5 KB
references/aesthetic-preferences.mdmarkdown3.0 KB
references/brand-card-templates.mdmarkdown1.6 KB
references/chinese-font-themes.mdmarkdown804 B
references/cinematic-techniques.mdmarkdown2.8 KB
references/code-motion-direction.mdmarkdown11.1 KB
references/cover-thumbnail-method.mdmarkdown6.4 KB
references/english-mix-fast-path.mdmarkdown6.0 KB
references/explainer-autopilot.mdmarkdown11.1 KB
references/feedback-evolution.mdmarkdown37.6 KB
references/ffmpeg-full.mdmarkdown1.7 KB
references/incremental-production.mdmarkdown4.4 KB
references/licensing.mdmarkdown1.9 KB
references/listenhub-provider.mdmarkdown12.6 KB
references/motion-prompt-patterns.mdmarkdown9.3 KB
references/movie-montage-fast-path.mdmarkdown4.4 KB
references/qiaocut-ir.mdmarkdown4.2 KB
references/renderer-engines.mdmarkdown3.3 KB
references/schemas/qiaocut.timeline.v1.schema.jsonconfig7.2 KB
references/social-safe-zones.mdmarkdown3.3 KB
references/source-adapters.mdmarkdown5.7 KB
references/source-selection-gate.mdmarkdown2.5 KB
references/styles/cinematic.mdmarkdown475 B
references/styles/explainer.mdmarkdown1.5 KB
references/styles/social-short.mdmarkdown383 B
references/timeline-schema.mdmarkdown12.2 KB
references/trust-boundary.mdmarkdown3.0 KB
references/workflows.mdmarkdown7.5 KB
scripts/adapters/33tc.jsscript2.1 KB
scripts/adapters/33tc_cli.jsscript4.8 KB
scripts/adapters/clipseek.jsexecutablescript5.4 KB
scripts/adapters/listenhub.jsscript35.7 KB
scripts/adapters/listenhub_cli.jsexecutablescript2.1 KB
scripts/adapters/local.jsscript2.4 KB
scripts/audio_beats.jsscript17.5 KB
scripts/bilingual_typography_smoke.jsscript1.4 KB
scripts/bootstrap_listenhub.shexecutablescript5.4 KB
scripts/bootstrap_macos.shexecutablescript2.5 KB
scripts/brand_templates.jsscript2.4 KB
scripts/brand_templates_smoke.jsscript869 B
scripts/complete_sentence.jsscript3.9 KB
scripts/component_motion_smoke.jsscript21.2 KB
scripts/concept_smoke.jsscript5.6 KB
scripts/cover.jsscript9.1 KB
scripts/cover_smoke.jsscript5.1 KB
scripts/english_mix.jsscript24.1 KB
scripts/english_mix_smoke.jsscript5.7 KB
scripts/explainer_beats.jsscript6.7 KB
scripts/explainer_beats_smoke.jsscript4.8 KB
scripts/explainer_cognitive_timing_smoke.jsscript5.8 KB
scripts/explainer_e2e_smoke.jsscript7.4 KB
scripts/explainer_pipeline.jsscript49.3 KB
scripts/explainer_pipeline_smoke.jsscript12.7 KB
scripts/explainer_spec.jsscript51.4 KB
scripts/explainer_timing.jsscript8.6 KB
scripts/fetch_generated.jsexecutablescript17.4 KB
scripts/ffmpeg_retry_shim_smoke.jsscript2.3 KB
scripts/file_narration_smoke.jsexecutablescript6.6 KB
scripts/ingest_asset.jsexecutablescript15.0 KB
scripts/kinetic_caption_smoke.jsscript1.4 KB
scripts/license_report.jsexecutablescript2.3 KB
scripts/listenhub_narration.jsexecutablescript11.0 KB
scripts/listenhub_smoke.jsexecutablescript26.7 KB
scripts/local_preferences.jsscript1.8 KB
scripts/motion_studio.jsscript55.9 KB
scripts/motion_studio_smoke.jsscript11.0 KB
scripts/movie_montage.jsscript24.7 KB
scripts/movie_montage_smoke.jsscript4.0 KB
scripts/qcut.jsexecutablescript40.8 KB
scripts/release_check.jsscript7.0 KB
scripts/render_project.jsscript85.1 KB
scripts/render_scene.jsscript26.4 KB
scripts/renderers/ass.jsexecutablescript2.7 KB
scripts/renderers/bilingual_ass.jsscript12.6 KB
scripts/renderers/html_scene.jsexecutablescript3.9 KB
scripts/renderers/procedural_music.jsscript7.6 KB
scripts/scene_content_cache.jsscript3.2 KB
scripts/scene_renderer_smoke.jsscript2.8 KB
scripts/security_smoke.jsscript10.2 KB
scripts/sentence_boundary_smoke.jsscript1.6 KB
scripts/setup_deps.jsscript8.4 KB
scripts/shims/ffmpegexecutablescript3.0 KB
scripts/source_review.jsexecutablescript5.1 KB
scripts/timeline_features_smoke.jsscript3.7 KB
scripts/trigger_eval.pyexecutablescript2.5 KB
scripts/validate_skill.pyexecutablescript3.1 KB
scripts/verify_marswave_vendor.jsexecutablescript3.5 KB
scripts/verify_video.jsexecutablescript3.4 KB

scripts/ingest_asset.js

View on GitHub
#!/usr/bin/env node
'use strict';

const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const { ensureInternalDirectory, projectPath } = require('./render_project');

const MEDIA_KINDS = new Set(['image', 'video', 'audio', 'subtitle', 'document', 'other']);
const MAX_DEFAULT_BYTES = 2 * 1024 * 1024 * 1024;
const MANIFEST_LOCK = path.join('.qiaocut', 'locks', 'assets-manifest.lock');
const LOCK_TIMEOUT_MS = 5000;

function waitSync(milliseconds) {
  const signal = new Int32Array(new SharedArrayBuffer(4));
  Atomics.wait(signal, 0, 0, milliseconds);
}

function removeAbandonedLock(lockFile, stat) {
  let metadata = null;
  try { metadata = JSON.parse(fs.readFileSync(lockFile, 'utf8')); } catch (_) {}
  let ownerAlive = null;
  if (metadata && Number.isInteger(Number(metadata.pid)) && Number(metadata.pid) > 0) {
    try {
      process.kill(Number(metadata.pid), 0);
      ownerAlive = true;
    } catch (error) {
      ownerAlive = error.code !== 'ESRCH';
    }
  }
  const oldEnough = Date.now() - stat.mtimeMs > 10 * 60 * 1000;
  if (ownerAlive !== false && !(ownerAlive == null && oldEnough)) return false;
  try {
    const current = fs.lstatSync(lockFile);
    if (current.dev === stat.dev && current.ino === stat.ino) fs.unlinkSync(lockFile);
    return true;
  } catch (error) {
    return error.code === 'ENOENT';
  }
}

function acquireManifestLock(projectRoot) {
  const lockFile = projectPath(projectRoot, MANIFEST_LOCK, 'asset manifest lock');
  ensureInternalDirectory(projectRoot, path.dirname(lockFile), 'asset manifest lock directory');
  const deadline = Date.now() + LOCK_TIMEOUT_MS;
  while (Date.now() < deadline) {
    try {
      const descriptor = fs.openSync(lockFile, 'wx', 0o600);
      fs.writeFileSync(descriptor, `${JSON.stringify({ pid: process.pid, createdAt: new Date().toISOString() })}\n`);
      return { descriptor, lockFile };
    } catch (error) {
      if (error.code !== 'EEXIST') throw error;
      const stat = fs.lstatSync(lockFile);
      if (stat.isSymbolicLink() || !stat.isFile()) {
        throw new Error('Asset manifest lock must be a regular, non-symbolic-link file.');
      }
      if (removeAbandonedLock(lockFile, stat)) continue;
      waitSync(25);
    }
  }
  throw new Error('Timed out waiting for the asset manifest lock. Retry the import.');
}

function releaseManifestLock(lock) {
  try {
    const held = fs.fstatSync(lock.descriptor);
    const current = fs.lstatSync(lock.lockFile);
    if (held.dev === current.dev && held.ino === current.ino) fs.unlinkSync(lock.lockFile);
  } catch (_) {
    // Preserve the primary error; a later run will report a stale or busy lock.
  }
  try { fs.closeSync(lock.descriptor); } catch (_) {}
}

function hashFile(file) {
  const hash = crypto.createHash('sha256');
  const descriptor = fs.openSync(file, 'r');
  const buffer = Buffer.allocUnsafe(1024 * 1024);
  try {
    let bytes;
    do {
      bytes = fs.readSync(descriptor, buffer, 0, buffer.length, null);
      if (bytes) hash.update(buffer.subarray(0, bytes));
    } while (bytes);
  } finally {
    fs.closeSync(descriptor);
  }
  return hash.digest('hex');
}

function safeSlug(value, fallback) {
  const slug = String(value || '').toLowerCase().replace(/[^a-z0-9._-]+/g, '-').replace(/^-+|-+$/g, '');
  return slug || fallback;
}

function atomicJson(file, value, projectRoot) {
  ensureInternalDirectory(projectRoot, path.dirname(file), 'asset manifest directory');
  const temporary = path.join(path.dirname(file), `.${path.basename(file)}.${process.pid}.${Date.now()}.tmp`);
  try {
    fs.writeFileSync(temporary, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600, flag: 'wx' });
    fs.renameSync(temporary, file);
  } catch (error) {
    try { fs.rmSync(temporary, { force: true }); } catch (_) {}
    throw error;
  }
}

function readManifest(file) {
  if (!fs.existsSync(file)) return { assets: [] };
  const data = JSON.parse(fs.readFileSync(file, 'utf8'));
  if (!data || !Array.isArray(data.assets)) throw new Error('assets-manifest.json must contain { assets: [] }.');
  return data;
}

function normalizeMetadata(metadata = {}) {
  const kind = String(metadata.kind || metadata.mediaType || 'other').toLowerCase();
  if (!MEDIA_KINDS.has(kind)) throw new Error(`Unsupported asset kind: ${kind}`);
  const provider = safeSlug(metadata.provider || 'local', 'local');
  const credits = metadata.creditCharged == null || metadata.creditCharged === ''
    ? null
    : Number(metadata.creditCharged);
  if (credits != null && (!Number.isFinite(credits) || credits < 0)) throw new Error('creditCharged must be a non-negative number.');
  return {
    kind,
    provider,
    taskId: metadata.taskId ? String(metadata.taskId) : null,
    model: metadata.model ? String(metadata.model) : null,
    speakerId: metadata.speakerId ? String(metadata.speakerId) : null,
    speakerName: metadata.speakerName ? String(metadata.speakerName) : null,
    speakerCatalogSha256: metadata.speakerCatalogSha256 ? String(metadata.speakerCatalogSha256) : null,
    narrationTextSha256: metadata.narrationTextSha256 ? String(metadata.narrationTextSha256) : null,
    visualBibleId: metadata.visualBibleId ? String(metadata.visualBibleId) : null,
    prompt: metadata.prompt ? String(metadata.prompt) : null,
    seed: metadata.seed == null || metadata.seed === '' ? null : String(metadata.seed),
    creditCharged: credits,
    source: metadata.source ? String(metadata.source) : provider,
    attribution: metadata.attribution ? String(metadata.attribution) : `AI-generated with ${provider}`,
    termsStatus: metadata.termsStatus ? String(metadata.termsStatus) : 'provider_terms_unverified',
    capturePath: metadata.capturePath ? String(metadata.capturePath) : null,
    captureSha256: metadata.captureSha256 ? String(metadata.captureSha256) : null,
    resultField: metadata.resultField ? String(metadata.resultField) : null,
    creditStatus: metadata.creditStatus === 'reported' || credits != null ? 'reported' : 'unreported',
    aiGenerated: metadata.aiGenerated !== false
  };
}

function provenanceRecord(normalized) {
  return {
    taskId: normalized.taskId,
    model: normalized.model,
    speakerId: normalized.speakerId,
    speakerName: normalized.speakerName,
    speakerCatalogSha256: normalized.speakerCatalogSha256,
    narrationTextSha256: normalized.narrationTextSha256,
    visualBibleId: normalized.visualBibleId,
    prompt: normalized.prompt,
    seed: normalized.seed,
    creditCharged: normalized.creditCharged,
    creditStatus: normalized.creditStatus,
    capturePath: normalized.capturePath,
    captureSha256: normalized.captureSha256,
    resultField: normalized.resultField,
    termsStatus: normalized.termsStatus,
    importedAt: new Date().toISOString()
  };
}

function mergeProvenanceRuns(asset, current) {
  const runs = Array.isArray(asset.provenanceRuns)
    ? [...asset.provenanceRuns]
    : asset.provenance
      ? [asset.provenance]
      : [];
  const comparable = (value) => JSON.stringify({ ...value, importedAt: null });
  if (!runs.some((run) => comparable(run) === comparable(current))) runs.push(current);
  return runs;
}

function existingAssetIsUsable(projectRoot, asset, digest) {
  if (!asset || typeof asset.localPath !== 'string' || !asset.localPath.trim()) {
    throw new Error('Existing asset manifest record has no valid localPath.');
  }
  let file;
  try {
    file = projectPath(projectRoot, asset.localPath, 'existing generated asset');
  } catch (error) {
    if (/not found/i.test(error.message)) return false;
    throw error;
  }
  if (!fs.existsSync(file)) return false;
  const stat = fs.lstatSync(file);
  if (!stat.isFile() || stat.isSymbolicLink()) return false;
  return hashFile(file) === digest;
}

function registerExistingAsset(projectDirectory, assetFile, metadata = {}) {
  const projectRoot = fs.realpathSync(path.resolve(projectDirectory));
  const absolute = path.resolve(assetFile);
  const target = projectPath(projectRoot, path.relative(projectRoot, absolute), 'generated asset', { exists: true });
  const stat = fs.lstatSync(target);
  if (!stat.isFile() || stat.isSymbolicLink()) throw new Error('Generated asset must be a regular, non-symbolic-link file.');
  const normalized = normalizeMetadata(metadata);
  const digest = metadata.sha256 || hashFile(target);
  const relative = path.relative(projectRoot, target).split(path.sep).join('/');
  const manifestFile = projectPath(projectRoot, 'assets-manifest.json', 'asset manifest');
  const lock = acquireManifestLock(projectRoot);
  try {
    const manifest = readManifest(manifestFile);
    const existing = manifest.assets.find((asset) => (
      asset.sha256 === digest
      && asset.provider === normalized.provider
      && asset.mediaType === normalized.kind
    ));
    const currentProvenance = provenanceRecord(normalized);
    if (existing) {
      const provenanceRuns = mergeProvenanceRuns(existing, currentProvenance);
      if (existingAssetIsUsable(projectRoot, existing, digest)) {
        existing.provenanceRuns = provenanceRuns;
        if (provenanceRuns.length > 1) atomicJson(manifestFile, manifest, projectRoot);
        return { asset: existing, manifest: 'assets-manifest.json', reused: true, repaired: false };
      }
      existing.title = path.basename(relative);
      existing.localPath = relative;
      existing.bytes = stat.size;
      existing.provenance = currentProvenance;
      existing.provenanceRuns = provenanceRuns;
      atomicJson(manifestFile, manifest, projectRoot);
      return { asset: existing, manifest: 'assets-manifest.json', reused: false, repaired: true };
    }
    const id = `${normalized.provider}-${normalized.kind}-${digest.slice(0, 12)}`;
    const record = {
      id,
      title: path.basename(relative),
      source: normalized.source,
      provider: normalized.provider,
      mediaType: normalized.kind,
      localPath: relative,
      sourcePage: '',
      licenseStatus: normalized.aiGenerated ? 'ai_generated' : 'unknown',
      attribution: normalized.attribution,
      aiGenerated: normalized.aiGenerated,
      sha256: digest,
      bytes: stat.size,
      provenance: currentProvenance,
      provenanceRuns: [currentProvenance]
    };
    manifest.assets.push(record);
    atomicJson(manifestFile, manifest, projectRoot);
    return { asset: record, manifest: 'assets-manifest.json', reused: false };
  } finally {
    releaseManifestLock(lock);
  }
}

function importAsset(projectDirectory, sourceFile, metadata = {}) {
  const projectRoot = fs.realpathSync(path.resolve(projectDirectory));
  const source = path.resolve(sourceFile);
  const sourceStat = fs.lstatSync(source);
  if (!sourceStat.isFile() || sourceStat.isSymbolicLink()) throw new Error('Source asset must be a regular, non-symbolic-link file.');
  const maxBytes = metadata.allowLarge ? Number.MAX_SAFE_INTEGER : MAX_DEFAULT_BYTES;
  if (sourceStat.size > maxBytes) throw new Error('Source asset exceeds the 2 GiB default limit. Re-run with --allow-large after reviewing disk use.');
  const normalized = normalizeMetadata(metadata);
  const digest = hashFile(source);
  const extension = path.extname(source).toLowerCase().replace(/[^a-z0-9.]/g, '').slice(0, 12);
  const basename = safeSlug(path.basename(source, path.extname(source)), normalized.kind);
  const destinationRelative = metadata.destination
    || `assets/generated/${normalized.provider}/${normalized.kind}/${basename}-${digest.slice(0, 12)}${extension}`;
  const destination = projectPath(projectRoot, destinationRelative, 'generated asset destination');
  ensureInternalDirectory(projectRoot, path.dirname(destination), 'generated asset directory');
  let copied = false;
  if (fs.existsSync(destination)) {
    const existing = fs.lstatSync(destination);
    if (!existing.isFile() || existing.isSymbolicLink() || hashFile(destination) !== digest) {
      throw new Error(`Generated asset destination already exists with different content: ${destinationRelative}`);
    }
  } else {
    const temporary = path.join(path.dirname(destination), `.${path.basename(destination)}.${process.pid}.${Date.now()}.tmp`);
    try {
      fs.copyFileSync(source, temporary, fs.constants.COPYFILE_EXCL);
      fs.chmodSync(temporary, 0o600);
      fs.linkSync(temporary, destination);
      fs.unlinkSync(temporary);
      copied = true;
    } catch (error) {
      try { fs.rmSync(temporary, { force: true }); } catch (_) {}
      throw error;
    }
  }
  try {
    const destinationLocalPath = path.relative(projectRoot, destination).split(path.sep).join('/');
    const registered = registerExistingAsset(projectRoot, destination, { ...metadata, sha256: digest });
    if (copied && registered.reused && registered.asset.localPath !== destinationLocalPath) {
      fs.unlinkSync(destination);
      copied = false;
    }
    return { ...registered, copied, localPath: registered.asset.localPath };
  } catch (error) {
    if (copied) {
      try { fs.rmSync(destination, { force: true }); } catch (_) {}
    }
    throw error;
  }
}

function parseArgs(argv) {
  const positional = [];
  const flags = {};
  const booleans = new Set(['allow-large', 'not-ai-generated', 'json']);
  for (let index = 0; index < argv.length; index += 1) {
    const token = argv[index];
    if (!token.startsWith('--')) {
      positional.push(token);
      continue;
    }
    const equal = token.indexOf('=');
    if (equal > 2) {
      const key = token.slice(2, equal);
      if (booleans.has(key)) throw new Error(`--${key} is a bare boolean flag and cannot use =value.`);
      flags[key] = token.slice(equal + 1);
      continue;
    }
    const key = token.slice(2);
    if (booleans.has(key)) {
      flags[key] = true;
      continue;
    }
    const value = argv[index + 1];
    if (!value || value.startsWith('--')) throw new Error(`--${key} requires a value.`);
    flags[key] = value;
    index += 1;
  }
  return { positional, flags };
}

function cli(argv = process.argv.slice(2)) {
  const { positional, flags } = parseArgs(argv);
  const [project, source] = positional;
  if (!project || !source) {
    throw new Error('Usage: ingest_asset.js <project> <source-file> --kind image|video|audio --provider listenhub [--task-id id] [--model name] [--json]');
  }
  const report = importAsset(project, source, {
    kind: flags.kind,
    provider: flags.provider,
    taskId: flags['task-id'],
    model: flags.model,
    speakerId: flags['speaker-id'],
    speakerName: flags['speaker-name'],
    speakerCatalogSha256: flags['speaker-catalog-sha256'],
    narrationTextSha256: flags['narration-text-sha256'],
    visualBibleId: flags['visual-bible-id'],
    prompt: flags.prompt,
    seed: flags.seed,
    creditCharged: flags.credits,
    destination: flags.output,
    termsStatus: flags['terms-status'],
    attribution: flags.attribution,
    aiGenerated: !flags['not-ai-generated'],
    allowLarge: Boolean(flags['allow-large'])
  });
  process.stdout.write(`${JSON.stringify({ ok: true, ...report }, null, 2)}\n`);
  return 0;
}

module.exports = {
  hashFile,
  importAsset,
  normalizeMetadata,
  registerExistingAsset
};

if (require.main === module) {
  try {
    process.exitCode = cli();
  } catch (error) {
    process.stderr.write(`${error.message}\n`);
    process.exitCode = 1;
  }
}
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall