Repository navigation
Expand file tree
/
Copy pathdevflow-cli.py
More file actions
215 lines (201 loc) · 5.96 KB
/
Copy pathdevflow-cli.py
File metadata and controls
215 lines (201 loc) · 5.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/usr/bin/env python3
"""
DevFlow CLI - 统一命令行入口
用法: python devflow-cli.py <command> [options]
"""
import sys
import subprocess
from pathlib import Path
SCRIPTS_DIR = Path(__file__).parent / "scripts"
COMMANDS = {
"review": {
"desc": "代码审查 (安全/逻辑/性能)",
"script": "review.py",
"example": "devflow review --mode security --dir ."
},
"explain": {
"desc": "代码解释 (代码→人话)",
"script": "explain.py",
"example": "devflow explain --file main.py"
},
"testgen": {
"desc": "测试用例生成",
"script": "testgen.py",
"example": "devflow testgen --file calculator.py --framework pytest"
},
"docgen": {
"desc": "文档生成",
"script": "docgen.py",
"example": "devflow docgen --mode all --file main.py"
},
"smell": {
"desc": "代码坏味道检测",
"script": "smell.py",
"example": "devflow smell --dir ."
},
"migrate": {
"desc": "语法/语言转换",
"script": "migrate.py",
"example": "devflow migrate --from py2 --to py3 --dir src/"
},
"env": {
"desc": "环境检查",
"script": "env-check.py",
"example": "devflow env --dir ."
},
"git": {
"desc": "Git 辅助 (Commit/PR)",
"script": "git-helper.py",
"example": "devflow git --mode commit"
},
"clean": {
"desc": "清理调试标记",
"script": "clean-debug.py",
"example": "devflow clean --dir src/"
},
"regex": {
"desc": "正则表达式工具",
"script": "regex.py",
"example": "devflow regex --pattern '\\d+' --text 'abc123'"
},
"boundary": {
"desc": "边界用例推演",
"script": "boundary.py",
"example": "devflow boundary --file main.py"
},
"racecheck": {
"desc": "竞态条件分析",
"script": "racecheck.py",
"example": "devflow racecheck --file async.py"
},
"config": {
"desc": "配置文件生成",
"script": "config-gen.py",
"example": "devflow config --mode docker"
},
"a11y": {
"desc": "无障碍审查",
"script": "a11y.py",
"example": "devflow a11y --file index.html"
},
"db": {
"desc": "数据库查询优化",
"script": "db-optimize.py",
"example": "devflow db --file query.sql"
},
"full": {
"desc": "全流程运行",
"script": "devflow.py",
"example": "devflow full --dir ."
},
"selftest": {
"desc": "自测",
"script": "selftest.py",
"example": "devflow selftest"
},
"todo": {
"desc": "TODO/FIXME 标记扫描",
"script": "todo-scan.py",
"example": "devflow todo --dir ."
},
"complexity": {
"desc": "代码复杂度分析",
"script": "complexity.py",
"example": "devflow complexity --dir src/ --threshold 10"
},
"gitstats": {
"desc": "Git 提交统计分析",
"script": "git-stats.py",
"example": "devflow gitstats --dir ."
},
"workflow": {
"desc": "阶段化工作流引擎 (init/plan/code/verify/review)",
"script": "workflow.py",
"example": "devflow workflow init --dir ."
},
"agents": {
"desc": "多 Agent 协作 (pm/architect/developer/qa/reviewer)",
"script": "agents.py",
"example": "devflow agents --team qa,reviewer --dir ."
},
"doctor": {
"desc": "项目健康诊断",
"script": "doctor.py",
"example": "devflow doctor --dir ."
},
"audit": {
"desc": "深度安全审计",
"script": "security-audit.py",
"example": "devflow audit --dir ."
},
"pr": {
"desc": "PR 合并检查",
"script": "pr-tool.py",
"example": "devflow pr --diff pr.diff"
},
"tdd": {
"desc": "TDD 实践检查",
"script": "tdd-check.py",
"example": "devflow tdd --dir ."
},
"map": {
"desc": "代码地图",
"script": "code-map.py",
"example": "devflow map --dir ."
},
"memory": {
"desc": "项目记忆管理",
"script": "memory.py",
"example": "devflow memory add '决策内容'"
},
"refactor": {
"desc": "重构建议",
"script": "refactor.py",
"example": "devflow refactor --dir ."
},
"release": {
"desc": "发布说明生成",
"script": "release-notes.py",
"example": "devflow release --dir ."
},
"onboarding": {
"desc": "新成员项目导览",
"script": "onboarding.py",
"example": "devflow onboarding --dir ."
},
"coverage": {
"desc": "测试覆盖率估算",
"script": "coverage-scan.py",
"example": "devflow coverage --dir ."
}
}
def show_help():
"""显示帮助信息"""
print("DevFlow CLI - 一站式全链路开发辅助工具\n")
print("用法: python devflow-cli.py <command> [options]\n")
print("可用命令:")
for cmd, info in COMMANDS.items():
print(f" {cmd:<12} {info['desc']}")
print("\n示例:")
for cmd, info in list(COMMANDS.items())[:5]:
print(f" {info['example']}")
print("\n更多帮助: python devflow-cli.py <command> --help")
def main():
if len(sys.argv) < 2 or sys.argv[1] in ("-h", "--help", "help"):
show_help()
return
command = sys.argv[1]
if command not in COMMANDS:
print(f"错误: 未知命令 '{command}'")
print(f"运行 'python devflow-cli.py help' 查看可用命令")
return
script = SCRIPTS_DIR / COMMANDS[command]["script"]
args = sys.argv[2:]
if not script.exists():
print(f"错误: 脚本不存在 {script}")
return
cmd = [sys.executable, str(script)] + args
result = subprocess.run(cmd, cwd=Path(__file__).parent)
sys.exit(result.returncode)
if __name__ == "__main__":
main()