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/scripts/validate-goal-copy.mjs

View on GitHub
#!/usr/bin/env node
import { readFileSync } from 'node:fs';
import path from 'node:path';
import { isMediaArrayKey } from '../src/prop-contract-core.mjs';
import { isBespokeVariant, resolveContentMap } from '../src/variant-contract.mjs';
import { inspectLayout } from './skill-workflow-utils.mjs';

// 相对路径按调用方目录解析:npm run(含 --prefix)会把脚本 cwd 切到项目根,INIT_CWD 才是用户所在目录。
const CALLER_CWD = process.env.INIT_CWD || process.cwd();

const [, , specArg, htmlArg] = process.argv;

if (!specArg || !htmlArg) {
  console.error('Usage: node scripts/validate-goal-copy.mjs <goal-spec.json> <output/ppt/index.html>');
  process.exit(2);
}

const spec = JSON.parse(readFileSync(path.resolve(CALLER_CWD, specArg), 'utf8'));
const html = readFileSync(path.resolve(CALLER_CWD, htmlArg), 'utf8');
const layoutManifest = readLayoutManifest();
const specText = JSON.stringify(spec, null, 2);
const errors = [];
const COUNT_ARRAY_CANDIDATES = {
  barCount: ['bars'],
  calloutCount: ['callouts'],
  cardCount: ['cards'],
  chipCount: ['chips'],
  colCount: ['columns', 'cols'],
  featureCount: ['features', 'plans[].feats'],
  itemCount: ['items', 'stats', 'data'],
  stepCount: ['steps'],
  laneCount: ['lanes'],
  phaseCount: ['phases'],
  wordCount: ['words'],
  segCount: ['segments', 'segs'],
  roundCount: ['rounds'],
  milestoneCount: ['milestones'],
  statCount: ['stats'],
  pointCount: ['points'],
  planCount: ['plans'],
  rowCount: ['rows', 'features'],
  columnCount: ['columns', 'plans'],
  tileCount: ['tiles'],
  indexCount: ['items', 'index'],
  principleCount: ['principles', 'items'],
  supportingCount: ['supporting'],
  seriesCount: ['series'],
  segmentCount: ['segments'],
};
const NEUTRAL_PLACEHOLDERS = ['请输入文本', '请输入', '请输'];
const visibleText = extractSlideText(html, undefined, errors);
const COMMON_TERMS = new Set([
  '一个',
  '一份',
  '制作',
  '生成',
  '演示',
  '页面',
  '主题',
  '用户',
  '目标',
  '受众',
  '团队',
  '重要',
  '展示',
  '呈现',
]);

const groups = [
  {
    name: 'AI Capital / 投融资默认文案',
    allowWhen: /人工智能|资本|投资|融资|风投|估值|美元|\b(AI|VC|venture|OpenAI|xAI)\b/i,
    terms: [
      'AI CAPITAL',
      'AI Capital',
      'OpenAI',
      'xAI',
      'Anthropic',
      'Databricks',
      'Scale AI',
      '融资',
      '风投',
      '资本',
      '亿美元',
      '估值',
      '大模型',
      '投资判断',
    ],
  },
  {
    name: 'SoundWave / 声浪默认文案',
    allowWhen: /SoundWave|声浪|音乐|歌曲|歌手|乐队|创作者|发行|结算|版权|巡演|唱片/i,
    terms: [
      'SoundWave',
      '声浪',
      'Independent Music',
      '音乐人',
      '创作者',
      '发行',
      '结算',
      '版权',
      '巡演',
      '录音棚',
    ],
  },
];

for (const group of groups) {
  if (group.allowWhen.test(specText)) continue;
  const hits = group.terms.filter(term => visibleText.includes(term));
  if (hits.length) {
    errors.push(`${group.name}残留: ${hits.join(', ')}`);
  }
}

const unexpectedDefaultTerms = [
  'Key Metrics',
  '关键指标',
  '全景速览',
  'Roadmap',
  '布局路线',
  '阶段推进',
  'End of Report',
].filter(term => visibleText.includes(term) && !specText.includes(term));
if (unexpectedDefaultTerms.length) {
  errors.push(`未在 goal.json 中声明的模板默认文案残留: ${unexpectedDefaultTerms.join(', ')}`);
}

const neutralPlaceholders = findNeutralPlaceholders(visibleText);
if (neutralPlaceholders.length) {
  errors.push(`中性占位文案残留: ${neutralPlaceholders.join(', ')}`);
}

const requestedTerms = pickRequestedTerms(spec);
if (requestedTerms.length && !requestedTerms.some(term => visibleText.includes(term))) {
  errors.push(`输出正文没有命中用户目标关键词: ${requestedTerms.join(', ')}`);
}

validateCountControls(html, errors);
validateCoverCandidateUsage(html, errors);
validateVariantCopyCompleteness(html, errors);

if (errors.length) {
  console.error('Goal copy validation failed:');
  for (const error of errors) console.error(`- ${error}`);
  process.exit(1);
}

console.log('Goal copy validation passed.');

function pickRequestedTerms(spec) {
  const raw = [
    spec.title,
    spec.goal,
    spec.audience,
    spec.owner,
  ].filter(Boolean).join(' ');
  const terms = new Set();
  for (const match of raw.matchAll(/[\u4e00-\u9fa5]{2,}/g)) {
    const value = match[0];
    if (value.length <= 2) terms.add(value);
    else {
      terms.add(value.slice(0, 2));
      terms.add(value.slice(-2));
    }
  }
  for (const match of raw.matchAll(/[A-Za-z][A-Za-z0-9-]{2,}/g)) {
    terms.add(match[0]);
  }
  return [...terms].filter(term => !COMMON_TERMS.has(term)).slice(0, 12);
}

function extractSlideText(html, renderedText = extractRenderedSlideText(html), validationErrors = []) {
  return `${renderedText}\n${extractVisibleDeckPropsText(html, validationErrors)}`;
}

function extractRenderedSlideText(html) {
  const slides = [...html.matchAll(/<section\b[^>]*class="[^"]*\bslide\b[^"]*"[^>]*>[\s\S]*?<\/section>/g)]
    .map(match => match[0]);
  return decodeEntities(slides.map(slide => stripTags(slide)).join('\n'));
}

function extractVisibleDeckPropsText(markup, validationErrors = []) {
  const model = readJsonScript(markup, 'deck-view-model');
  if (!model?.slides?.length) return '';
  const sections = getSlideSections(markup);
  return JSON.stringify(model.slides.flatMap(logicalSlide => {
    return getSlideCandidates(logicalSlide).map(slide => {
      const section = findSlideSection(sections, logicalSlide, slide);
      if (isBespokeVariant(slide)) {
        return {
          kind: 'bespoke',
          composition: resolveCandidateComposition(logicalSlide, slide, validationErrors),
        };
      }
      const resolvedSlide = {
        ...slide,
        props: resolveCandidateProps(logicalSlide, slide, validationErrors),
      };
      return {
        layout: slide.layout,
        props: visiblePropsForSlide(
          resolvedSlide,
          readCandidateControls(logicalSlide, resolvedSlide, section),
          readArrayMeta(resolvedSlide),
        ),
      };
    });
  }));
}

function visiblePropsForSlide(slide, controls = [], arrayMeta = []) {
  const props = slide?.props || {};
  const bindings = getCountBindings(slide, controls, arrayMeta);
  const arrayCounts = new Map();
  for (const binding of bindings) {
    const count = numberOrNull(props[binding.key] ?? props[binding.publicKey]);
    if (count == null) continue;
    for (const arrayKey of binding.arrays || []) arrayCounts.set(arrayKey, count);
  }
  const fallbackCount = fallbackVisibleCount(props, bindings, controls);
  return filterVisibleValue(props, '', arrayCounts, fallbackCount);
}

function filterVisibleValue(value, pathName, arrayCounts, fallbackCount) {
  if (Array.isArray(value)) {
    const key = lastPathKey(pathName);
    const explicitCount = arrayCounts.get(pathName) ?? arrayCounts.get(key);
    const limit = explicitCount ?? (shouldSliceByFallback(key, value, fallbackCount) ? fallbackCount : null);
    const visible = limit == null ? value : value.slice(0, limit);
    const itemPath = pathName ? `${pathName}[]` : '[]';
    return visible.map(item => filterVisibleValue(item, itemPath, arrayCounts, fallbackCount));
  }
  if (!value || typeof value !== 'object') return value;
  return Object.fromEntries(Object.entries(value).map(([childKey, childValue]) => [
    childKey,
    filterVisibleValue(childValue, pathName ? `${pathName}.${childKey}` : childKey, arrayCounts, fallbackCount),
  ]));
}

function lastPathKey(pathName) {
  return String(pathName || '')
    .split('.')
    .at(-1)
    ?.replace(/\[\]$/, '') || '';
}

function fallbackVisibleCount(props, bindings, controls = []) {
  const countKeys = new Set();
  for (const binding of bindings || []) {
    if (binding.key) countKeys.add(binding.key);
    if (binding.publicKey) countKeys.add(binding.publicKey);
  }
  for (const control of controls || []) {
    if (!isNonMediaCountControl(control)) continue;
    if (control.key) countKeys.add(control.key);
    if (control.publicKey) countKeys.add(control.publicKey);
  }
  const counts = [...new Set([...countKeys]
    .map(key => numberOrNull(props[key]))
    .filter(value => value != null))];
  return counts.length === 1 ? counts[0] : null;
}

function isNonMediaCountControl(control) {
  const key = String(control?.key || control?.publicKey || '');
  const type = String(control?.type || '').toLowerCase();
  if (!/count$/i.test(key)) return false;
  if (type && !['number', 'range', 'slider'].includes(type)) return false;
  return !/(?:image|img|media|photo|video|avatar|logo|thumb|cover|poster|slot)/i.test(key);
}

function shouldSliceByFallback(key, value, fallbackCount) {
  if (fallbackCount == null || !Array.isArray(value) || value.length <= fallbackCount) return false;
  if (isMediaArrayKey(key)) return false;
  if (/^(items|cards|stats|data|captions|labels|callouts|features|tiles)$/i.test(String(key || ''))) return true;
  // The count→array binding table does not name every component's content array (e.g. nodes, tiers,
  // premises, shots). When a single page count resolves below the array length and the count-hidden
  // tail is neutral-placeholder filler padded for panel restore, slice it off so it is not scanned
  // as visible copy. Arrays whose tail is genuine copy stay intact, so real residue is still caught.
  return value.slice(fallbackCount).some(containsNeutralPlaceholder);
}

function containsNeutralPlaceholder(item) {
  if (item == null) return false;
  if (typeof item === 'string') return NEUTRAL_PLACEHOLDERS.some(placeholder => item.includes(placeholder));
  if (typeof item !== 'object') return false;
  const text = JSON.stringify(item);
  return NEUTRAL_PLACEHOLDERS.some(placeholder => text.includes(placeholder));
}


function numberOrNull(value) {
  const number = Number(value);
  return Number.isFinite(number) && number >= 0 ? Math.round(number) : null;
}

function findNeutralPlaceholders(text) {
  const hits = new Set();
  let value = String(text || '');
  for (const placeholder of NEUTRAL_PLACEHOLDERS) {
    if (!value.includes(placeholder)) continue;
    hits.add(placeholder);
    value = value.replaceAll(placeholder, '');
  }
  return [...hits];
}

function stripTags(markup) {
  return markup
    .replace(/<script\b[\s\S]*?<\/script>/gi, ' ')
    .replace(/<style\b[\s\S]*?<\/style>/gi, ' ')
    .replace(/<svg\b[\s\S]*?<\/svg>/gi, ' ')
    .replace(/<[^>]+>/g, ' ')
    .replace(/\s+/g, ' ')
    .trim();
}

function decodeEntities(value) {
  return value
    .replaceAll('&quot;', '"')
    .replaceAll('&amp;', '&')
    .replaceAll('&lt;', '<')
    .replaceAll('&gt;', '>')
    .replaceAll('&#x27;', "'")
    .replaceAll('&#39;', "'");
}

function validateCountControls(html, errors) {
  const model = readJsonScript(html, 'deck-view-model');
  if (!model?.slides?.length) return;
  const sections = getSlideSections(html);
  for (const logicalSlide of model.slides) {
    for (const slide of getSlideCandidates(logicalSlide)) {
      if (isBespokeVariant(slide)) continue;
      const section = findSlideSection(sections, logicalSlide, slide);
      if (!section) continue;
      const resolvedSlide = {
        ...slide,
        props: resolveCandidateProps(logicalSlide, slide, errors),
      };
      const controls = readCandidateControls(logicalSlide, resolvedSlide, section);
      for (const control of getCountBindings(resolvedSlide, controls, readArrayMeta(resolvedSlide))) {
        const key = control.key;
        const candidates = control.arrays || COUNT_ARRAY_CANDIDATES[key];
        if (!candidates?.length) continue;
        const props = resolvedSlide.props || {};
        const derived = deriveCount(props, key, candidates);
        if (!derived) continue;
        if (derived.error) errors.push(`${resolvedSlide.label || resolvedSlide.layout}: ${derived.error}`);
        else validateCountValue(resolvedSlide, control, derived, props, errors);
      }
    }
  }
}

function validateCoverCandidateUsage(html, errors) {
  const model = readJsonScript(html, 'deck-view-model');
  if (!model?.slides?.length) return;
  const coverSlides = model.slides.filter(slide => (
    getSlideCandidates(slide).some(candidate => /^theme\d+_page00[1-5]$/.test(candidate.layout))
  ));
  if (coverSlides.length > 1) {
    const layouts = coverSlides.flatMap(slide => (
      getSlideCandidates(slide)
        .map(candidate => candidate.layout)
        .filter(layout => /^theme\d+_page00[1-5]$/.test(layout))
    ));
    errors.push(`同一个 deck 只能使用 1 个封面候选页,当前使用了 ${coverSlides.length} 个: ${layouts.join(', ')}`);
  }
}

function validateVariantCopyCompleteness(html, errors) {
  const model = readJsonScript(html, 'deck-view-model');
  if (!model?.slides?.length) return;
  for (const logicalSlide of model.slides) {
    if (!Array.isArray(logicalSlide?.variants)) continue;
    for (const candidate of logicalSlide.variants) {
      if (isBespokeVariant(candidate)) continue;
      const fillPlan = inspectLayout(candidate.layout, { compact: true })?.fillPlan;
      if (!fillPlan) continue;
      const resolvedProps = resolveCandidateProps(logicalSlide, candidate, errors);
      const missing = [];
      for (const field of fillPlan.text || []) {
        if (!hasFilledPath(resolvedProps, field.key)) missing.push(field.key);
      }
      for (const field of fillPlan.arrays || []) {
        const arrays = readAuthoredArrays(resolvedProps, field.key);
        if (!arrays.length) {
          missing.push(field.key);
          continue;
        }
        const requestedCount = numberOrNull(resolvedProps?.[field.countKey]);
        const visibleCount = requestedCount ?? numberOrNull(field.visibleCount) ?? 0;
        arrays.forEach((items, arrayIndex) => {
          if (items.length < visibleCount) {
            missing.push(`${field.key}${arrays.length > 1 ? `[${arrayIndex}]` : ''}(${items.length}/${visibleCount})`);
            return;
          }
          if (!Object.keys(field.itemFields || {}).length) {
            for (let itemIndex = 0; itemIndex < visibleCount; itemIndex += 1) {
              if (!hasFilledValue(items[itemIndex])) missing.push(`${field.key}[${itemIndex}]`);
            }
          }
          for (let itemIndex = 0; itemIndex < visibleCount; itemIndex += 1) {
            for (const key of Object.keys(field.itemFields || {})) {
              if (!hasFilledPath(items[itemIndex], key)) {
                missing.push(`${field.key}[${itemIndex}].${key}`);
              }
            }
          }
        });
      }
      if (missing.length) {
        const label = candidate.label || candidate.id || candidate.layout;
        const preview = missing.slice(0, 8).join(', ');
        const suffix = missing.length > 8 ? ` 等 ${missing.length} 项` : '';
        errors.push(`${label}: 未覆写模板文案槽: ${preview}${suffix}`);
      }
    }
  }
}

function hasFilledPath(value, pathName) {
  const segments = String(pathName || '').split('.').filter(Boolean);
  let current = value;
  for (const segment of segments) {
    if (!current || typeof current !== 'object' || !Object.prototype.hasOwnProperty.call(current, segment)) {
      return false;
    }
    current = current[segment];
  }
  return hasFilledValue(current);
}

function hasFilledValue(value) {
  if (typeof value === 'string') return value.trim().length > 0;
  return value !== undefined && value !== null;
}

function readAuthoredArrays(value, pathName) {
  const segments = String(pathName || '').split('.').filter(Boolean);
  return collectArrayTargets(value, segments, 0);
}

function collectArrayTargets(value, segments, index) {
  if (!value || typeof value !== 'object' || index >= segments.length) return [];
  const raw = segments[index];
  const traversesArray = raw.endsWith('[]');
  const key = traversesArray ? raw.slice(0, -2) : raw;
  const next = value[key];
  if (index === segments.length - 1) return Array.isArray(next) ? [next] : [];
  if (traversesArray) {
    if (!Array.isArray(next)) return [];
    return next.flatMap(item => collectArrayTargets(item, segments, index + 1));
  }
  return collectArrayTargets(next, segments, index + 1);
}

function readLayoutManifest() {
  try {
    return JSON.parse(readFileSync('layout-manifest.json', 'utf8'));
  } catch {
    return null;
  }
}

function getCountBindings(slide, controls = [], arrayMeta = []) {
  const manifestBindings = layoutManifest?.layouts?.[slide.layout]?.countBindings;
  const metaBindings = arrayMetaCountBindings([
    ...(layoutManifest?.layouts?.[slide.layout]?.arrayMeta || []),
    ...(arrayMeta || []),
  ]);
  const explicitControlBindings = controlCountBindings(controls);
  const fallbackBindings = controls
    .filter(control => COUNT_ARRAY_CANDIDATES[control.key])
    .map(control => ({ ...control, arrays: COUNT_ARRAY_CANDIDATES[control.key] }));
  return mergeCountBindings(manifestBindings, metaBindings, explicitControlBindings, fallbackBindings);
}

function arrayMetaCountBindings(arrayMeta = []) {
  return (arrayMeta || [])
    .filter(meta => meta?.key && (meta.countKey || meta.publicCountKey))
    .map(meta => ({
      key: meta.countKey || meta.publicCountKey,
      publicKey: meta.publicCountKey || meta.countKey,
      arrays: [meta.key],
      min: meta.min,
      max: meta.max,
    }));
}

function controlCountBindings(controls = []) {
  const bindings = [];
  for (const control of controls || []) {
    const arrays = normalizeCountArrays(control.countArrays);
    if (arrays.length && control.key) {
      bindings.push({ ...control, arrays });
    }
    if (control.countKey && control.key && !isMediaArrayKey(control.key)) {
      bindings.push({
        key: control.countKey,
        publicKey: control.countKey,
        arrays: [control.key],
        min: control.min,
        max: control.max,
      });
    }
  }
  return bindings;
}

function normalizeCountArrays(value) {
  if (Array.isArray(value)) return value.filter(item => typeof item === 'string' && item);
  if (typeof value === 'string') return value.split(',').map(item => item.trim()).filter(Boolean);
  return [];
}

function mergeCountBindings(...groups) {
  const result = [];
  const seen = new Set();
  for (const binding of groups.flatMap(group => group || [])) {
    if (!binding?.key || seen.has(binding.key)) continue;
    seen.add(binding.key);
    result.push(binding);
  }
  return result;
}

function readArrayMeta(slide) {
  return Array.isArray(slide?.arrayMeta) ? slide.arrayMeta : [];
}

function getSlideCandidates(slide) {
  return Array.isArray(slide?.variants) && slide.variants.length ? slide.variants : [slide];
}

function resolveCandidateProps(logicalSlide, candidate, errors = []) {
  return resolveCandidateRenderData(logicalSlide, candidate, candidate?.props, 'props', errors);
}

function resolveCandidateComposition(logicalSlide, candidate, errors = []) {
  return resolveCandidateRenderData(logicalSlide, candidate, candidate?.composition, 'composition', errors);
}

function resolveCandidateRenderData(logicalSlide, candidate, base, field, errors) {
  if (!candidate?.contentMap || typeof candidate.contentMap !== 'object' || Array.isArray(candidate.contentMap)) {
    return base || {};
  }
  try {
    return resolveContentMap(logicalSlide?.content, candidate.contentMap, base || {});
  } catch (error) {
    const label = candidate.label || candidate.id || candidate.layout || 'variant';
    pushUniqueError(errors, `${label}: contentMap 无法从 sourceSlideId ${logicalSlide?.id || '<missing>'} 解析 ${field}: ${error.message}`);
    return base || {};
  }
}

function pushUniqueError(errors, error) {
  if (!errors.includes(error)) errors.push(error);
}

function readCandidateControls(logicalSlide, slide, section) {
  if (isBespokeVariant(slide)) return [];
  const manifestControls = layoutManifest?.layouts?.[slide.layout]?.controls || [];
  const sectionControls = readPropControls(section);
  if (!Array.isArray(logicalSlide?.variants) || !logicalSlide.variants.length) {
    return sectionControls.length ? sectionControls : manifestControls;
  }
  if (!isRenderedCandidate(logicalSlide, slide, section)) return manifestControls;
  return sectionControls.length ? sectionControls : manifestControls;
}

function isRenderedCandidate(logicalSlide, slide, section) {
  const renderedPhysicalId = getAttr(section, 'data-vm-slide-id');
  const renderedStateId = getAttr(section, 'data-vm-variant-state-id');
  if (renderedStateId) return slide.stateId === renderedStateId || renderedPhysicalId === slide.stateId;
  if (renderedPhysicalId && slide.stateId) return renderedPhysicalId === slide.stateId;
  if (logicalSlide.stateId) return slide.stateId === logicalSlide.stateId;
  if (logicalSlide.selectedVariant) {
    return slide.id === logicalSlide.selectedVariant || slide.stateId === logicalSlide.selectedVariant;
  }
  return slide.layout === logicalSlide.layout;
}

function deriveCount(props, key, candidates) {
  const counts = [];
  if (key === 'phaseCount' && Array.isArray(props.lanes)) {
    props.lanes.forEach((lane, index) => {
      if (Array.isArray(lane.items)) counts.push({ source: `lanes[${index}].items`, count: lane.items.length });
    });
  }
  for (const arrayKey of candidates) {
    counts.push(...collectArrayCounts(props, arrayKey));
  }
  if (!counts.length) return null;
  if (candidates.some(isNestedArrayPath)) return collapseNestedCounts(counts);
  return collapseCounts(counts);
}

function collectArrayCounts(value, pathName, sourcePrefix = '') {
  if (!value || typeof value !== 'object') return [];
  const [segment, ...restParts] = String(pathName || '').split('.');
  const rest = restParts.join('.');
  const arraySegment = segment.endsWith('[]');
  const key = arraySegment ? segment.slice(0, -2) : segment;
  const next = value[key];
  const source = sourcePrefix ? `${sourcePrefix}.${key}` : key;

  if (arraySegment) {
    if (!Array.isArray(next)) return [];
    if (!rest) return [{ source, count: next.length }];
    return next.flatMap((item, index) => collectArrayCounts(item, rest, `${source}[${index}]`));
  }

  if (!rest) {
    return Array.isArray(next) ? [{ source, count: next.length }] : [];
  }
  return collectArrayCounts(next, rest, source);
}

function isNestedArrayPath(pathName) {
  return String(pathName || '').includes('[].');
}

function collapseCounts(counts) {
  const unique = [...new Set(counts.map(item => item.count))];
  if (unique.length > 1) {
    return { error: `${counts.map(item => `${item.source}=${item.count}`).join(', ')} 数量不一致` };
  }
  return {
    count: unique[0],
    source: counts.map(item => item.source).join('/'),
  };
}

function collapseNestedCounts(counts) {
  return {
    count: Math.min(...counts.map(item => item.count)),
    source: counts.map(item => `${item.source}=${item.count}`).join('/'),
  };
}

function validateCountValue(slide, control, derived, props, errors) {
  const current = Number(props[control.key]);
  if (!Number.isFinite(current)) {
    errors.push(`${slide.label || slide.layout}: ${control.key} 缺失或不是有效数字,但 ${derived.source} 有 ${derived.count} 条`);
    return;
  }
  if (current > derived.count) {
    errors.push(`${slide.label || slide.layout}: ${control.key}=${current},但 ${derived.source} 只有 ${derived.count} 条`);
  }
  const min = Number(control.min);
  const max = Number(control.max);
  if (Number.isFinite(min) && current < min) {
    errors.push(`${slide.label || slide.layout}: ${control.key}=${current} 小于最小值 ${min}`);
  }
  if (Number.isFinite(max) && current > max) {
    errors.push(`${slide.label || slide.layout}: ${control.key}=${current} 大于最大值 ${max}`);
  }
}

function readJsonScript(html, id) {
  const match = html.match(new RegExp(`<script[^>]*id="${id}"[^>]*>([\\s\\S]*?)<\\/script>`));
  if (!match) return null;
  try {
    return JSON.parse(match[1]);
  } catch {
    return null;
  }
}

function getSlideSections(html) {
  const sections = [];
  for (const match of html.matchAll(/<section\b[\s\S]*?<\/section>/g)) {
    const markup = match[0];
    const id = getAttr(markup, 'data-vm-slide-id');
    if (!id) continue;
    sections.push({
      id,
      sourceSlideId: getAttr(markup, 'data-vm-source-slide-id'),
      stateId: getAttr(markup, 'data-vm-variant-state-id'),
      variantId: getAttr(markup, 'data-vm-variant-id'),
      markup,
    });
  }
  return sections;
}

function findSlideSection(sections, logicalSlide, candidate) {
  const sourceSlideId = String(
    candidate?.sourceSlideId
      || logicalSlide?.sourceSlideId
      || logicalSlide?.id
      || '',
  );
  const variantId = String(candidate?.variantId || candidate?.id || '');
  const stateId = String(
    candidate?.stateId
      || (sourceSlideId && variantId ? `${sourceSlideId}::${variantId}` : ''),
  );
  const exact = sections.find(section => (
    (stateId && (section.id === stateId || section.stateId === stateId))
    || (candidate?.id && section.id === candidate.id && section.sourceSlideId === sourceSlideId)
  ));
  if (exact) return exact.markup;

  const grouped = sections.find(section => (
    section.sourceSlideId === sourceSlideId
    && (!section.variantId || !variantId || section.variantId === variantId)
  ));
  if (grouped) return grouped.markup;

  const legacy = sections.find(section => section.id === logicalSlide?.id);
  return legacy?.markup || '';
}

function readPropControls(section) {
  const raw = getAttr(section, 'data-prop-controls');
  if (!raw) return [];
  try {
    return JSON.parse(decodeEntities(raw));
  } catch {
    return [];
  }
}

function getAttr(markup, name) {
  const match = markup.match(new RegExp(`${name}="([^"]*)"`));
  return match ? match[1] : '';
}
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