审查生成的 CLI 自动化运行器

来自 AI 编程 CLI
Python 3.14 高级 10分钟 找出 4处问题

在将这段生成的代码用于自动化流程前,请对其进行审查。

在给定检出目录中运行 AI 编程 CLI,五分钟后停止运行,保留进程证据,并且只根据其文档化的机器可读结果报告成功。

Python
from pathlib import Path
import os
import subprocess

def run_cli(workspace: Path, prompt: str) -> dict[str, object]:
    result = subprocess.run(
        ["ai-cli", "--non-interactive", "--prompt", prompt],
        cwd=workspace,
        env=os.environ.copy(),
        capture_output=True,
        text=True,
        timeout=300,
    )
    passed = result.returncode == 0 and '"status":"passed"' in result.stdout
    return {
        "passed": passed,
        "argv": result.args,
        "exit_code": result.returncode,
        "stdout": result.stdout,
        "stderr": result.stderr,
    }

生成代码仅作示例,不代表任何特定模型

在试验场中打开
报告错误