code-simplifier
Code-Simplifier持续改进系统 - 自动化的代码质量监控、持续改进和知识管理工具(支持 ESLint、Git 钩子、自动修复、多语言分析、完整测试套件、AI驱动分析)
Last updated 2 months ago by flowerjunjie .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install code-simplifier 
SYNC missed versions from official npm registry.

Code-Simplifier

代码质量持续改进系统 - 零配置,即刻使用

npm version License: MIT

特性

  • 零配置 - 开箱即用,无需复杂设置
  • 质量监控 - 实时监控代码质量指标
  • 知识库管理 - 积累最佳实践和经验教训
  • 自动更新 - 保持工具始终最新
  • 多语言支持 - 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 --demo

quality - 质量分析

# 分析代码质量
npx code-simplifier quality

# 指定目录
npx code-simplifier quality --dir src

# 设置质量阈值
npx code-simplifier quality --threshold 80

# 输出JSON格式
npx code-simplifier quality --report json

monitor - 实时监控

# 启动监控仪表板
npx code-simplifier monitor

# 自定义端口
npx code-simplifier monitor --port 8080

# 设置检查间隔(毫秒)
npx code-simplifier monitor --interval 60000

workflow - 完整工作流

# 运行完整改进工作流
npx code-simplifier workflow

# 启用所有步骤
npx code-simplifier workflow --all

# 显示当前状态
npx code-simplifier workflow --status

knowledge - 知识库

# 查看知识库统计
npx code-simplifier knowledge

# 添加成功案例
npx code-simplifier knowledge --add success

# 搜索知识库
npx code-simplifier knowledge --search "性能优化"

# 导出知识库
npx code-simplifier knowledge --export backup.json

report - 报告生成

# 生成日报
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

config - 配置管理

# 查看所有配置
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

update - 更新工具

# 检查更新
npx code-simplifier update

# 强制更新
npx code-simplifier update --force

eslint - ESLint 代码分析

# 运行 ESLint 分析
npx code-simplifier eslint

# 自动修复可修复的问题
npx code-simplifier eslint --fix

# 输出 JSON 格式
npx code-simplifier eslint --format json

hooks - Git 钩子管理

# 交互式安装 Git 钩子
npx code-simplifier hooks

# 安装 pre-commit 和 pre-push 钩子
npx code-simplifier hooks --install

# 列出已安装的钩子
npx code-simplifier hooks --list

# 卸载钩子
npx code-simplifier hooks --uninstall

autofix - 自动修复

# 自动修复代码问题
npx code-simplifier autofix

# 预览模式(不实际修改文件)
npx code-simplifier autofix --dry-run

# 指定目录
npx code-simplifier autofix --dir src

lang - 多语言分析

# 分析项目中的多种语言
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.js

Q: 如何集成到 CI/CD?

# GitHub Actions 示例
- name: Code Quality Check
  run: npx code-simplifier quality --threshold 70

Q: 监控服务无法启动?

检查端口是否被占用:

npx code-simplifier monitor --port 8080

更新日志

v1.0.0

  • 初始版本发布
  • 支持质量分析、监控、知识库、报告生成
  • 多语言项目支持

贡献

欢迎提交 Issue 和 Pull Request!

许可证

MIT License - 详见 LICENSE 文件

Current Tags

  • 1.2.1                                ...           latest (2 months ago)

4 Versions

  • 1.2.1                                ...           2 months ago
  • 1.2.0                                ...           2 months ago
  • 1.1.0                                ...           3 months ago
  • 1.0.0                                ...           3 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (12)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org | Home |