Set workspace directory Called by workflow to set workspace to: {plan_file_parent}/generate_code This ensures all file operations are executed relative to the correct project directory Args: workspace_path: Workspace path (Usually {plan_file_parent}/generate_code) Ret
(workspace_path: str)
| 1394 | |
| 1395 | @mcp.tool() |
| 1396 | async def set_workspace(workspace_path: str) -> str: |
| 1397 | """ |
| 1398 | Set workspace directory |
| 1399 | |
| 1400 | Called by workflow to set workspace to: {plan_file_parent}/generate_code |
| 1401 | This ensures all file operations are executed relative to the correct project directory |
| 1402 | |
| 1403 | Args: |
| 1404 | workspace_path: Workspace path (Usually {plan_file_parent}/generate_code) |
| 1405 | |
| 1406 | Returns: |
| 1407 | JSON string of operation result |
| 1408 | """ |
| 1409 | try: |
| 1410 | global WORKSPACE_DIR |
| 1411 | new_workspace = Path(workspace_path).resolve() |
| 1412 | |
| 1413 | # Create directory (if it does not exist) |
| 1414 | new_workspace.mkdir(parents=True, exist_ok=True) |
| 1415 | |
| 1416 | old_workspace = WORKSPACE_DIR |
| 1417 | WORKSPACE_DIR = new_workspace |
| 1418 | |
| 1419 | logger.info(f"New Workspace: {WORKSPACE_DIR}") |
| 1420 | |
| 1421 | result = { |
| 1422 | "status": "success", |
| 1423 | "message": f"Workspace setup successful: {workspace_path}", |
| 1424 | "new_workspace": str(WORKSPACE_DIR), |
| 1425 | } |
| 1426 | |
| 1427 | log_operation( |
| 1428 | "set_workspace", |
| 1429 | { |
| 1430 | "old_workspace": str(old_workspace) if old_workspace else None, |
| 1431 | "new_workspace": str(WORKSPACE_DIR), |
| 1432 | "workspace_alignment": "plan_file_parent/generate_code", |
| 1433 | }, |
| 1434 | ) |
| 1435 | |
| 1436 | return json.dumps(result, ensure_ascii=False, indent=2) |
| 1437 | |
| 1438 | except Exception as e: |
| 1439 | result = { |
| 1440 | "status": "error", |
| 1441 | "message": f"Failed to set workspace: {str(e)}", |
| 1442 | "workspace_path": workspace_path, |
| 1443 | } |
| 1444 | log_operation( |
| 1445 | "set_workspace_error", {"workspace_path": workspace_path, "error": str(e)} |
| 1446 | ) |
| 1447 | return json.dumps(result, ensure_ascii=False, indent=2) |
| 1448 | |
| 1449 | |
| 1450 | @mcp.tool() |
nothing calls this directly
no test coverage detected