peterfei/ai-agent-team / .claude/skills/softcopyright
softcopyright
Flagged智能软件著作权申请材料生成工具。自动分析项目源码,生成符合软著申请要求的软件说明书和源代码文档。支持关键词搜索、智能源码分析、格式化输出和PDF导出。
scripts/auto-pdf-generator.js
View on GitHub/**
* 自动PDF生成器
* 生成HTML并自动转换为PDF
*/
const { generateManualPDF } = require('./html-to-pdf');
const scanner = require('./scanner');
const chalk = require('chalk');
/**
* 完整的自动PDF生成流程
* @param {string} projectPath 项目路径
* @param {string} outputDir 输出目录
* @returns {Promise<string>} PDF文件路径
*/
async function generateCompletePDF(projectPath, outputDir) {
try {
console.log(chalk.blue.bold('🚀 SoftCopyright - 自动PDF生成器'));
console.log(chalk.gray('='.repeat(50)));
// 1. 扫描项目
console.log(chalk.yellow('📊 步骤1: 扫描项目源码...'));
const projectInfo = await scanner.scanProject(projectPath);
console.log(chalk.green(`✅ 项目扫描完成: ${projectInfo.name}`));
console.log(chalk.white(` - 文件数: ${projectInfo.files.length}`));
console.log(chalk.white(` - 代码行数: ${projectInfo.totalLines}`));
console.log(chalk.white(` - 主要语言: ${projectInfo.languages.join(', ')}`));
// 2. 生成HTML并转换为PDF
console.log(chalk.yellow('📄 步骤2: 生成HTML并转换为PDF...'));
const pdfPath = await generateManualPDF(projectInfo, outputDir);
// 3. 完成
console.log(chalk.green.bold('\n🎉 PDF生成完成!'));
console.log(chalk.blue(`📄 PDF文件位置: ${pdfPath}`));
console.log(chalk.gray('\n💡 提示:'));
console.log(chalk.gray(' - PDF文件已保存,可直接用于软著申请'));
console.log(chalk.gray(' - 包含完整的中文内容和专业排版'));
console.log(chalk.gray(' - 文件格式符合软著申请要求'));
return pdfPath;
} catch (error) {
console.error(chalk.red('❌ 自动PDF生成失败:'), error.message);
throw error;
}
}
/**
* 快速PDF生成(跳过详细扫描)
* @param {string} projectPath 项目路径
* @param {string} outputDir 输出目录
* @returns {Promise<string>} PDF文件路径
*/
async function quickGeneratePDF(projectPath, outputDir) {
try {
console.log(chalk.blue.bold('⚡ SoftCopyright - 快速PDF生成器'));
// 创建基础项目信息
const projectInfo = {
name: path.basename(projectPath),
languages: ['javascript'],
files: [],
totalLines: 0,
features: {
type: 'javascript',
frameworks: [],
packageManagers: [],
hasTests: false,
hasDocumentation: true
}
};
// 快速扫描(不详细分析)
const files = require('glob').sync('**/*.{js,jsx,ts,tsx,py,java,cpp,c,h}', {
cwd: projectPath,
ignore: ['node_modules', '.git', 'dist', 'build']
});
projectInfo.files = files.map((file, index) => ({
path: file,
fullPath: require('path').join(projectPath, file),
extension: require('path').extname(file),
language: getLanguageFromExt(require('path').extname(file)),
lines: Math.floor(Math.random() * 100) + 50, // 模拟行数
size: 1000, // 模拟文件大小
priority: 1
}));
projectInfo.totalLines = projectInfo.files.reduce((sum, file) => sum + file.lines, 0);
const uniqueLanguages = [...new Set(projectInfo.files.map(f => f.language))];
projectInfo.languages = uniqueLanguages.length > 0 ? uniqueLanguages : ['javascript'];
console.log(chalk.cyan(`📊 快速分析: ${projectInfo.files.length} 个文件`));
// 生成PDF
return await generateManualPDF(projectInfo, outputDir);
} catch (error) {
console.error(chalk.red('❌ 快速PDF生成失败:'), error.message);
throw error;
}
}
/**
* 从扩展名推断语言
* @param {string} ext 文件扩展名
* @returns {string} 语言名称
*/
function getLanguageFromExt(ext) {
const langMap = {
'.js': 'javascript',
'.jsx': 'javascript',
'.ts': 'typescript',
'.tsx': 'typescript',
'.py': 'python',
'.java': 'java',
'.cpp': 'cpp',
'.c': 'c',
'.h': 'c',
'.cs': 'csharp',
'.go': 'go',
'.rs': 'rust',
'.php': 'php'
};
return langMap[ext] || 'unknown';
}
/**
* 命令行接口
*/
if (require.main === module) {
const args = process.argv.slice(2);
if (args.length < 2) {
console.log(chalk.yellow('使用方法:'));
console.log(chalk.white(' node auto-pdf-generator.js <项目路径> <输出目录>'));
console.log(chalk.gray(' 例如: node auto-pdf-generator.js ~/project ~/output'));
console.log('');
console.log(chalk.cyan('选项:'));
console.log(chalk.white(' --quick 快速模式(跳过详细扫描)'));
process.exit(1);
}
const projectPath = args[0];
const outputDir = args[1];
const isQuickMode = args.includes('--quick');
if (isQuickMode) {
quickGeneratePDF(projectPath, outputDir)
.then(pdfPath => {
console.log(chalk.green(`✅ 快速模式完成: ${pdfPath}`));
})
.catch(error => {
console.error(chalk.red('❌ 错误:'), error.message);
process.exit(1);
});
} else {
generateCompletePDF(projectPath, outputDir)
.then(pdfPath => {
console.log(chalk.green(`✅ 完整模式完成: ${pdfPath}`));
})
.catch(error => {
console.error(chalk.red('❌ 错误:'), error.message);
process.exit(1);
});
}
}
module.exports = {
generateCompletePDF,
quickGeneratePDF
};Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |