ea1c67b33f
Agent système complet remplaçant agent_debian : - 20 skills : apt, systemd, cron, process, network, user, sysinfo, journal, container, shell, filesystem (enhanced), git, ssh, web_fetch, todo, script, mqtt_send, mqtt_subscribe, muc_send, agents_status - filesystem : read avec numéros de lignes, edit, multiedit (style SHAI) - git : status, log, diff, add, commit, push, pull, clone, branch, checkout - ssh : exécution distante + SCP (password ou clé) - web_fetch : GET/HEAD/POST avec nettoyage HTML - todo : liste de tâches en mémoire
75 lines
2.2 KiB
Python
75 lines
2.2 KiB
Python
"""
|
|
Skill TODO — liste de tâches en mémoire pour la session courante.
|
|
|
|
Usage LLM :
|
|
SKILL:todo ARGS:add <texte>
|
|
SKILL:todo ARGS:list
|
|
SKILL:todo ARGS:done <id>
|
|
SKILL:todo ARGS:delete <id>
|
|
SKILL:todo ARGS:clear
|
|
"""
|
|
|
|
DESCRIPTION = "Liste de tâches en mémoire (session) : add, list, done, delete, clear"
|
|
USAGE = "SKILL:todo ARGS:add <texte> | list | done <id> | delete <id> | clear"
|
|
|
|
# Stockage partagé entre tous les appels (même processus)
|
|
_todos: list = []
|
|
_next_id: int = 1
|
|
|
|
|
|
def run(args: str, context) -> str:
|
|
global _todos, _next_id
|
|
|
|
parts = args.strip().split(None, 1)
|
|
action = parts[0].lower() if parts else ""
|
|
rest = parts[1].strip() if len(parts) > 1 else ""
|
|
|
|
if action == "add":
|
|
if not rest:
|
|
return "Précise le texte de la tâche."
|
|
_todos.append({"id": _next_id, "text": rest, "done": False})
|
|
_next_id += 1
|
|
return f"Tâche #{_next_id - 1} ajoutée : {rest}"
|
|
|
|
if action == "list":
|
|
if not _todos:
|
|
return "Aucune tâche."
|
|
lines = []
|
|
for t in _todos:
|
|
status = "✓" if t["done"] else "○"
|
|
lines.append(f" {status} #{t['id']} {t['text']}")
|
|
return "Tâches :\n" + "\n".join(lines)
|
|
|
|
if action == "done":
|
|
if not rest:
|
|
return "Précise l'ID de la tâche."
|
|
try:
|
|
tid = int(rest)
|
|
except ValueError:
|
|
return f"ID invalide : {rest}"
|
|
for t in _todos:
|
|
if t["id"] == tid:
|
|
t["done"] = True
|
|
return f"Tâche #{tid} marquée comme terminée."
|
|
return f"Tâche #{tid} introuvable."
|
|
|
|
if action == "delete":
|
|
if not rest:
|
|
return "Précise l'ID de la tâche."
|
|
try:
|
|
tid = int(rest)
|
|
except ValueError:
|
|
return f"ID invalide : {rest}"
|
|
before = len(_todos)
|
|
_todos = [t for t in _todos if t["id"] != tid]
|
|
if len(_todos) < before:
|
|
return f"Tâche #{tid} supprimée."
|
|
return f"Tâche #{tid} introuvable."
|
|
|
|
if action == "clear":
|
|
_todos = []
|
|
_next_id = 1
|
|
return "Liste de tâches vidée."
|
|
|
|
return "Action inconnue. Disponible : add, list, done, delete, clear"
|