from pathlib import Path from aios_cockpit.config import CockpitPaths from aios_cockpit.models import ProjectCard from aios_cockpit.workbench import ( create_task_from_candidate, list_tasks, prepare_run_preview, propose_sprint_candidates, route_task_record, ) def test_propose_sprint_candidates_from_plan(tmp_path: Path) -> None: (tmp_path / "README.md").write_text("# Demo", encoding="utf-8") (tmp_path / "PLAN.md").write_text( "- [ ] Add workbench route\n- [ ] Write smoke test\n", encoding="utf-8", ) project = ProjectCard( name="Demo", path=str(tmp_path), category="project", role="project", status="active-recent", ) candidates = propose_sprint_candidates(project) assert candidates assert candidates[0].title == "Add workbench route" def test_task_persistence_and_run_preview(tmp_path: Path) -> None: project_dir = tmp_path / "Project" project_dir.mkdir() paths = CockpitPaths( cockpit_root=tmp_path / "Cockpit", projects_dir=tmp_path, samuel_os=tmp_path / "samuel-os-v2", zentrale=tmp_path / "Zentrale", komandozentral=tmp_path / "KomandoZentral", prompt_garage_db=tmp_path / "PromptGarage" / "prompts.db", codex_max_howto=tmp_path / "CodexMaxHarnessHowTo", harness_db=tmp_path / "harness.db", harness_ecosystem=tmp_path / "HarnessEcosystem", ) project = ProjectCard( name="Project", path=str(project_dir), category="project", role="project", status="active-recent", ) task = create_task_from_candidate( project, title="Add route", description="Add route to the workbench", verification="pytest", target_agent="codex", tasks_dir=paths.tasks_dir, ) route = route_task_record(task, paths) preview = prepare_run_preview(task, paths) assert list_tasks(paths.tasks_dir)[0].id == task.id assert route.task == "Add route to the workbench" assert preview.status == "ready" assert "--dry-run" in preview.command assert Path(preview.instructions_file).is_file()