import os import shutil def simulate_perceive(project_name, projects_dir): prd_path = os.path.join(projects_dir, project_name, "PRD.org") protocol_path = os.path.join(projects_dir, project_name, "PROTOCOL.org") if not os.path.exists(prd_path): return None with open(prd_path, 'r') as f: content = f.read() if "#+STATUS: FROZEN" in content and not os.path.exists(protocol_path): return {"project": project_name, "prd_path": prd_path, "content": content} return None if __name__ == "__main__": test_dir = "/tmp/architect_test_projects" if os.path.exists(test_dir): shutil.rmtree(test_dir) os.makedirs(os.path.join(test_dir, "test-project")) prd_file = os.path.join(test_dir, "test-project", "PRD.org") print("--- Test 1: Draft PRD ---") with open(prd_file, "w") as f: f.write("#+TITLE: Test\n#+STATUS: DRAFT\n") res = simulate_perceive("test-project", test_dir) print(f"Result: {res}") status1 = "PASS" if res is None else "FAIL" print("\n--- Test 2: Frozen PRD ---") with open(prd_file, "w") as f: f.write("#+TITLE: Test\n#+STATUS: FROZEN\n") res = simulate_perceive("test-project", test_dir) print(f"Result: {res['project'] if res else None}") status2 = "PASS" if res and res['project'] == "test-project" else "FAIL" print("\n--- Test 3: Protocol already exists ---") with open(os.path.join(test_dir, "test-project", "PROTOCOL.org"), "w") as f: f.write("exists") res = simulate_perceive("test-project", test_dir) print(f"Result: {res}") status3 = "PASS" if res is None else "FAIL" print(f"\nFinal Status: {'PASS' if all(s == 'PASS' for s in [status1, status2, status3]) else 'FAIL'}")