code-simplifier 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +302 -0
- package/bin/code-simplifier.js +216 -0
- package/lib/auto-update.js +256 -0
- package/lib/config.js +258 -0
- package/lib/improvement.js +298 -0
- package/lib/knowledge-base.js +254 -0
- package/lib/master.js +359 -0
- package/lib/quality-analyzer.js +327 -0
- package/lib/quality-monitor.js +397 -0
- package/lib/report-generator.js +254 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Code-Simplifier Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# Code-Simplifier
|
|
2
|
+
|
|
3
|
+
> 代码质量持续改进系统 - 零配置,即刻使用
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/code-simplifier)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## 特性
|
|
9
|
+
|
|
10
|
+
- **零配置** - 开箱即用,无需复杂设置
|
|
11
|
+
- **质量监控** - 实时监控代码质量指标
|
|
12
|
+
- **知识库管理** - 积累最佳实践和经验教训
|
|
13
|
+
- **自动更新** - 保持工具始终最新
|
|
14
|
+
- **多语言支持** - Node.js、Java、Python、Rust、Go
|
|
15
|
+
|
|
16
|
+
## 快速开始
|
|
17
|
+
|
|
18
|
+
### 使用 npx (推荐)
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# 直接运行,无需安装
|
|
22
|
+
npx code-simplifier
|
|
23
|
+
|
|
24
|
+
# 初始化项目
|
|
25
|
+
npx code-simplifier init
|
|
26
|
+
|
|
27
|
+
# 运行质量检查
|
|
28
|
+
npx code-simplifier quality
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 全局安装
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install -g code-simplifier
|
|
35
|
+
|
|
36
|
+
# 使用简写命令
|
|
37
|
+
cs quality
|
|
38
|
+
cs monitor
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 命令
|
|
42
|
+
|
|
43
|
+
### init - 初始化
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# 初始化配置
|
|
47
|
+
npx code-simplifier init
|
|
48
|
+
|
|
49
|
+
# 带演示模式
|
|
50
|
+
npx code-simplifier init --demo
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### quality - 质量分析
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# 分析代码质量
|
|
57
|
+
npx code-simplifier quality
|
|
58
|
+
|
|
59
|
+
# 指定目录
|
|
60
|
+
npx code-simplifier quality --dir src
|
|
61
|
+
|
|
62
|
+
# 设置质量阈值
|
|
63
|
+
npx code-simplifier quality --threshold 80
|
|
64
|
+
|
|
65
|
+
# 输出JSON格式
|
|
66
|
+
npx code-simplifier quality --report json
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### monitor - 实时监控
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# 启动监控仪表板
|
|
73
|
+
npx code-simplifier monitor
|
|
74
|
+
|
|
75
|
+
# 自定义端口
|
|
76
|
+
npx code-simplifier monitor --port 8080
|
|
77
|
+
|
|
78
|
+
# 设置检查间隔(毫秒)
|
|
79
|
+
npx code-simplifier monitor --interval 60000
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### workflow - 完整工作流
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# 运行完整改进工作流
|
|
86
|
+
npx code-simplifier workflow
|
|
87
|
+
|
|
88
|
+
# 启用所有步骤
|
|
89
|
+
npx code-simplifier workflow --all
|
|
90
|
+
|
|
91
|
+
# 显示当前状态
|
|
92
|
+
npx code-simplifier workflow --status
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### knowledge - 知识库
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# 查看知识库统计
|
|
99
|
+
npx code-simplifier knowledge
|
|
100
|
+
|
|
101
|
+
# 添加成功案例
|
|
102
|
+
npx code-simplifier knowledge --add success
|
|
103
|
+
|
|
104
|
+
# 搜索知识库
|
|
105
|
+
npx code-simplifier knowledge --search "性能优化"
|
|
106
|
+
|
|
107
|
+
# 导出知识库
|
|
108
|
+
npx code-simplifier knowledge --export backup.json
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### report - 报告生成
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# 生成日报
|
|
115
|
+
npx code-simplifier report
|
|
116
|
+
|
|
117
|
+
# 生成周报
|
|
118
|
+
npx code-simplifier report --type weekly
|
|
119
|
+
|
|
120
|
+
# 生成月报
|
|
121
|
+
npx code-simplifier report --type monthly
|
|
122
|
+
|
|
123
|
+
# 指定输出路径
|
|
124
|
+
npx code-simplifier report --output ./reports/my-report.md
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### config - 配置管理
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# 查看所有配置
|
|
131
|
+
npx code-simplifier config
|
|
132
|
+
|
|
133
|
+
# 获取特定配置
|
|
134
|
+
npx code-simplifier config --get quality.threshold
|
|
135
|
+
|
|
136
|
+
# 设置配置值
|
|
137
|
+
npx code-simplifier config --set quality.threshold --value 80
|
|
138
|
+
|
|
139
|
+
# 重置配置
|
|
140
|
+
npx code-simplifier config --reset
|
|
141
|
+
|
|
142
|
+
# 交互式配置
|
|
143
|
+
npx code-simplifier config --interactive
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### update - 更新工具
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# 检查更新
|
|
150
|
+
npx code-simplifier update
|
|
151
|
+
|
|
152
|
+
# 强制更新
|
|
153
|
+
npx code-simplifier update --force
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## 配置文件
|
|
157
|
+
|
|
158
|
+
配置存储在 `.code-simplifier/config.json`:
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"quality": {
|
|
163
|
+
"threshold": 70,
|
|
164
|
+
"autoFix": false,
|
|
165
|
+
"reportFormat": "md"
|
|
166
|
+
},
|
|
167
|
+
"monitor": {
|
|
168
|
+
"port": 3000,
|
|
169
|
+
"interval": 300000,
|
|
170
|
+
"autoOpen": true
|
|
171
|
+
},
|
|
172
|
+
"update": {
|
|
173
|
+
"autoCheck": true,
|
|
174
|
+
"channel": "stable"
|
|
175
|
+
},
|
|
176
|
+
"report": {
|
|
177
|
+
"outputDir": "reports",
|
|
178
|
+
"openAfterGenerate": false
|
|
179
|
+
},
|
|
180
|
+
"knowledge": {
|
|
181
|
+
"dataDir": ".code-simplifier",
|
|
182
|
+
"autoUpdate": true
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## 工作流程
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
191
|
+
│ Code-Simplifier 工作流 │
|
|
192
|
+
├─────────────────────────────────────────────────────────────┤
|
|
193
|
+
│ │
|
|
194
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
|
195
|
+
│ │ 质量分析 │───▶│ 趋势跟踪 │───▶│ 预警检查 │ │
|
|
196
|
+
│ └──────────┘ └──────────┘ └──────────┘ │
|
|
197
|
+
│ │ │ │
|
|
198
|
+
│ ▼ ▼ │
|
|
199
|
+
│ ┌──────────┐ ┌──────────┐ │
|
|
200
|
+
│ │ 报告生成 │ │ 知识更新 │ │
|
|
201
|
+
│ └──────────┘ └──────────┘ │
|
|
202
|
+
│ │ │ │
|
|
203
|
+
│ └────────────┬───────────────────┘ │
|
|
204
|
+
│ ▼ │
|
|
205
|
+
│ ┌──────────┐ │
|
|
206
|
+
│ │ 持续改进 │ │
|
|
207
|
+
│ └──────────┘ │
|
|
208
|
+
│ │
|
|
209
|
+
└─────────────────────────────────────────────────────────────┘
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## API 端点
|
|
213
|
+
|
|
214
|
+
监控服务提供以下 REST API:
|
|
215
|
+
|
|
216
|
+
| 端点 | 方法 | 描述 |
|
|
217
|
+
|------|------|------|
|
|
218
|
+
| `/api/status` | GET | 获取当前质量状态 |
|
|
219
|
+
| `/api/trend` | GET | 获取趋势数据 |
|
|
220
|
+
| `/api/alerts` | GET | 获取预警信息 |
|
|
221
|
+
|
|
222
|
+
## 项目结构
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
code-simplifier/
|
|
226
|
+
├── bin/
|
|
227
|
+
│ └── code-simplifier.js # CLI 入口
|
|
228
|
+
├── lib/
|
|
229
|
+
│ ├── master.js # 主控制器
|
|
230
|
+
│ ├── quality-monitor.js # 质量监控
|
|
231
|
+
│ ├── quality-analyzer.js # 质量分析
|
|
232
|
+
│ ├── knowledge-base.js # 知识库
|
|
233
|
+
│ ├── improvement.js # 持续改进
|
|
234
|
+
│ ├── report-generator.js # 报告生成
|
|
235
|
+
│ ├── auto-update.js # 自动更新
|
|
236
|
+
│ └── config.js # 配置管理
|
|
237
|
+
├── package.json
|
|
238
|
+
└── README.md
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## 支持的项目类型
|
|
242
|
+
|
|
243
|
+
| 类型 | 检测文件 | 扫描模式 |
|
|
244
|
+
|------|----------|----------|
|
|
245
|
+
| Node.js | `package.json` | `*.js, *.ts, *.jsx, *.tsx` |
|
|
246
|
+
| Java | `pom.xml` | `*.java` |
|
|
247
|
+
| Python | `requirements.txt` | `*.py` |
|
|
248
|
+
| Rust | `Cargo.toml` | `*.rs` |
|
|
249
|
+
| Go | `go.mod` | `*.go` |
|
|
250
|
+
|
|
251
|
+
## 质量评分标准
|
|
252
|
+
|
|
253
|
+
| 评分 | 等级 | 说明 |
|
|
254
|
+
|------|------|------|
|
|
255
|
+
| 90-100 | 优秀 | 代码质量很高,继续保持 |
|
|
256
|
+
| 80-89 | 良好 | 代码质量良好,可继续优化 |
|
|
257
|
+
| 70-79 | 一般 | 代码质量一般,建议改进 |
|
|
258
|
+
| 60-69 | 较差 | 代码质量较差,需要改进 |
|
|
259
|
+
| <60 | 很差 | 代码质量很差,急需改进 |
|
|
260
|
+
|
|
261
|
+
## 常见问题
|
|
262
|
+
|
|
263
|
+
### Q: 如何忽略某些文件?
|
|
264
|
+
|
|
265
|
+
在项目根目录创建 `.code-simplifier-ignore` 文件:
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
node_modules/
|
|
269
|
+
dist/
|
|
270
|
+
coverage/
|
|
271
|
+
*.min.js
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Q: 如何集成到 CI/CD?
|
|
275
|
+
|
|
276
|
+
```yaml
|
|
277
|
+
# GitHub Actions 示例
|
|
278
|
+
- name: Code Quality Check
|
|
279
|
+
run: npx code-simplifier quality --threshold 70
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Q: 监控服务无法启动?
|
|
283
|
+
|
|
284
|
+
检查端口是否被占用:
|
|
285
|
+
```bash
|
|
286
|
+
npx code-simplifier monitor --port 8080
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## 更新日志
|
|
290
|
+
|
|
291
|
+
### v1.0.0
|
|
292
|
+
- 初始版本发布
|
|
293
|
+
- 支持质量分析、监控、知识库、报告生成
|
|
294
|
+
- 多语言项目支持
|
|
295
|
+
|
|
296
|
+
## 贡献
|
|
297
|
+
|
|
298
|
+
欢迎提交 Issue 和 Pull Request!
|
|
299
|
+
|
|
300
|
+
## 许可证
|
|
301
|
+
|
|
302
|
+
MIT License - 详见 [LICENSE](LICENSE) 文件
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Code-Simplifier 持续改进系统
|
|
5
|
+
* CLI入口脚本
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { Command } = require('commander')
|
|
9
|
+
const chalk = require('chalk')
|
|
10
|
+
const ora = require('ora')
|
|
11
|
+
const boxen = require('boxen')
|
|
12
|
+
const path = require('path')
|
|
13
|
+
const pkg = require('../package.json')
|
|
14
|
+
|
|
15
|
+
// 异步检查更新
|
|
16
|
+
async function checkForUpdates() {
|
|
17
|
+
try {
|
|
18
|
+
const updateNotifier = (await import('update-notifier')).default
|
|
19
|
+
const notifier = updateNotifier({ pkg })
|
|
20
|
+
notifier.notify()
|
|
21
|
+
} catch (e) {
|
|
22
|
+
// 忽略更新检查失败
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
checkForUpdates()
|
|
26
|
+
|
|
27
|
+
const program = new Command()
|
|
28
|
+
|
|
29
|
+
// 打印横幅
|
|
30
|
+
function printBanner() {
|
|
31
|
+
const banner = `
|
|
32
|
+
${chalk.cyan.bold('██╗ ██╗ ███╗ ██╗██╗ ██╗██████╗ ██╗ ██╗')}
|
|
33
|
+
${chalk.cyan.bold('██║ ██╔╝ ████╗ ██║██║ ██║██╔══██╗██║ ██║')}
|
|
34
|
+
${chalk.cyan.bold('█████╔╝ ██╔██╗ ██║██║ ██║██████╔╝██║ ██║')}
|
|
35
|
+
${chalk.cyan.bold('██╔═██╗ ██║╚██╗██║██║ ██║██╔══██╗██║ ██║')}
|
|
36
|
+
${chalk.cyan.bold('██║ ██╗ ██║ ╚████║╚██████╔╝██████╔╝╚██████╔╝')}
|
|
37
|
+
${chalk.cyan.bold('╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═════╝')}
|
|
38
|
+
|
|
39
|
+
${chalk.green.bold(' Code-Simplifier 持续改进系统 v')}${pkg.version}
|
|
40
|
+
`
|
|
41
|
+
console.log(boxen(banner, { padding: 1, borderColor: 'cyan', dimBorder: true }))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 配置主命令
|
|
45
|
+
program
|
|
46
|
+
.name('code-simplifier')
|
|
47
|
+
.description(chalk.cyan.bold('Code-Simplifier持续改进系统 - 自动化代码质量监控与改进工具'))
|
|
48
|
+
.version(pkg.version, '-v, --version', '显示版本号')
|
|
49
|
+
.helpOption('-h, --help', '显示帮助信息')
|
|
50
|
+
|
|
51
|
+
// init命令
|
|
52
|
+
program
|
|
53
|
+
.command('init')
|
|
54
|
+
.description(chalk.green('✨ 初始化Code-Simplifier系统'))
|
|
55
|
+
.option('-y, --yes', '跳过交互式确认', false)
|
|
56
|
+
.option('--force', '强制重新初始化', false)
|
|
57
|
+
.action(async (options) => {
|
|
58
|
+
try {
|
|
59
|
+
const spinner = ora(chalk.blue('正在初始化系统...')).start()
|
|
60
|
+
const master = require('../lib/master')
|
|
61
|
+
await master.initialize(options)
|
|
62
|
+
spinner.succeed(chalk.green('✅ 系统初始化完成'))
|
|
63
|
+
console.log(chalk.cyan('\n📖 下一步: 运行 ') + chalk.yellow('code-simplifier workflow') + chalk.cyan(' 启动完整工作流'))
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error(chalk.red('❌ 初始化失败:'), error.message)
|
|
66
|
+
process.exit(1)
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
// workflow命令
|
|
71
|
+
program
|
|
72
|
+
.command('workflow')
|
|
73
|
+
.description(chalk.blue('🔄 运行完整改进工作流'))
|
|
74
|
+
.option('-s, --skip-update', '跳过版本检查', false)
|
|
75
|
+
.option('-q, --quiet', '静默模式', false)
|
|
76
|
+
.action(async (options) => {
|
|
77
|
+
try {
|
|
78
|
+
const master = require('../lib/master')
|
|
79
|
+
await master.runWorkflow(options)
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error(chalk.red('❌ 工作流执行失败:'), error.message)
|
|
82
|
+
process.exit(1)
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
// monitor命令
|
|
87
|
+
program
|
|
88
|
+
.command('monitor')
|
|
89
|
+
.description(chalk.magenta('📊 启动质量监控服务'))
|
|
90
|
+
.option('-p, --port <port>', '服务端口号', '3000')
|
|
91
|
+
.option('--host <host>', '服务主机', 'localhost')
|
|
92
|
+
.option('-i, --interval <ms>', '检查间隔(毫秒)', '300000')
|
|
93
|
+
.action((options) => {
|
|
94
|
+
const monitor = require('../lib/quality-monitor')
|
|
95
|
+
monitor.start(options)
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
// knowledge命令
|
|
99
|
+
program
|
|
100
|
+
.command('knowledge')
|
|
101
|
+
.description(chalk.yellow('📚 知识库管理'))
|
|
102
|
+
.option('-a, --add <type>', '添加案例 (success|failure|practice)')
|
|
103
|
+
.option('-s, --search <keyword>', '搜索关键词')
|
|
104
|
+
.option('--stats', '显示统计信息')
|
|
105
|
+
.option('-e, --export <file>', '导出知识库到文件')
|
|
106
|
+
.action(async (options) => {
|
|
107
|
+
try {
|
|
108
|
+
const knowledge = require('../lib/knowledge-base')
|
|
109
|
+
await knowledge.run(options)
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.error(chalk.red('❌ 操作失败:'), error.message)
|
|
112
|
+
process.exit(1)
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
// update命令
|
|
117
|
+
program
|
|
118
|
+
.command('update')
|
|
119
|
+
.description(chalk.cyan('🔧 工具更新管理'))
|
|
120
|
+
.option('-c, --check', '检查更新')
|
|
121
|
+
.option('-f, --force', '强制更新')
|
|
122
|
+
.option('-b, --backup', '更新前备份', true)
|
|
123
|
+
.action(async (options) => {
|
|
124
|
+
try {
|
|
125
|
+
const updater = require('../lib/auto-update')
|
|
126
|
+
await updater.run(options)
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.error(chalk.red('❌ 更新失败:'), error.message)
|
|
129
|
+
process.exit(1)
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
// quality命令
|
|
134
|
+
program
|
|
135
|
+
.command('quality')
|
|
136
|
+
.description(chalk.red('🔍 执行代码质量检查'))
|
|
137
|
+
.option('-d, --dir <path>', '检查目录', 'src')
|
|
138
|
+
.option('--report <type>', '报告类型 (json|html|md)', 'md')
|
|
139
|
+
.option('-o, --output <file>', '输出文件')
|
|
140
|
+
.option('--threshold <score>', '质量阈值', '70')
|
|
141
|
+
.action(async (options) => {
|
|
142
|
+
try {
|
|
143
|
+
const quality = require('../lib/quality-analyzer')
|
|
144
|
+
await quality.run(options)
|
|
145
|
+
} catch (error) {
|
|
146
|
+
console.error(chalk.red('❌ 质量检查失败:'), error.message)
|
|
147
|
+
process.exit(1)
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
// report命令
|
|
152
|
+
program
|
|
153
|
+
.command('report')
|
|
154
|
+
.description(chalk.blue('📈 生成改进报告'))
|
|
155
|
+
.option('-t, --type <type>', '报告类型 (daily|weekly|monthly)', 'daily')
|
|
156
|
+
.option('-o, --output <file>', '输出文件')
|
|
157
|
+
.option('--open', '生成后打开报告', false)
|
|
158
|
+
.action(async (options) => {
|
|
159
|
+
try {
|
|
160
|
+
const reporter = require('../lib/report-generator')
|
|
161
|
+
await reporter.generate(options)
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.error(chalk.red('❌ 报告生成失败:'), error.message)
|
|
164
|
+
process.exit(1)
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
// config命令
|
|
169
|
+
program
|
|
170
|
+
.command('config')
|
|
171
|
+
.description(chalk.green('⚙️ 系统配置管理'))
|
|
172
|
+
.option('--get <key>', '获取配置项')
|
|
173
|
+
.option('--set <key> <value>', '设置配置项')
|
|
174
|
+
.option('--list', '显示所有配置')
|
|
175
|
+
.option('--reset', '重置为默认配置')
|
|
176
|
+
.action((options) => {
|
|
177
|
+
const config = require('../lib/config')
|
|
178
|
+
config.run(options)
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
// demo命令
|
|
182
|
+
program
|
|
183
|
+
.command('demo')
|
|
184
|
+
.description(chalk.magenta('🎬 运行交互式演示'))
|
|
185
|
+
.action(async () => {
|
|
186
|
+
try {
|
|
187
|
+
const demo = require('../lib/demo')
|
|
188
|
+
await demo.run()
|
|
189
|
+
} catch (error) {
|
|
190
|
+
console.error(chalk.red('❌ 演示执行失败:'), error.message)
|
|
191
|
+
process.exit(1)
|
|
192
|
+
}
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
// 检查是否直接运行此脚本
|
|
196
|
+
if (require.main === module) {
|
|
197
|
+
// 打印横幅
|
|
198
|
+
printBanner()
|
|
199
|
+
|
|
200
|
+
// 如果没有参数,显示帮助
|
|
201
|
+
if (process.argv.length === 2) {
|
|
202
|
+
console.log(chalk.cyan('\n🚀 快速开始:\n'))
|
|
203
|
+
console.log(chalk.yellow(' code-simplifier init'))
|
|
204
|
+
console.log(chalk.gray(' 初始化系统\n'))
|
|
205
|
+
console.log(chalk.yellow(' code-simplifier workflow'))
|
|
206
|
+
console.log(chalk.gray(' 运行完整工作流\n'))
|
|
207
|
+
console.log(chalk.yellow(' code-simplifier monitor'))
|
|
208
|
+
console.log(chalk.gray(' 启动质量监控\n'))
|
|
209
|
+
console.log(chalk.cyan('💡 输入 ') + chalk.yellow('code-simplifier <command> --help') + chalk.cyan(' 查看命令详细帮助'))
|
|
210
|
+
console.log('')
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
program.parse(process.argv)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
module.exports = program
|