Skip to content

chuspeeism/dashi-ppt-skill / skills/dashi-ppt

dashi-ppt

Flagged

制作 PPT、演示文稿、幻灯片、汇报材料时使用。Dashi PPT 基于预置视觉主题组合页面,生成可离线打开、可在浏览器编辑的 HTML 演示,支持导出 PPTX / PDF 文件。

FileKindSize
.gitignoreother173 B
README.mdmarkdown3.9 KB
SKILL.mdskill md25.4 KB
agents/openai.yamlconfig292 B
assets/skill/dashi-ppt-favicon.pngbinary2.0 KB
assets/skill/dashi-ppt-small.pngbinary895 B
assets/skill/dashi-ppt.pngbinary12.6 KB
assets/skill/theme-style-grid.pngbinary2.1 MB
project/.npmrcother40 B
project/assets/skill/dashi-ppt-favicon.pngbinary2.0 KB
project/assets/social-icons/bilibili.svgother7.9 KB
project/assets/social-icons/douyin.svgother4.7 KB
project/assets/social-icons/github.svgother1.3 KB
project/assets/social-icons/redbook.svgother3.5 KB
project/assets/template-swiss.htmlother465.5 KB
project/assets/ui-icons/sidebar.svgother1.3 KB
project/assets/unicorn/automations_remix_scene.jsonconfig42.9 KB
project/assets/unicorn/goey_balls_remix_scene.jsonconfig14.2 KB
project/assets/unicorn/media/blue_noise_med.pngbinary206.4 KB
project/assets/unicorn/media/font_atlas.pngbinary64.6 KB
project/assets/unicorn/moving_into_remix_scene.jsonconfig67.8 KB
project/assets/unicorn/tech_background_remix_scene.jsonconfig52.2 KB
project/distribution-source.jsonconfig517 B
project/i18n/zh-en.jsonconfig574.5 KB
project/layout-manifest.jsonconfig3.4 MB
project/npmrc.templateother40 B
project/package-lock.jsonmanifest21.8 KB
project/package.jsonmanifest1.2 KB
project/packages/html-deck-to-pptx/LICENSEother1.6 KB
project/packages/html-deck-to-pptx/README.mdmarkdown2.2 KB
project/packages/html-deck-to-pptx/index.mjsscript719 B
project/packages/html-deck-to-pptx/package.jsonmanifest840 B
project/packages/html-deck-to-pptx/src/editable.mjsscript143 B
project/packages/html-deck-to-pptx/src/screenshot.mjsscript147 B
project/scripts/chrome-path.mjsscript6.1 KB
project/scripts/command-paths.mjsscript334 B
project/scripts/ensure-registry.mjsscript2.1 KB
project/scripts/export-pptx.mjsscript6.4 KB
project/scripts/goal-scaffold.mjsscript31.3 KB
project/scripts/inspect-layout.mjsscript2.1 KB
project/scripts/layout-query.mjsscript3.4 KB
project/scripts/media-formats.mjsscript1.3 KB
project/scripts/openssl-path.mjsscript2.2 KB
project/scripts/persist-deck-state.mjsscript6.7 KB
project/scripts/preview-export-auth.mjsscript1.0 KB
project/scripts/preview-freshness.mjsscript6.2 KB
project/scripts/preview-path.mjsscript569 B
project/scripts/preview/ensure-tmpdir.mjsscript3.4 KB
project/scripts/preview/export-routes.mjsscript24.2 KB
project/scripts/preview/launch-export-browser.mjsscript2.5 KB
project/scripts/preview/mime.mjsscript671 B
project/scripts/preview/network.mjsscript799 B
project/scripts/preview/static-serve.mjsscript1.2 KB
project/scripts/preview/tls.mjsscript2.7 KB
project/scripts/render-goal-deck.jsxother2.5 KB
project/scripts/scrub-local-paths.mjsscript898 B
project/scripts/serve-preview-https.mjsscript10.7 KB
project/scripts/skill-workflow-utils.mjsscript1.4 KB
project/scripts/stage-media.mjsexecutablescript14.7 KB
project/scripts/start-preview-server.mjsscript16.1 KB
project/scripts/validate-goal-copy.mjsscript25.4 KB
project/scripts/validate-goal-spec.mjsscript80.7 KB
project/scripts/validate-swiss-deck.mjsscript34.1 KB
project/scripts/workflow-telemetry.mjsscript6.1 KB
project/scripts/workflow/copy-contract.mjsscript19.2 KB
project/scripts/workflow/inspect-fillplan.mjsscript70.6 KB
project/scripts/workflow/layout-allocation.mjsscript8.5 KB
project/scripts/workflow/layout-query.mjsscript64.4 KB
project/scripts/workflow/media-slots.mjsscript15.8 KB
project/scripts/workflow/theme-registry.mjsscript16.1 KB
project/scripts/write-safe-props.mjsscript17.7 KB
project/src/accepted-themes.mjsscript570 B
project/src/components/bespoke/BespokeSlide.jsxother32.0 KB
project/src/components/bespoke/theme-profiles.mjsscript11.5 KB
project/src/components/index.jsxother71 B
project/src/components/shell/SlideShell.jsxother1.5 KB
project/src/components/shell/index.jsxother47 B
project/src/components/themes/canonical-metadata.mjsscript4.6 KB
project/src/components/themes/chart-safety.mjsscript1.9 KB
project/src/components/themes/client-runtime.jsxother57.9 KB
project/src/components/themes/decorative-overrides.mjsscript859 B
project/src/components/themes/generated-metadata.jsscript4.4 MB
project/src/components/themes/index.jsxother2.8 KB
project/src/components/themes/runtime-build.mjsscript7.3 KB
project/src/components/themes/runtime-helpers.jsxother6.2 KB
project/src/components/themes/theme-registry-codegen.mjsscript7.2 KB
project/src/components/themes/theme01/metadata.jsscript363.9 KB
project/src/components/themes/theme01/source/slides/theme.jsscript5.6 KB
project/src/components/themes/theme02/metadata.jsscript384.6 KB
project/src/components/themes/theme02/overrides.jsscript114 B
project/src/components/themes/theme02/source/src/gxnTheme.jsscript19.6 KB
project/src/components/themes/theme03/metadata.jsscript512.5 KB
project/src/components/themes/theme03/overrides.jsscript1.2 KB
project/src/components/themes/theme03/source/assets/3d/01.pngbinary635.1 KB
project/src/components/themes/theme03/source/assets/3d/02.pngbinary865.2 KB
project/src/components/themes/theme03/source/assets/3d/03.pngbinary921.8 KB
project/src/components/themes/theme03/source/assets/3d/04.pngbinary1.1 MB
project/src/components/themes/theme03/source/assets/3d/05.pngbinary920.3 KB
project/src/components/themes/theme03/source/assets/3d/06.pngbinary1.2 MB
project/src/components/themes/theme03/source/assets/3d/07.pngbinary1.6 MB
project/src/components/themes/theme03/source/assets/3d/08.pngbinary1.4 MB
project/src/components/themes/theme03/source/assets/3d/09.pngbinary1.9 MB
project/src/components/themes/theme03/source/assets/3d/10.pngbinary1.4 MB
project/src/components/themes/theme03/source/assets/3d/11.pngbinary1.6 MB
project/src/components/themes/theme03/source/assets/3d/12.pngbinary1.8 MB
project/src/components/themes/theme03/source/src/icons.jsscript799 B
project/src/components/themes/theme03/source/src/preset3d.jsscript119 B
project/src/components/themes/theme03/source/src/presetBase.jsscript3.4 KB
project/src/components/themes/theme03/source/src/registry.jsscript22.3 KB
project/src/components/themes/theme03/source/src/slides/safeProps.jsscript504 B
project/src/components/themes/theme03/source/src/theme.cssother5.4 KB
project/src/components/themes/theme03/source/src/theme.jsscript3.0 KB
project/src/components/themes/theme04/TEXT_CONTROL_POLICY.mdmarkdown344 B
project/src/components/themes/theme04/metadata.jsscript324.4 KB
project/src/components/themes/theme04/overrides.jsscript118 B
project/src/components/themes/theme04/source/image-slot.jsscript41.0 KB
project/src/components/themes/theme05/metadata.jsscript492.0 KB
project/src/components/themes/theme05/source/styles/exc-covers.cssother9.6 KB
project/src/components/themes/theme05/source/styles/pulse-deck.cssother288.9 KB
project/src/components/themes/theme06/metadata.jsscript331.7 KB
project/src/components/themes/theme07/metadata.jsscript319.6 KB
project/src/components/themes/theme07/source/src/theme.jsscript2.9 KB
project/src/components/themes/theme08/metadata.jsscript366.7 KB
project/src/components/themes/theme08/source/image-slot.jsscript45 B
project/src/components/themes/theme09/metadata.jsscript378.4 KB
project/src/components/themes/theme10/metadata.jsscript294.2 KB
project/src/components/themes/theme11/metadata.jsscript399.9 KB
project/src/components/themes/theme12/metadata.jsscript311.7 KB
project/src/components/themes/theme12/source/src/index.jsscript23.1 KB
project/src/components/themes/theme12/source/src/swTheme.jsscript2.3 KB
project/src/components/themes/unicorn-background.jsxother2.0 KB
project/src/control-naming.mjsscript17.2 KB
project/src/deckComposer.jsxother18.8 KB
project/src/generated-metadata-writer.mjsscript722 B
project/src/i18n-core.mjsscript2.3 KB
project/src/i18n.mjsscript1.8 KB
project/src/metadata-serialize.mjsscript6.1 KB
project/src/options.jsxother1.5 KB
project/src/prop-contract-core.mjsscript70.1 KB
project/src/propContracts.jsxother658 B
project/src/react-shim.jsscript51 B
project/src/renderDeck.jsxother14.0 KB
project/src/runtime-assets.mjsscript1.7 KB
project/src/types.d.tsscript1.7 KB
project/src/variant-contract.mjsscript28.8 KB
project/src/variant-materializer.mjsscript9.0 KB
project/src/view-model/context.jsxother382 B
project/src/view-model/index.jsxother26.0 KB
project/src/view-model/schema-v2-canonical.mjsscript471 B
references/examples/annual-review.jsonconfig14.9 KB
references/examples/portfolio.jsonconfig13.1 KB
references/goal-spec.schema.jsonconfig9.9 KB
references/layout-roles.mdmarkdown1.7 KB
references/options.mdmarkdown7.5 KB
scripts/check_latest_version.mjsexecutablescript3.1 KB
scripts/render_goal_deck.ps1script4.5 KB
scripts/render_goal_deck.shexecutablescript2.3 KB

project/src/renderDeck.jsx

View on GitHub
import fs from 'node:fs';
import path from 'node:path';
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { buildSync } from 'esbuild';
import {
  LAYOUT_ALIASES,
  LAYOUT_OPTIONS,
  DEFAULT_THEME_PACK,
  THEME_PACK_OPTIONS,
  resolveOption,
} from './options.jsx';
import {
  buildDeckViewModel,
  renderDeckView,
  serializeDeckViewModel,
} from './view-model/index.jsx';
import {
  REQUIRED_OUTPUT_ASSETS,
  RUNTIME_ASSET_PATHS,
  RUNTIME_TEMPLATE,
} from './runtime-assets.mjs';
import {
  buildThemeRegistrySource,
  isFullThemeSet,
  normalizeThemeKeys,
} from './components/themes/theme-registry-codegen.mjs';
import { normalizeDeckLanguage, buildDeckI18nDict } from './i18n.mjs';
import {
  buildClientRuntime,
  buildClientRuntimeFromModules,
  prebuiltBundlePath,
  prebuiltModulePath,
} from './components/themes/runtime-build.mjs';

const ROOT = path.resolve(import.meta.dirname, '..');
const FULL_THEME_REGISTRY = path.join(ROOT, 'src/components/themes/theme-registry.jsx');
const MIGRATION_ONLY_DIRS = new Set(['uploads', 'screens', 'screenshots', 'shots', 'scratch']);

export function renderDeck(deck, { outFile, includeThemeSwitcher = deck.preview?.themeSwitcher === true }) {
  const viewModel = buildDeckViewModel(deck, {
    layouts: LAYOUT_OPTIONS,
    layoutAliases: LAYOUT_ALIASES,
    themePacks: THEME_PACK_OPTIONS,
    defaultThemePack: DEFAULT_THEME_PACK,
    resolveOption,
  });
  const { key: themePackName } = viewModel.themePack;
  const language = normalizeDeckLanguage(deck.language);
  const template = fs.readFileSync(path.join(ROOT, RUNTIME_TEMPLATE), 'utf8');
  const slides = renderToStaticMarkup(<>{renderDeckView(viewModel)}</>);
  let html = insertSlides(template, slides);
  const htmlLang = language === 'en' ? 'en' : 'zh-CN';
  html = html.replace('<html lang="zh-CN">', `<html lang="${htmlLang}" data-theme-pack="${themePackName}">`);
  html = html.replace('<title>[必填] 替换为 PPT 标题 · Deck Title</title>', `<title>${escapeHtml(viewModel.model.title)}</title>`);
  html = injectPreviewOptions(html, viewModel.options, { includeThemeSwitcher, language, viewModel });
  html = injectDeckViewModel(html, serializeDeckViewModel(viewModel));

  fs.mkdirSync(path.dirname(outFile), { recursive: true });
  fs.writeFileSync(outFile, html);
  copyRuntimeAssets(path.dirname(outFile), { usedThemeKeys: collectUsedThemeKeys(viewModel) });
}

// JAD-201:从 deck 实际用到的主题(每页 themePack)推导待打包的主题集合。
function collectUsedThemeKeys(viewModel) {
  const keys = new Set();
  for (const slide of viewModel.slides || []) {
    for (const variant of slide.variants || [slide]) {
      if (variant.themePack) keys.add(variant.themePack);
    }
  }
  return normalizeThemeKeys(keys);
}

function insertSlides(template, slides) {
  const startMatch = template.match(/<div id="deck"[^>]*>/);
  const startTag = startMatch?.[0];
  const start = startMatch?.index ?? -1;
  const nav = template.indexOf('<div id="nav"', start);
  const deckEnd = findClosingDiv(template, start);

  if (start === -1 || nav === -1 || deckEnd === -1) {
    throw new Error('Template is missing <div id="deck"> or <div id="nav"> markers.');
  }

  const before = template.slice(0, start + startTag.length);
  const after = template.slice(deckEnd);
  return `${before}\n\n<!-- Generated by scripts/render-deck.jsx -->\n${slides}\n\n${after}`;
}

function findClosingDiv(html, start) {
  if (start < 0) return -1;
  const tagPattern = /<\/?div\b[^>]*>/gi;
  tagPattern.lastIndex = start;
  let depth = 0;
  let match;
  while ((match = tagPattern.exec(html))) {
    if (match[0].startsWith('</')) {
      depth -= 1;
      if (depth === 0) return match.index;
    } else {
      depth += 1;
    }
  }
  return -1;
}

function injectPreviewOptions(html, options, { includeThemeSwitcher = false, language = 'zh', viewModel = null } = {}) {
  const previewOptions = {
    ...options,
    themePacks: includeThemeSwitcher ? options.themePacks : {},
    // 多主题调试总览(showcase)不自动保存:它是共享调试产物,浏览器里的试验性编辑
    // 不应烧回 index.html(会污染 render:themes 与其上运行的其他测试)。
    ...(includeThemeSwitcher ? { autosave: false } : {}),
    language,
    // 词典子集始终注入(按本 deck 用到的页面裁剪,通常几 KB):运行时语言可由
    // 系统语言/用户手动切换决定,中文 deck 也可能要切到英文界面。
    ...(viewModel ? { i18n: buildDeckI18nDict(viewModel) } : {}),
  };
  const json = escapeScriptJson(JSON.stringify(previewOptions));
  return html.replace(
    /<script id="preview-options" type="application\/json">[\s\S]*?<\/script>/,
    `<script id="preview-options" type="application/json">${json}</script>`,
  );
}

function injectDeckViewModel(html, viewModel) {
  const json = escapeScriptJson(JSON.stringify(viewModel));
  return html.replace(
    /<script id="deck-view-model" type="application\/json">[\s\S]*?<\/script>/,
    `<script id="deck-view-model" type="application/json">${json}</script>`,
  );
}

function copyRuntimeAssets(outDir, { usedThemeKeys = [] } = {}) {
  const assetsDir = path.join(outDir, 'assets');
  const imagesDir = path.join(outDir, 'images');
  for (const dir of [assetsDir, imagesDir]) {
    if (!fs.existsSync(dir)) continue;
    for (const name of fs.readdirSync(dir)) {
      if (name !== 'user-media') fs.rmSync(path.join(dir, name), { recursive: true, force: true });
    }
  }
  [path.join(outDir, 'uploads'), path.join(outDir, 'screens'), path.join(outDir, 'screenshots')].forEach(dir => {
    fs.rmSync(dir, { recursive: true, force: true });
  });
  fs.mkdirSync(assetsDir, { recursive: true });
  copyRequiredFile(path.join(ROOT, 'node_modules/gsap/dist/gsap.min.js'), path.join(assetsDir, 'vendor/gsap.min.js'));
  copyRequiredFile(path.join(ROOT, 'node_modules/pptxgenjs/dist/pptxgen.bundle.js'), path.join(assetsDir, 'vendor/pptxgen.bundle.js'));
  copyRequiredFile(path.join(ROOT, 'node_modules/pdf-lib/dist/pdf-lib.min.js'), path.join(assetsDir, 'vendor/pdf-lib.min.js'));
  copyRequiredFile(path.join(ROOT, 'node_modules/html-to-image/dist/html-to-image.js'), path.join(assetsDir, 'vendor/html-to-image.js'));
  for (const assetPath of RUNTIME_ASSET_PATHS) {
    if (assetPath === RUNTIME_TEMPLATE) continue;
    copyRuntimeAsset(assetPath, outDir);
  }
  copyImportedThemeAssets(outDir, usedThemeKeys);
  buildImportedThemeRuntime(path.join(assetsDir, 'imported-theme-runtime.js'), usedThemeKeys);
  const imageSlotStateFile = path.join(outDir, '.image-slots.state.json');
  if (!fs.existsSync(imageSlotStateFile)) fs.writeFileSync(imageSlotStateFile, '{}\n');
}

function copyRuntimeAsset(assetPath, outDir) {
  const source = path.join(ROOT, assetPath);
  const target = path.join(outDir, assetPath);
  if (!fs.existsSync(source)) {
    throw new Error(`Runtime asset is listed but missing: ${assetPath}`);
  }
  if (fs.statSync(source).isDirectory()) {
    copyDirectoryIfExists(source, target);
  } else {
    fs.mkdirSync(path.dirname(target), { recursive: true });
    fs.copyFileSync(source, target);
  }
}

// JAD-201/203:打包这份 deck 实际用到主题的浏览器运行时。两条等价路径(见 runtime-build.mjs):
//   - dev / 有主题源(showcase 全主题、本地迭代):源 esbuild(行为同 JAD-201)。
//   - 安装版 / 无可读主题源:单主题拷贝预构建自包含 bundle;多主题用预构建模块链接。
// `DASHI_PPT_THEME_RUNTIME`:auto(默认,有源走源、无源走预构建)| prebuilt(强制预构建,测试用)
//   | source(强制源)。安装版无主题源时自动走预构建,产出与源路径等价(单一 React,水合一致)。
function buildImportedThemeRuntime(outFile, usedThemeKeys = []) {
  const normalized = normalizeThemeKeys(usedThemeKeys || []);
  const mode = process.env.DASHI_PPT_THEME_RUNTIME || 'auto';
  const sourcePresent = hasThemeSource(normalized);
  const wantPrebuilt = mode === 'prebuilt' || (mode === 'auto' && !sourcePresent);

  if (wantPrebuilt) {
    // 单主题(绝大多数 deck):直接拷贝预构建自包含 bundle —— 零 deck 级 esbuild、零主题源。
    if (normalized.length === 1) {
      const bundle = prebuiltBundlePath(ROOT, normalized[0]);
      if (fs.existsSync(bundle)) {
        fs.copyFileSync(bundle, outFile);
        return;
      }
    }
    // 多主题(或单主题缺自包含 bundle):用预构建 minified 模块链接(无主题源)。
    if (normalized.length && prebuiltModulesAvailable(normalized)) {
      buildClientRuntimeFromModules({ root: ROOT, outFile, themeKeys: normalized });
      return;
    }
    if (mode === 'prebuilt') {
      throw new Error(`prebuilt theme runtime requested but artifacts missing for [${normalized.join(', ')}]; run \`node scripts/build/build-theme-runtime.mjs\`.`);
    }
    // mode=auto 且无源、无预构建:落到下方报错。
  }

  if (sourcePresent && mode !== 'prebuilt') {
    buildImportedThemeRuntimeFromSource(outFile, normalized);
    return;
  }

  throw new Error(`No imported theme runtime available for [${normalized.join(', ')}] (no readable theme source and no prebuilt artifacts).`);
}

// 源路径(JAD-201):别名指向全主题签入注册表或按 usedThemeKeys 裁剪的源注册表。
function buildImportedThemeRuntimeFromSource(outFile, usedThemeKeys = []) {
  const { registryPath, cleanup } = resolveThemeRegistryEntry(usedThemeKeys);
  try {
    buildClientRuntime({ root: ROOT, outFile, registryPath });
  } finally {
    cleanup();
  }
}

// 主题源是否在盘上(dev 仓为真;安装版已删 runtime.jsx + theme-registry.jsx,为假)。
function hasThemeSource(normalized) {
  if (!normalized.length) return fs.existsSync(FULL_THEME_REGISTRY);
  return normalized.every(key => fs.existsSync(path.join(ROOT, 'src/components/themes', key, 'runtime.jsx')));
}

function prebuiltModulesAvailable(normalized) {
  return normalized.length > 0 && normalized.every(key => fs.existsSync(prebuiltModulePath(ROOT, key)));
}

// 全主题(或主题集合无法识别时)→ 直接用签入的全主题注册表;
// 单/少主题 → 生成裁剪版临时注册表(写到 gitignore 的 node_modules/.cache,
// import 用指向仓库的绝对路径,确保从临时位置也能解析主题源码与 react)。
function resolveThemeRegistryEntry(usedThemeKeys) {
  const normalized = normalizeThemeKeys(usedThemeKeys || []);
  if (!normalized.length || isFullThemeSet(normalized)) {
    return { registryPath: FULL_THEME_REGISTRY, cleanup: () => {} };
  }
  const importPrefix = `${path.join(ROOT, 'src/components/themes')}/`;
  const source = buildThemeRegistrySource(normalized, { importPrefix });
  const cacheDir = path.join(ROOT, 'node_modules/.cache/dashi-theme-registry');
  fs.mkdirSync(cacheDir, { recursive: true });
  const registryPath = path.join(
    cacheDir,
    `registry-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}.jsx`,
  );
  fs.writeFileSync(registryPath, source);
  return {
    registryPath,
    cleanup: () => { try { fs.rmSync(registryPath, { force: true }); } catch {} },
  };
}

function copyImportedThemeAssets(outDir, usedThemeKeys = []) {
  const themesDir = path.join(ROOT, 'src/components/themes');
  if (!fs.existsSync(themesDir)) return;
  // JAD-201: a deck only needs its used theme(s)' assets. Empty/all-themes (e.g.
  // the showcase) copies everything; a single-/few-theme deck skips the rest,
  // shrinking the deck and not leaking other themes' image/video source assets.
  const usedFilter = new Set(usedThemeKeys || []);
  const copiedByRelativePath = new Map(
    REQUIRED_OUTPUT_ASSETS.map(assetPath => [
      assetPath,
      { themeKey: 'runtime', from: path.join(ROOT, assetPath) },
    ]),
  );
  for (const themeKey of fs.readdirSync(themesDir).sort()) {
    if (usedFilter.size > 0 && !usedFilter.has(themeKey)) continue;
    const sourceDir = path.join(themesDir, themeKey, 'source');
    if (!fs.existsSync(sourceDir)) continue;
    const files = [];
    collectThemeAssetFiles(sourceDir, files);
    files.forEach(from => {
      const rel = path.relative(sourceDir, from);
      const outputRel = rel.replaceAll(path.sep, '/');
      const existing = copiedByRelativePath.get(outputRel);
      if (existing) {
        throw new Error(`Theme asset output path collision: ${outputRel} (${existing.themeKey}: ${existing.from}, ${themeKey}: ${from})`);
      }
      copiedByRelativePath.set(outputRel, { themeKey, from });
      const to = path.join(outDir, rel);
      fs.mkdirSync(path.dirname(to), { recursive: true });
      fs.copyFileSync(from, to);
    });
  }
}

function collectThemeAssetFiles(dir, out) {
  for (const name of fs.readdirSync(dir).sort()) {
    const file = path.join(dir, name);
    const stat = fs.statSync(file);
    if (stat.isDirectory()) {
      if (MIGRATION_ONLY_DIRS.has(name.toLowerCase())) continue;
      collectThemeAssetFiles(file, out);
      continue;
    }
    if (/\.(png|jpe?g|webp|gif|svg|mp4|mov)$/i.test(name)) out.push(file);
  }
}

function copyDirectoryIfExists(from, to) {
  if (!fs.existsSync(from)) return;
  for (const name of fs.readdirSync(from)) {
    const source = path.join(from, name);
    const target = path.join(to, name);
    const stat = fs.statSync(source);
    if (stat.isDirectory()) {
      copyDirectoryIfExists(source, target);
    } else {
      fs.mkdirSync(path.dirname(target), { recursive: true });
      fs.copyFileSync(source, target);
    }
  }
}

function copyFileIfExists(from, to) {
  if (fs.existsSync(from)) {
    fs.mkdirSync(path.dirname(to), { recursive: true });
    fs.copyFileSync(from, to);
  }
}

// 交付件必需的 vendor 库缺失时立刻失败,不允许静默产出缺脚本的 deck。
function copyRequiredFile(from, to) {
  if (!fs.existsSync(from)) {
    throw new Error(`Required vendor asset missing: ${from}`);
  }
  fs.mkdirSync(path.dirname(to), { recursive: true });
  fs.copyFileSync(from, to);
}

function escapeHtml(value) {
  return String(value)
    .replaceAll('&', '&amp;')
    .replaceAll('<', '&lt;')
    .replaceAll('>', '&gt;')
    .replaceAll('"', '&quot;');
}

function escapeScriptJson(value) {
  return value
    .replaceAll('<', '\\u003c')
    .replaceAll('\u2028', '\\u2028')
    .replaceAll('\u2029', '\\u2029');
}
canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall