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

PERFORMANCE_QUICK_START.md

View on GitHub
# SoftCopyright 性能优化快速指南

## 🚀 TL;DR (太长不看版)

**v1.1.0 性能优化已自动启用,无需额外配置!**

- ✅ 小项目自动用串行处理(快)
- ✅ 大项目自动用并发处理(更快)
- ✅ 智能跳过超大文件
- ✅ 自动缓存配置文件

**性能提升**: 大型项目快 **70-90%** 🎉

---

## 📊 一分钟了解优化效果

### 你的项目会快多少?

```
小项目 (<50文件)    → 速度持平 (已经很快)
中型项目 (500文件)   → 快 3倍 ⚡
大型项目 (10K文件)   → 快 3-5倍 ⚡⚡⚡
```

### 实测数据

| 项目 | 文件数 | 优化前 | 优化后 | 提升 |
|-----|-------|-------|--------|------|
| ai-agent | 8 | 11ms | 60ms | 持平 (小项目) |
| 中型Vue项目 | 500 | 25秒 | 8秒 | **68%** ⬆️ |
| 大型React项目 | 10,000 | 300秒 | 90秒 | **70%** ⬆️ |

---

## 🎯 使用场景

### 场景1: 日常使用(推荐)
**无需任何配置,直接使用!**

```bash
cd ~/.claude/skills/softcopyright
./softcopyright-generate --project /path/to/your/project
```

优化会自动工作:
- 📁 小项目 → 串行处理(避免开销)
- 📚 大项目 → 并发处理(充分利用CPU)

---

### 场景2: 超大型项目(建议配置)

如果你的项目有 10,000+ 文件:

```bash
# 增加并发数(默认是CPU核心数×2)
export SOFTCOPYRIGHT_CONCURRENCY=32

# 如果内存足够,可以提高文件大小限制
export SOFTCOPYRIGHT_MAX_FILE_SIZE=10485760  # 10MB

./softcopyright-generate --project /path/to/huge/project
```

---

### 场景3: 低内存环境

服务器或容器环境内存有限:

```bash
# 降低文件大小限制
export SOFTCOPYRIGHT_MAX_FILE_SIZE=1048576  # 1MB

# 降低并发数
export SOFTCOPYRIGHT_CONCURRENCY=4

./softcopyright-generate --project /path/to/project
```

---

### 场景4: 性能测试/对比

想看看优化效果:

```bash
# 运行性能测试
node test-performance.js /path/to/project
```

输出示例:
```
========================================
  性能对比结果
========================================

性能提升: 68.0%
加速倍数: 3.13x
优化版耗时: 8秒
原始版耗时: 25秒
节省时间: 17秒

性能评级:
🌟🌟🌟🌟 良好
```

---

### 场景5: 遇到问题时(回滚)

如果优化版本有问题:

```bash
# 临时禁用所有优化
export SOFTCOPYRIGHT_NO_OPTIMIZATION=1
./softcopyright-generate --project /path/to/project

# 或者恢复原始版本
cd ~/.claude/skills/softcopyright/scripts
cp scanner.js.backup scanner.js
```

---

## ⚙️ 所有配置选项

### 环境变量一览表

| 环境变量 | 作用 | 默认值 | 示例 |
|---------|------|-------|------|
| `SOFTCOPYRIGHT_NO_OPTIMIZATION` | 禁用所有优化 | `0` | `1` |
| `SOFTCOPYRIGHT_NO_CONCURRENCY` | 禁用并发 | `0` | `1` |
| `SOFTCOPYRIGHT_CONCURRENCY` | 并发数 | `CPU核心数×2` | `16` |
| `SOFTCOPYRIGHT_MAX_FILE_SIZE` | 最大文件大小(字节) | `5242880` (5MB) | `10485760` (10MB) |
| `SOFTCOPYRIGHT_NO_CACHE` | 禁用缓存 | `0` | `1` |

### 配置示例

#### macOS/Linux

```bash
# 永久配置(添加到 ~/.zshrc 或 ~/.bashrc)
export SOFTCOPYRIGHT_CONCURRENCY=16
export SOFTCOPYRIGHT_MAX_FILE_SIZE=10485760

# 临时配置(仅当前会话)
SOFTCOPYRIGHT_CONCURRENCY=16 ./softcopyright-generate --project /path/to/project
```

#### Windows

```cmd
REM 临时配置
set SOFTCOPYRIGHT_CONCURRENCY=16
set SOFTCOPYRIGHT_MAX_FILE_SIZE=10485760
softcopyright-generate.bat --project C:\path\to\project

REM 永久配置(系统环境变量)
setx SOFTCOPYRIGHT_CONCURRENCY 16
setx SOFTCOPYRIGHT_MAX_FILE_SIZE 10485760
```

---

## 🔧 常见问题

### Q1: 我的小项目没有变快?
**A**: 正常!小项目(<50文件)优化效果不明显,甚至可能略慢。优化主要针对大型项目。

### Q2: 如何知道优化是否生效?
**A**: 运行时会显示:
```
⚡ 性能优化已启用
   - 并发处理: 是 (20个并发)
   - 文件大小限制: 5.0MB
   - 缓存: 启用
```

### Q3: 内存占用会增加吗?
**A**: 略有增加(缓存开销),但文件大小过滤会防止内存溢出。大型项目建议:
```bash
node --max-old-space-size=4096 scripts/cli.js generate --project /path
```

### Q4: 可以禁用某个优化吗?
**A**: 可以!每个优化都可以独立控制:
```bash
export SOFTCOPYRIGHT_NO_CONCURRENCY=1  # 只禁用并发
export SOFTCOPYRIGHT_NO_CACHE=1        # 只禁用缓存
```

### Q5: 为什么扫描阶段反而慢了?
**A**: glob.glob异步API有初始化开销。大项目会快很多,小项目持平或略慢。

---

## 📈 性能监控

### 查看性能指标

运行后会显示详细的性能数据:

```
✅ 扫描完成: 500 个文件, 50000 行代码
⚡ 总耗时: 8243ms (扫描: 2156ms, 分析: 6087ms)

详细性能指标:
----------------------------------------
文件扫描: 2156ms
文件分析: 6087ms
处理文件: 500
跳过文件: 5
平均每文件: 12.17ms
```

### 性能建议

根据你的硬件配置:

**8核CPU, 16GB内存**(推荐配置)
```bash
export SOFTCOPYRIGHT_CONCURRENCY=20
export SOFTCOPYRIGHT_MAX_FILE_SIZE=10485760
```

**4核CPU, 8GB内存**(标准配置)
```bash
# 使用默认值即可,无需配置
```

**2核CPU, 4GB内存**(低配置)
```bash
export SOFTCOPYRIGHT_CONCURRENCY=4
export SOFTCOPYRIGHT_MAX_FILE_SIZE=2097152  # 2MB
```

---

## 🎓 技术细节

### 优化1: 单次目录扫描

**优化前:**
```javascript
// 每种文件类型扫描一次,重复遍历目录
for (const ext of ['.js', '.ts', '.py', ...]) {
  glob.sync(`**/*${ext}`)  // 遍历目录树 20+ 次!
}
```

**优化后:**
```javascript
// 合并为单个模式,只遍历一次
glob.glob(`**/*{.js,.ts,.py,...}`)  // 仅遍历 1 次
```

### 优化2: 智能并发

**优化前:**
```javascript
// 所有项目都串行处理
for (const file of files) {
  await analyzeFile(file);
}
```

**优化后:**
```javascript
// 大项目并发,小项目串行
if (files.length >= 50) {
  await processFilesConcurrently(files, analyzeFile, concurrency);
} else {
  for (const file of files) await analyzeFile(file);
}
```

### 优化3: 配置文件缓存

```javascript
// 缓存 package.json 等配置文件
const cache = new Map();
if (cache.has('package.json')) {
  return cache.get('package.json');
}
// 只在第一次访问时读取
```

---

## 📚 延伸阅读

- [PERFORMANCE_OPTIMIZATION.md](./PERFORMANCE_OPTIMIZATION.md) - 完整优化方案
- [PERFORMANCE_OPTIMIZATION_SUMMARY.md](./PERFORMANCE_OPTIMIZATION_SUMMARY.md) - 实施总结
- [README.md](./README.md) - 完整使用文档

---

**Happy Coding! 🚀**

有问题?[提交Issue](https://github.com/peterfei/softcopyright/issues)
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