# unsafe_agent_demo.py  (educational/demonstration purpose)
import time

def mock_llm_plan(prompt: str):
    """
    The 'plan' returned by LLM - a list of steps.
    (This would be replaced by an LLM API: 'How to find & deploy latest build X')
    """
    return [
        "git checkout main",
        "git pull origin main",
        "run tests",
        "build artifact",
        "deploy to production"
    ]

def execute_step(step: str):
    # >>> CAUTION: the real implementation could run actual commands here,
    # pl. subprocess.run([...]), ssh commands, CI/CD API calls. This is VERY dangerous.
    print(f"[EXECUTE] {step}")
    # Let's simulate running
    time.sleep(1)
    # If we call subprocess.run here, the string generated by the model would be executed directly!

def run_agent(prompt: str):
    plan = mock_llm_plan(prompt)
    print("LLM proposal:")
    for i, s in enumerate(plan, 1):
        print(f"  {i}. {s}")

    print("\nImmediate implementation (unsafe) starts...")
    for s in plan:
        execute_step(s)
    print("Implementation complete.")

if __name__ == "__main__":
    run_agent("Find and deploy latest build of service-X")
