4.7 KiB
4.7 KiB
Streamlit 运行说明
📂 生成的代码在哪里?
当您运行 streamlit run frontend/streamlit_app_v3.py 并启动 SDLC 工作流后,所有生成的文件都保存在:
c:\Workspace\AI_AutoGen\workspace\
📁 目录结构
c:\Workspace\AI_AutoGen/
├── workspace/ ← 生成的代码在这里!
│ ├── SRS.md # 软件需求规格说明书
│ ├── test_battery_health.py # 测试用例
│ ├── src_battery_health.py # 源代码
│ ├── bdd_scenarios.md # BDD 测试场景
│ ├── coverage_report.md # 测试覆盖率报告
│ └── FINAL_REPORT.md # 最终项目报告
├── logs/ ← 对话日志
│ └── session_*.jsonl # 会话日志
└── frontend/
└── streamlit_app_v3.py
🔍 如何查看生成的文件
方法 1: 在 Streamlit 界面查看(推荐)
运行 Streamlit 后,在界面右侧边栏会显示:
- "生成的文件" 区域
- 点击文件名可以预览内容
- 支持查看
.md,.py,.txt等格式
方法 2: 直接在文件管理器查看
Windows:
# 打开 workspace 目录
explorer c:\Workspace\AI_AutoGen\workspace
命令行查看:
# 查看所有生成的文件
dir c:\Workspace\AI_AutoGen\workspace
# 查看 SRS 文档
type c:\Workspace\AI_AutoGen\workspace\SRS.md
# 查看源代码
type c:\Workspace\AI_AutoGen\workspace\src_battery_health.py
方法 3: 使用 Python 脚本查看
创建一个快速查看脚本:
# view_generated_files.py
from pathlib import Path
workspace = Path("workspace")
if workspace.exists():
print("生成的文件列表:")
for file in workspace.glob("*"):
if file.is_file():
print(f" 📄 {file.name} ({file.stat().st_size:,} bytes)")
else:
print("workspace 目录不存在,请先运行 SDLC 工作流")
🎯 典型生成的文件
运行一次完整的 SDLC 工作流后,通常会生成以下文件:
| 文件名 | 类型 | 说明 | 生成 Agent |
|---|---|---|---|
SRS.md |
Markdown | 软件需求规格说明书 | PM Agent |
test_*.py |
Python | 测试用例脚本 | QA Agent |
src_*.py |
Python | 源代码实现 | Dev Agent |
bdd_scenarios.md |
Markdown | BDD 测试场景 | QA Agent |
coverage_report.md |
Markdown | 测试覆盖率报告 | QA Agent |
FINAL_REPORT.md |
Markdown | 最终项目总结 | Orchestrator |
💡 示例:查看生成的代码
假设您运行了"电池健康预测 API"的示例,生成的代码会在:
源代码位置:
c:\Workspace\AI_AutoGen\workspace\src_battery_health.py
测试代码位置:
c:\Workspace\AI_AutoGen\workspace\test_battery_health.py
需求文档位置:
c:\Workspace\AI_AutoGen\workspace\SRS.md
🔧 在 Streamlit 中添加文件查看器
如果想要在 Streamlit 界面中直接查看生成的文件,可以在 streamlit_app_v3.py 中添加以下代码:
# 在 sidebar 中添加
st.sidebar.subheader("📁 生成的文件")
workspace_dir = Path("workspace")
if workspace_dir.exists():
files = list(workspace_dir.glob("*"))
for file in files:
if file.is_file():
with st.sidebar.expander(f"📄 {file.name}"):
try:
content = file.read_text(encoding='utf-8')
st.code(content[:1000] + ("..." if len(content) > 1000 else ""))
# 下载按钮
st.download_button(
label="⬇️ 下载",
data=content,
file_name=file.name,
mime="text/plain"
)
except Exception as e:
st.error(f"读取失败:{e}")
else:
st.sidebar.info("工作目录为空,请先运行工作流")
⚠️ 注意事项
- 首次运行会创建目录 - workspace 目录会在第一次运行时自动创建
- 文件会覆盖 - 每次运行新的需求会覆盖之前的文件
- 及时备份 - 重要的生成物请及时复制到其他目录
- 日志目录 - 对话历史保存在
logs/目录,格式为 JSONL
📊 查看对话日志
对话日志保存在 logs/ 目录:
# 查看最新的会话日志
dir c:\Workspace\AI_AutoGen\logs\session_*.jsonl
# 使用 Python 查看
python -c "import json; [print(json.loads(line)) for line in open('logs/session_*.jsonl')]"
🎉 现在您知道生成的代码在哪里了!
运行 streamlit run frontend/streamlit_app_v3.py 后,所有生成的文件都会出现在 workspace/ 目录中。