Skip to content

peterfei/ai-agent-team / .claude/skills/softcopyright

softcopyright

Flagged

智能软件著作权申请材料生成工具。自动分析项目源码,生成符合软著申请要求的软件说明书和源代码文档。支持关键词搜索、智能源码分析、格式化输出和PDF导出。

FileKindSize
.npmignoreother14 B
CHANGELOG.mdmarkdown6.8 KB
IMPLEMENTATION_REPORT.mdmarkdown7.5 KB
LICENSEother1.0 KB
PERFORMANCE_OPTIMIZATION.mdmarkdown4.0 KB
PERFORMANCE_OPTIMIZATION_SUMMARY.mdmarkdown7.8 KB
PERFORMANCE_QUICK_START.mdmarkdown6.6 KB
README.mdmarkdown6.5 KB
SKILL.mdskill md7.6 KB
TESTING_GUIDE.mdmarkdown11.4 KB
USAGE_EXAMPLES.mdmarkdown8.4 KB
demo-keywords.mdmarkdown2.5 KB
install.shexecutablescript1.5 KB
package-lock.jsonmanifest122.7 KB
package.jsonmanifest1.1 KB
scripts/auto-pdf-generator.jsscript5.2 KB
scripts/auto-print-pdf.jsscript7.1 KB
scripts/chinese-pdf-fix.jsscript4.0 KB
scripts/cli.jsexecutablescript5.9 KB
scripts/doc-generator-english.jsscript13.2 KB
scripts/doc-generator-new.jsscript624 B
scripts/doc-generator.jsscript28.1 KB
scripts/font-manager.jsscript5.7 KB
scripts/html-pdf-generator.jsscript17.3 KB
scripts/html-source-exporter.jsscript30.8 KB
scripts/html-to-pdf.jsscript5.6 KB
scripts/index.jsscript17.3 KB
scripts/index.js.pdf-backupother12.3 KB
scripts/run.batscript463 B
scripts/run.shexecutablescript893 B
scripts/scanner-optimized.jsscript21.9 KB
scripts/scanner.jsscript22.2 KB
scripts/simple-doc-generator.jsscript25.9 KB
scripts/simple-pdf-generator.jsscript14.4 KB
scripts/simple-source-exporter.jsscript4.6 KB
scripts/source-exporter.jsscript13.1 KB
scripts/system-chrome-pdf.jsscript7.0 KB
scripts/utils-optimized.jsscript4.8 KB
scripts/utils.jsscript9.2 KB
softcopyrightexecutablescript150 B
softcopyright-generateexecutablescript168 B
softcopyright-generate.batscript194 B
softcopyright-manualexecutablescript169 B
softcopyright-manual.batscript195 B
softcopyright-sourceexecutablescript169 B
softcopyright-source.batscript195 B
softcopyright.batscript176 B
templates/software-manual.mdmarkdown6.0 KB
test-auto-pdf.jsscript636 B
test-clean-header-footer.jsscript2.3 KB
test-complete.jsscript848 B
test-counter-fix.jsexecutablescript2.3 KB
test-fixed-page-number.jsscript2.4 KB
test-html-generation.jsscript2.9 KB
test-html.jsscript732 B
test-no-border.jsscript1.8 KB
test-pdf.jsscript639 B
test-performance.jsexecutablescript4.9 KB

scripts/font-manager.js

View on GitHub
const fs = require('fs-extra');
const path = require('path');
const https = require('https');
const http = require('http');
const chalk = require('chalk');

/**
 * 字体管理器
 * 处理中文字体的下载和管理
 */
class FontManager {
  constructor() {
    this.fontsDir = path.join(__dirname, '..', 'fonts');
    this.defaultFont = 'NotoSansCJK-Regular';
  }

  /**
   * 初始化字体
   * @returns {Promise<string>} 字体文件路径
   */
  async initFont() {
    await this.ensureFontsDir();

    // 尝试下载字体
    const fontPath = await this.downloadFont();

    if (fontPath) {
      console.log(chalk.green('✅ 中文字体加载成功'));
      return fontPath;
    } else {
      console.log(chalk.yellow('⚠️  使用系统字体'));
      return null;
    }
  }

  /**
   * 确保字体目录存在
   */
  async ensureFontsDir() {
    await fs.ensureDir(this.fontsDir);
  }

  /**
   * 下载中文字体
   * @returns {Promise<string|null>} 字体文件路径
   */
  async downloadFont() {
    const fonts = [
      {
        name: 'NotoSansCJK-Regular',
        url: 'https://fonts.gstatic.com/s/notosanssc/v35/k3kXo84MPvpLmixcA63oeALZTYKL2S24UEg-2_c.woff2',
        filename: 'NotoSansCJK-Regular.woff2'
      },
      {
        name: 'NotoSansSC-Regular',
        url: 'https://fonts.gstatic.com/s/notosanssc/v35/k3kXo84MPvpLmixcA63oeALZTYKL2S24UEg-2_c.woff2',
        filename: 'NotoSansSC-Regular.woff2'
      },
      {
        // 备选方案:使用开源中文字体
        name: 'SourceHanSans-Regular',
        url: 'https://github.com/adobe-fonts/source-han-sans/releases/download/2.004R/SourceHanSansSC-Regular.otf',
        filename: 'SourceHanSansSC-Regular.otf'
      }
    ];

    for (const font of fonts) {
      const fontPath = path.join(this.fontsDir, font.filename);

      // 如果字体已存在,直接返回
      if (await fs.pathExists(fontPath)) {
        console.log(chalk.cyan(`📁 使用已存在的字体: ${font.name}`));
        return fontPath;
      }

      // 尝试下载字体
      console.log(chalk.blue(`📥 下载字体: ${font.name}`));

      try {
        await this.downloadFile(font.url, fontPath);
        console.log(chalk.green(`✅ 字体下载成功: ${font.name}`));
        return fontPath;
      } catch (error) {
        console.warn(chalk.yellow(`⚠️  下载 ${font.name} 失败: ${error.message}`));
        continue;
      }
    }

    // 如果所有字体都下载失败,尝试复制系统字体
    return await this.copySystemFont();
  }

  /**
   * 复制系统字体
   * @returns {Promise<string|null>} 字体文件路径
   */
  async copySystemFont() {
    const systemFonts = [
      '/System/Library/Fonts/STHeiti Medium.ttc',
      '/System/Library/Fonts/STHeiti Light.ttc',
      '/System/Library/Fonts/PingFang.ttc',
      '/System/Library/Fonts/Hiragino Sans GB.ttc',
      '/Windows/Fonts/msyh.ttc',
      '/Windows/Fonts/simhei.ttf',
      '/usr/share/fonts/truetype/wqy/wqy-microhei.ttc'
    ];

    for (const systemFont of systemFonts) {
      if (await fs.pathExists(systemFont)) {
        try {
          const fontName = path.basename(systemFont);
          const targetPath = path.join(this.fontsDir, fontName);

          await fs.copy(systemFont, targetPath);
          console.log(chalk.green(`✅ 系统字体复制成功: ${fontName}`));
          return targetPath;
        } catch (error) {
          console.warn(chalk.yellow(`⚠️  复制系统字体失败: ${systemFont}`));
          continue;
        }
      }
    }

    return null;
  }

  /**
   * 下载文件
   * @param {string} url 下载链接
   * @param {string} targetPath 目标路径
   * @returns {Promise<void>}
   */
  async downloadFile(url, targetPath) {
    return new Promise((resolve, reject) => {
      const protocol = url.startsWith('https') ? https : http;

      const fileStream = fs.createWriteStream(targetPath);

      protocol.get(url, (response) => {
        if (response.statusCode !== 200) {
          reject(new Error(`HTTP ${response.statusCode}: ${response.statusMessage}`));
          return;
        }

        response.pipe(fileStream);

        fileStream.on('finish', () => {
          fileStream.close();
          resolve();
        });

        fileStream.on('error', (error) => {
          fs.unlink(targetPath, () => {}); // 删除不完整的文件
          reject(error);
        });

      }).on('error', (error) => {
        reject(error);
      });
    });
  }

  /**
   * 获取字体路径
   * @returns {Promise<string|null>}
   */
  async getFontPath() {
    const fontFiles = await fs.readdir(this.fontsDir);

    for (const file of fontFiles) {
      if (file.match(/\.(ttf|otf|woff|woff2)$/i)) {
        return path.join(this.fontsDir, file);
      }
    }

    return await this.initFont();
  }

  /**
   * 清理旧字体文件
   */
  async cleanupOldFonts() {
    try {
      const files = await fs.readdir(this.fontsDir);
      const maxSize = 5; // 最多保留5个字体文件

      if (files.length > maxSize) {
        // 按修改时间排序,删除最旧的文件
        const fileStats = await Promise.all(
          files.map(async (file) => {
            const filePath = path.join(this.fontsDir, file);
            const stats = await fs.stat(filePath);
            return { file, filePath, mtime: stats.mtime };
          })
        );

        fileStats.sort((a, b) => a.mtime - b.mtime);

        // 删除最旧的文件
        for (let i = 0; i < fileStats.length - maxSize; i++) {
          await fs.remove(fileStats[i].filePath);
          console.log(chalk.gray(`🗑️  删除旧字体: ${fileStats[i].file}`));
        }
      }
    } catch (error) {
      console.warn(chalk.yellow('⚠️  清理字体文件失败:'), error.message);
    }
  }
}

module.exports = FontManager;
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