mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-11 17:26:57 +02:00
refactor(agent): vérification JS via _verify_written (déjà auto après écriture)
L'auto-check séparé dans la boucle agent doublonnait _verify_written et signalait à tort les fichiers écrits par morceaux (mode append). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
c92e4d4a13
commit
d19624b46b
2 files changed
+9
-30
No files matched your search
@@ -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).
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user