73 lines
2.1 KiB
Python
73 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
QwenPaw 调用 MetaGPT 干活 — 集成示例
|
|
使用时确保已安装:pip install metagpt
|
|
"""
|
|
|
|
import subprocess
|
|
|
|
# ============================================
|
|
# 方式一:Shell 调用(最简单)
|
|
# ============================================
|
|
def call_metagpt_cli(requirement: str):
|
|
"""QwenPaw 通过 Shell 直接调 MetaGPT CLI"""
|
|
cmd = f'metagpt "{requirement}"'
|
|
print(f"🚀 QwenPaw → MetaGPT: {cmd}")
|
|
|
|
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=300)
|
|
print(f"✅ 输出:\n{result.stdout[:500]}")
|
|
return result
|
|
|
|
|
|
# ============================================
|
|
# 方式二:Python SDK 调用(更灵活)
|
|
# ============================================
|
|
def call_metagpt_sdk(requirement: str):
|
|
"""QwenPaw 通过 Python SDK 调 MetaGPT,拿到结构化结果"""
|
|
from metagpt.software_company import generate_repo
|
|
|
|
print(f"🚀 QwenPaw → MetaGPT SDK: {requirement}")
|
|
repo = generate_repo(requirement)
|
|
print(f"✅ 项目生成成功! 仓库: {repo}")
|
|
return repo
|
|
|
|
|
|
# ============================================
|
|
# 方式三:QwenPaw + MetaGPT + ECC 全套流水线
|
|
# ============================================
|
|
def full_pipeline(requirement: str):
|
|
"""
|
|
QwenPaw 编排完整流水线:
|
|
1. MetaGPT 从需求生成项目
|
|
2. ECC 代码审查
|
|
3. ECC 安全扫描
|
|
4. ECC 测试
|
|
5. ECC 部署
|
|
"""
|
|
print("=" * 60)
|
|
print("🔥 QwenPaw 编排完整开发流水线")
|
|
print("=" * 60)
|
|
|
|
print("\n[1/5] MetaGPT 生成项目...")
|
|
# repo = call_metagpt_sdk(requirement)
|
|
|
|
print("\n[2/5] ECC 代码审查...")
|
|
# ecc_code_review(...)
|
|
|
|
print("\n[3/5] ECC 安全扫描...")
|
|
# ecc_security_scan(...)
|
|
|
|
print("\n[4/5] ECC 自动化测试...")
|
|
# ecc_test(...)
|
|
|
|
print("\n[5/5] ECC 部署上线...")
|
|
# ecc_deploy(...)
|
|
|
|
print("\n✅ 流水线完成!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
requirement = "用 Python 创建一个命令行 TODO 应用,支持增删改查,数据存 JSON"
|
|
print(f"📝 需求: {requirement}\n")
|
|
call_metagpt_cli(requirement)
|