feat(run): 试运行脚本 + 运行说明(真实 LLM 默认 / --fake 离线)

- scripts/run_trial.py:库级端到端驱动(argparse 默认指向 samples/ 股票追加改修+sunOnly+真实模板)
  - --fake 离线 FakeEngine(无 key)/ 默认 build_inference_engine 真实 LLM(读 .env)
  - SourceParser → WriteOrchestrator 门控自动影响调查 → output/output.docx + impact-report.json
  - 暴露 main(argv) 供测试
- tests/test_run_trial.py(fake 模式断言 13 章 + summary 16/5/8/3/50/0 + 文件产出 + docx 注入)
- .gitignore 新增 output/(试运行产物不入库)
- 新建 README.md(安装 / .env 配置 / 离线与真实试运行 / 输出 / 测试)
- 全量 364 passed / 99.28%;fake 试运行 PASS(13 章、summary 与 MVP 基线一致)
This commit is contained in:
lhl
2026-08-24 11:05:45 +08:00
parent 61ac47c7af
commit 6372bb17b9
5 changed files with 218 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
"""scripts/run_trial.py 驱动测试(fake 模式,离线确定性,无需 API key)。"""
import json
from pathlib import Path
from scripts.run_trial import main
def test_run_trial_fake_produces_docx_and_report(tmp_path):
out = tmp_path / "output.docx"
report = tmp_path / "impact-report.json"
result = main([
"--fake",
"--output", str(out),
"--impact-report", str(report),
])
# 章数:真实概要设计书模板 13 章
assert result["chapters"] == 13
# 影响调查 summary 与 MVP 基线一致
assert result["summary"] == {
"total": 16, "new": 5, "modified": 8, "deleted": 3,
"unchanged": 50, "warnings": 0,
}
assert out.is_file()
assert report.is_file()
data = json.loads(report.read_text(encoding="utf-8"))
assert data["summary"] == result["summary"]
def test_run_trial_fake_docx_contains_injected_text(tmp_path):
out = tmp_path / "out.docx"
report = tmp_path / "ir.json"
main(["--fake", "--output", str(out), "--impact-report", str(report)])
from docx import Document
joined = "\n".join(p.text for p in Document(str(out)).paragraphs)
assert "自动生成内容" in joined