|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +import os |
| 4 | +from pathlib import Path |
| 5 | + |
| 6 | +from agentflow.context_builder import build_context_pack |
| 7 | +from agentflow.exporters import export_context |
| 8 | +from agentflow.runner import run_task |
| 9 | +from agentflow.storage import Store |
| 10 | + |
| 11 | + |
| 12 | +def test_task_context_export_and_run(tmp_path: Path): |
| 13 | + root = tmp_path / "demo" |
| 14 | + root.mkdir() |
| 15 | + (root / "hello.py").write_text("print('hello')\n", encoding="utf-8") |
| 16 | + store = Store(root) |
| 17 | + store.root = root |
| 18 | + store.base = root / ".agentflow" |
| 19 | + store.tasks_file = store.base / "tasks.json" |
| 20 | + store.runs_file = store.base / "runs.json" |
| 21 | + store.config_file = store.base / "config.json" |
| 22 | + store.init("demo") |
| 23 | + |
| 24 | + task = store.add_task( |
| 25 | + title="Add a hello test", |
| 26 | + goal="Create a small test around hello.py", |
| 27 | + files=["hello.py"], |
| 28 | + acceptance=["Context pack is generated"], |
| 29 | + ) |
| 30 | + |
| 31 | + context_dir = build_context_pack(store, task.id) |
| 32 | + assert (context_dir / "context-pack.md").exists() |
| 33 | + assert "hello.py" in (context_dir / "relevant-files.md").read_text(encoding="utf-8") |
| 34 | + |
| 35 | + written = export_context(store, task.id, ["agents"], force=True) |
| 36 | + assert written[0].name == "AGENTS.md" |
| 37 | + assert written[0].exists() |
| 38 | + |
| 39 | + run = run_task(store, task.id, agent="manual", command="python hello.py", checks=["python hello.py"]) |
| 40 | + assert run.status == "finished" |
| 41 | + assert (root / run.report_path).exists() |
0 commit comments