Tsitsi19 commited on
Commit
1c0b5e6
·
verified ·
1 Parent(s): 1e8850e

Create command_router.py

Browse files
Files changed (1) hide show
  1. command_router.py +32 -0
command_router.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from divinity_engine import divine_mutation, apply_pending, cancel_pending
2
+
3
+ def process_command(text, agent):
4
+ text = text.strip()
5
+
6
+ # Mutation : langage naturel ou code
7
+ if text.lower().startswith("mutation:"):
8
+ try:
9
+ # Si format code direct : "mutation: fichier=app.py"
10
+ lines = text.split("\n")
11
+ header = lines[0]
12
+ new_code = "\n".join(lines[1:]).strip()
13
+
14
+ if "fichier=" in header:
15
+ target = header.split("fichier=")[1].strip()
16
+ else:
17
+ return "Format invalide. Utilise : mutation: fichier=app.py"
18
+
19
+ return divine_mutation(new_code, target)
20
+ except Exception as e:
21
+ return f"Erreur dans la mutation : {e}"
22
+
23
+ # Validation
24
+ if text.upper() == "VALIDER":
25
+ return apply_pending()
26
+
27
+ # Annulation
28
+ if text.upper() == "ANNULER":
29
+ return cancel_pending()
30
+
31
+ # Toutes autres commandes → Qwen interprète
32
+ return agent.run(text)