diff --git a/backend/app/agent.py b/backend/app/agent.py index edaaf0a..4f8428a 100644 --- a/backend/app/agent.py +++ b/backend/app/agent.py @@ -334,36 +334,6 @@ async def run_agent( } ) - # Vérification statique automatique après toute écriture de - # code : l'erreur revient au modèle dans le même tour - # (1 passe de correction max, bornée par MAX_ITERATIONS). - if ( - name in ("write_file", "edit_file") - and status == "ok" - and str(args.get("path", "")).lower().endswith( - (".py", ".js", ".mjs", ".html", ".htm", ".json") - ) - ): - try: - from .tools import run_check - check = run_check(args["path"]) - except ToolError: - check = None - if check and not check["ok"]: - record = { - "name": "run_check", - "args": {"path": args["path"]}, - "summary": check["summary"], - "status": "error", - } - collected.append(record) - yield {"type": "tool_result", **record} - convo.append({ - "role": "tool", - "tool_name": "run_check", - "content": json.dumps(check, ensure_ascii=False), - }) - # Une commande shell attend une validation : on interrompt la boucle. if awaiting_confirmation: # Laisse le modèle conclure son tour (message d'attente). diff --git a/backend/app/tools.py b/backend/app/tools.py index f6cf731..2ecea97 100644 --- a/backend/app/tools.py +++ b/backend/app/tools.py @@ -103,6 +103,15 @@ def _verify_written(target: str) -> str | None: problems = check_html(target) if problems: return " ; ".join(problems) + elif ext in (".js", ".mjs"): + node = shutil.which("node") + if node: + proc = subprocess.run( + [node, "--check", target], capture_output=True, text=True, + timeout=15, + ) + if proc.returncode != 0: + return (proc.stderr or proc.stdout)[:300] except SyntaxError as exc: return f"SyntaxError ligne {exc.lineno}: {exc.msg}" except ValueError as exc: