agent-zero-core / command_router.py
Tsitsi19's picture
Create command_router.py
1c0b5e6 verified
raw
history blame contribute delete
994 Bytes
from divinity_engine import divine_mutation, apply_pending, cancel_pending
def process_command(text, agent):
text = text.strip()
# Mutation : langage naturel ou code
if text.lower().startswith("mutation:"):
try:
# Si format code direct : "mutation: fichier=app.py"
lines = text.split("\n")
header = lines[0]
new_code = "\n".join(lines[1:]).strip()
if "fichier=" in header:
target = header.split("fichier=")[1].strip()
else:
return "Format invalide. Utilise : mutation: fichier=app.py"
return divine_mutation(new_code, target)
except Exception as e:
return f"Erreur dans la mutation : {e}"
# Validation
if text.upper() == "VALIDER":
return apply_pending()
# Annulation
if text.upper() == "ANNULER":
return cancel_pending()
# Toutes autres commandes → Qwen interprète
return agent.run(text)