Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (code-simplifier) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Code-Simplifier
代码质量持续改进系统 - 零配置,即刻使用
特性
- 零配置 - 开箱即用,无需复杂设置
- 质量监控 - 实时监控代码质量指标
- 知识库管理 - 积累最佳实践和经验教训
- 自动更新 - 保持工具始终最新
- 多语言支持 - JavaScript、TypeScript、Python、Java、C#、C++、PHP、Go、Rust、Kotlin、Swift
- ESLint 集成 - 自动运行 ESLint 分析和修复
- Git 钩子 - 自动安装 pre-commit 和 pre-push 钩子
- 自动修复 - 智能修复常见代码问题
快速开始
使用 npx (推荐)
# 直接运行,无需安装
npx code-simplifier
# 初始化项目
npx code-simplifier init
# 运行质量检查
npx code-simplifier quality全局安装
npm install -g code-simplifier
# 使用简写命令
cs quality
cs monitor命令
init - 初始化
# 初始化配置
npx code-simplifier init
# 带演示模式
npx code-simplifier init --demoquality - 质量分析
# 分析代码质量
npx code-simplifier quality
# 指定目录
npx code-simplifier quality --dir src
# 设置质量阈值
npx code-simplifier quality --threshold 80
# 输出JSON格式
npx code-simplifier quality --report jsonmonitor - 实时监控
# 启动监控仪表板
npx code-simplifier monitor
# 自定义端口
npx code-simplifier monitor --port 8080
# 设置检查间隔(毫秒)
npx code-simplifier monitor --interval 60000workflow - 完整工作流
# 运行完整改进工作流
npx code-simplifier workflow
# 启用所有步骤
npx code-simplifier workflow --all
# 显示当前状态
npx code-simplifier workflow --statusknowledge - 知识库
# 查看知识库统计
npx code-simplifier knowledge
# 添加成功案例
npx code-simplifier knowledge --add success
# 搜索知识库
npx code-simplifier knowledge --search "性能优化"
# 导出知识库
npx code-simplifier knowledge --export backup.jsonreport - 报告生成
# 生成日报
npx code-simplifier report
# 生成周报
npx code-simplifier report --type weekly
# 生成月报
npx code-simplifier report --type monthly
# 指定输出路径
npx code-simplifier report --output ./reports/my-report.mdconfig - 配置管理
# 查看所有配置
npx code-simplifier config
# 获取特定配置
npx code-simplifier config --get quality.threshold
# 设置配置值
npx code-simplifier config --set quality.threshold --value 80
# 重置配置
npx code-simplifier config --reset
# 交互式配置
npx code-simplifier config --interactiveupdate - 更新工具
# 检查更新
npx code-simplifier update
# 强制更新
npx code-simplifier update --forceeslint - ESLint 代码分析
# 运行 ESLint 分析
npx code-simplifier eslint
# 自动修复可修复的问题
npx code-simplifier eslint --fix
# 输出 JSON 格式
npx code-simplifier eslint --format jsonhooks - Git 钩子管理
# 交互式安装 Git 钩子
npx code-simplifier hooks
# 安装 pre-commit 和 pre-push 钩子
npx code-simplifier hooks --install
# 列出已安装的钩子
npx code-simplifier hooks --list
# 卸载钩子
npx code-simplifier hooks --uninstallautofix - 自动修复
# 自动修复代码问题
npx code-simplifier autofix
# 预览模式(不实际修改文件)
npx code-simplifier autofix --dry-run
# 指定目录
npx code-simplifier autofix --dir srclang - 多语言分析
# 分析项目中的多种语言
npx code-simplifier lang
# 指定目录
npx code-simplifier lang --dir src配置文件
配置存储在 .code-simplifier/config.json:
{
"quality": {
"threshold": 70,
"autoFix": false,
"reportFormat": "md"
},
"monitor": {
"port": 3000,
"interval": 300000,
"autoOpen": true
},
"update": {
"autoCheck": true,
"channel": "stable"
},
"report": {
"outputDir": "reports",
"openAfterGenerate": false
},
"knowledge": {
"dataDir": ".code-simplifier",
"autoUpdate": true
}
}工作流程
┌─────────────────────────────────────────────────────────────┐
│ Code-Simplifier 工作流 │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ 质量分析 │───▶│ 趋势跟踪 │───▶│ 预警检查 │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌──────────┐ ┌──────────┐ │
│ │ 报告生成 │ │ 知识更新 │ │
│ └──────────┘ └──────────┘ │
│ │ │ │
│ └────────────┬───────────────────┘ │
│ ▼ │
│ ┌──────────┐ │
│ │ 持续改进 │ │
│ └──────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘API 端点
监控服务提供以下 REST API:
| 端点 | 方法 | 描述 |
|---|---|---|
/api/status |
GET | 获取当前质量状态 |
/api/trend |
GET | 获取趋势数据 |
/api/alerts |
GET | 获取预警信息 |
项目结构
code-simplifier/
├── bin/
│ └── code-simplifier.js # CLI 入口
├── lib/
│ ├── master.js # 主控制器
│ ├── quality-monitor.js # 质量监控
│ ├── quality-analyzer.js # 质量分析
│ ├── knowledge-base.js # 知识库
│ ├── improvement.js # 持续改进
│ ├── report-generator.js # 报告生成
│ ├── auto-update.js # 自动更新
│ └── config.js # 配置管理
├── package.json
└── README.md支持的项目类型
| 类型 | 检测文件 | 扫描模式 |
|---|---|---|
| Node.js | package.json |
*.js, *.ts, *.jsx, *.tsx |
| Java | pom.xml |
*.java |
| Python | requirements.txt |
*.py |
| Rust | Cargo.toml |
*.rs |
| Go | go.mod |
*.go |
质量评分标准
| 评分 | 等级 | 说明 |
|---|---|---|
| 90-100 | 优秀 | 代码质量很高,继续保持 |
| 80-89 | 良好 | 代码质量良好,可继续优化 |
| 70-79 | 一般 | 代码质量一般,建议改进 |
| 60-69 | 较差 | 代码质量较差,需要改进 |
| <60 | 很差 | 代码质量很差,急需改进 |
常见问题
Q: 如何忽略某些文件?
在项目根目录创建 .code-simplifier-ignore 文件:
node_modules/
dist/
coverage/
*.min.jsQ: 如何集成到 CI/CD?
# GitHub Actions 示例
- name: Code Quality Check
run: npx code-simplifier quality --threshold 70Q: 监控服务无法启动?
检查端口是否被占用:
npx code-simplifier monitor --port 8080更新日志
v1.0.0
- 初始版本发布
- 支持质量分析、监控、知识库、报告生成
- 多语言项目支持
贡献
欢迎提交 Issue 和 Pull Request!
许可证
MIT License - 详见 LICENSE 文件