From 230c55c432499e442060c6ae04927c81596a0f51 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Thu, 12 Mar 2026 02:51:01 -0400 Subject: [PATCH] [ADD] todo: add RTK management menu Integrate RTK (Rust Token Killer) into the interactive CLI to let users install, configure, and monitor token savings directly from the ERPLibre todo interface. Generated by Claude Code 2.1.74 model claude-sonnet-4-6 Co-Authored-By: Mathieu Benoit --- script/todo/todo.py | 113 +++++++++++++++++++++++++++++++++++++++ script/todo/todo_i18n.py | 65 ++++++++++++++++++++++ 2 files changed, 178 insertions(+) diff --git a/script/todo/todo.py b/script/todo/todo.py index 88b2102..98a27d6 100755 --- a/script/todo/todo.py +++ b/script/todo/todo.py @@ -775,6 +775,7 @@ class TODO: print(f"🤖 {t('gpt_code_manage')}") choices = [ {"prompt_description": t("gpt_code_claude_commit")}, + {"prompt_description": t("menu_rtk")}, ] help_info = self.fill_help_info(choices) @@ -785,6 +786,8 @@ class TODO: return False elif status == "1": self._setup_claude_commit() + elif status == "2": + self.prompt_execute_rtk() else: print(t("cmd_not_found")) @@ -926,6 +929,116 @@ class TODO: ) print(t("kill_git_daemon_done")) + def prompt_execute_rtk(self): + print(f"🤖 {t('rtk_manage')}") + choices = [ + {"prompt_description": t("rtk_install")}, + {"prompt_description": t("rtk_version")}, + {"prompt_description": t("rtk_gain")}, + {"prompt_description": t("rtk_discover")}, + {"prompt_description": t("rtk_init_global")}, + {"prompt_description": t("rtk_status")}, + ] + help_info = self.fill_help_info(choices) + + while True: + status = click.prompt(help_info) + print() + if status == "0": + return False + elif status == "1": + self.rtk_install() + elif status == "2": + self.rtk_check_version() + elif status == "3": + self.rtk_show_gain() + elif status == "4": + self.rtk_discover() + elif status == "5": + self.rtk_init_global() + elif status == "6": + self.rtk_check_status() + else: + print(t("cmd_not_found")) + + def rtk_install(self): + print(f"🤖 {t('rtk_install_method')}") + choices = [ + {"prompt_description": t("rtk_install_curl")}, + {"prompt_description": t("rtk_install_brew")}, + {"prompt_description": t("rtk_install_cargo")}, + ] + help_info = self.fill_help_info(choices) + status = click.prompt(help_info) + print() + if status == "0": + return + elif status == "1": + self.execute.exec_command_live( + "curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh", + source_erplibre=False, + ) + elif status == "2": + self.execute.exec_command_live( + "brew install rtk", + source_erplibre=False, + ) + elif status == "3": + self.execute.exec_command_live( + "cargo install --git https://github.com/rtk-ai/rtk", + source_erplibre=False, + ) + else: + print(t("cmd_not_found")) + + def rtk_check_version(self): + self.execute.exec_command_live( + "rtk --version", + source_erplibre=False, + ) + + def rtk_show_gain(self): + self.execute.exec_command_live( + "rtk gain", + source_erplibre=False, + ) + + def rtk_discover(self): + self.execute.exec_command_live( + "rtk discover", + source_erplibre=False, + ) + + def rtk_init_global(self): + self.execute.exec_command_live( + "rtk init --global", + source_erplibre=False, + ) + + def rtk_check_status(self): + rtk_path = shutil.which("rtk") + if rtk_path is None: + print(t("rtk_not_installed")) + return + + result = self.execute.exec_command_live( + "rtk --version", + source_erplibre=False, + quiet=True, + return_status_and_output=True, + ) + if isinstance(result, tuple) and result[0] == 0: + version_output = " ".join(result[1]).strip() + print(f"{t('rtk_installed_version')}{version_output}") + else: + print(f"{t('rtk_installed_version')}?") + + config_path = os.path.expanduser("~/.config/rtk/config.toml") + if os.path.exists(config_path): + print(t("rtk_hook_active")) + else: + print(t("rtk_hook_inactive")) + def prompt_execute_config(self): print(f"🤖 {t('config_manage')}") choices = [ diff --git a/script/todo/todo_i18n.py b/script/todo/todo_i18n.py index a4f3ca3..9310329 100644 --- a/script/todo/todo_i18n.py +++ b/script/todo/todo_i18n.py @@ -96,10 +96,75 @@ TRANSLATIONS = { "fr": "Sécurité - Audit de sécurité des dépendances", "en": "Security - Dependency security audit", }, + "menu_rtk": { + "fr": "RTK - Proxy CLI pour réduire la consommation de tokens LLM", + "en": "RTK - CLI proxy to reduce LLM token consumption", + }, "menu_lang": { "fr": "Langue - Changer la langue / Change language", "en": "Language - Change language / Changer la langue", }, + # RTK (Rust Token Killer) + "rtk_manage": { + "fr": "Gérer RTK (Rust Token Killer) pour optimiser les tokens!", + "en": "Manage RTK (Rust Token Killer) for token optimization!", + }, + "rtk_install": { + "fr": "Installer RTK", + "en": "Install RTK", + }, + "rtk_version": { + "fr": "Vérifier la version de RTK", + "en": "Check RTK version", + }, + "rtk_gain": { + "fr": "Afficher les économies de tokens cumulées", + "en": "Show cumulative token savings", + }, + "rtk_discover": { + "fr": "Identifier les opportunités d'optimisation", + "en": "Discover optimization opportunities", + }, + "rtk_init_global": { + "fr": "Initialiser le hook auto-rewrite global", + "en": "Initialize global auto-rewrite hook", + }, + "rtk_status": { + "fr": "Vérifier le statut de RTK", + "en": "Check RTK status", + }, + "rtk_not_installed": { + "fr": "RTK n'est pas installé. Utilisez l'option 1 pour l'installer.", + "en": "RTK is not installed. Use option 1 to install it.", + }, + "rtk_installed_version": { + "fr": "RTK est installé, version : ", + "en": "RTK is installed, version: ", + }, + "rtk_hook_active": { + "fr": "Hook auto-rewrite global : actif", + "en": "Global auto-rewrite hook: active", + }, + "rtk_hook_inactive": { + "fr": "Hook auto-rewrite global : inactif", + "en": "Global auto-rewrite hook: inactive", + }, + "rtk_install_method": { + "fr": "Méthode d'installation :", + "en": "Installation method:", + }, + "rtk_install_curl": { + "fr": "curl - Script d'installation automatique", + "en": "curl - Automatic install script", + }, + "rtk_install_brew": { + "fr": "brew - Homebrew (macOS/Linux)", + "en": "brew - Homebrew (macOS/Linux)", + }, + "rtk_install_cargo": { + "fr": "cargo - Compilation depuis les sources (Rust requis)", + "en": "cargo - Build from source (Rust required)", + }, # Prompts and messages "enter_password": { "fr": "Entrez votre mot de passe : ",