Code-Simplifier持续改进系统 - 自动化的代码质量监控、持续改进和知识管理工具(支持 ESLint、Git 钩子、自动修复、多语言分析、完整测试套件、AI驱动分析)
npm install code-simplifierbash
直接运行,无需安装
npx code-simplifier
初始化项目
npx code-simplifier init
运行质量检查
npx code-simplifier quality
`
$3
`bash
npm install -g code-simplifier
使用简写命令
cs quality
cs monitor
`
命令
$3
`bash
初始化配置
npx code-simplifier init
带演示模式
npx code-simplifier init --demo
`
$3
`bash
分析代码质量
npx code-simplifier quality
指定目录
npx code-simplifier quality --dir src
设置质量阈值
npx code-simplifier quality --threshold 80
输出JSON格式
npx code-simplifier quality --report json
`
$3
`bash
启动监控仪表板
npx code-simplifier monitor
自定义端口
npx code-simplifier monitor --port 8080
设置检查间隔(毫秒)
npx code-simplifier monitor --interval 60000
`
$3
`bash
运行完整改进工作流
npx code-simplifier workflow
启用所有步骤
npx code-simplifier workflow --all
显示当前状态
npx code-simplifier workflow --status
`
$3
`bash
查看知识库统计
npx code-simplifier knowledge
添加成功案例
npx code-simplifier knowledge --add success
搜索知识库
npx code-simplifier knowledge --search "性能优化"
导出知识库
npx code-simplifier knowledge --export backup.json
`
$3
`bash
生成日报
npx code-simplifier report
生成周报
npx code-simplifier report --type weekly
生成月报
npx code-simplifier report --type monthly
指定输出路径
npx code-simplifier report --output ./reports/my-report.md
`
$3
`bash
查看所有配置
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 --interactive
`
$3
`bash
检查更新
npx code-simplifier update
强制更新
npx code-simplifier update --force
`
$3
`bash
运行 ESLint 分析
npx code-simplifier eslint
自动修复可修复的问题
npx code-simplifier eslint --fix
输出 JSON 格式
npx code-simplifier eslint --format json
`
$3
`bash
交互式安装 Git 钩子
npx code-simplifier hooks
安装 pre-commit 和 pre-push 钩子
npx code-simplifier hooks --install
列出已安装的钩子
npx code-simplifier hooks --list
卸载钩子
npx code-simplifier hooks --uninstall
`
$3
`bash
自动修复代码问题
npx code-simplifier autofix
预览模式(不实际修改文件)
npx code-simplifier autofix --dry-run
指定目录
npx code-simplifier autofix --dir src
`
$3
`bash
分析项目中的多种语言
npx code-simplifier lang
指定目录
npx code-simplifier lang --dir src
`
配置文件
配置存储在 .code-simplifier/config.json:
`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 | 很差 | 代码质量很差,急需改进 |
常见问题
$3
在项目根目录创建 .code-simplifier-ignore 文件:
`
node_modules/
dist/
coverage/
*.min.js
`
$3
`yaml
GitHub Actions 示例
- name: Code Quality Check
run: npx code-simplifier quality --threshold 70
`
$3
检查端口是否被占用:
`bash
npx code-simplifier monitor --port 8080
``