Skip to content

feat(init): interactive config wizard for rtk init #331

@FlorianBruniaux

Description

@FlorianBruniaux

Contexte

rtk init expose aujourd'hui des flags booléens qui composent mal pour un nouvel utilisateur :

rtk init -g                   # hook + RTK.md (recommended)
rtk init -g --hook-only        # hook only
rtk init -g --claude-md        # legacy 137-line injection
rtk init -g --auto-patch       # no prompt for settings.json
rtk init -g --no-patch         # print manual instructions
rtk init --show                # status only
rtk init -g --uninstall        # remove everything

Le problème : les flags sont découvrables uniquement via --help. Un nouvel utilisateur ne sait pas quoi choisir entre --hook-only, --claude-md, --auto-patch. Ce n'est pas un vrai wizard — c'est une API interne exposée comme CLI.

Proposition

Transformer rtk init en wizard interactif optionnel, avec des paramètres nommés pour les cas d'usage programmatiques.

Mode 1 — Wizard interactif (défaut sans flags)

$ rtk init --global

  RTK Setup Wizard
  ────────────────

  Where do you want RTK active?
  > [1] All Claude Code projects (recommended)
    [2] This project only

  What to install?
  > [1] Hook + RTK.md context (recommended, ~10 tokens)
    [2] Hook only (zero tokens in context)
    [3] Legacy: full instructions in CLAUDE.md (~2000 tokens)

  Patch ~/.claude/settings.json automatically?
  > [y/N]

  Summary:
    Hook    → ~/.claude/hooks/rtk-rewrite.sh ✓
    RTK.md  → ~/.claude/RTK.md ✓
    CLAUDE.md → @RTK.md added ✓
    settings.json → RTK hook registered ✓

Mode 2 — Paramètres nommés (non-interactif, CI/scripts)

# Flags explicites (comportement actuel préservé)
rtk init --global --auto-patch

# Nouveaux paramètres nommés
rtk init --global --mode=hook-only
rtk init --global --mode=full         # hook + RTK.md (défaut)
rtk init --global --mode=claude-md    # legacy

rtk init --global --patch=auto        # équivalent --auto-patch
rtk init --global --patch=manual      # équivalent --no-patch
rtk init --global --patch=ask         # défaut (prompt)

# Shorthand complet pour CI/CD
rtk init --global --yes               # accepte tout sans prompt (= --auto-patch + wizard auto)

Mode 3 — Dev hooks (nouveau)

# Pour les contributeurs du projet RTK lui-même
rtk init --dev-hooks
# → Installe .git/hooks/pre-push qui lance scripts/validate-docs.sh
# → Détecte auto qu'on est dans le repo rtk-ai/rtk via Cargo.toml name

Comportement de détection

rtk init sans flags et sans --global :

  • Si dans un repo avec CLAUDE.md local → propose local setup
  • Si hors repo → propose --global automatiquement

Non-breaking

Les flags actuels (--hook-only, --claude-md, --auto-patch, --no-patch) restent fonctionnels. Le wizard s'active uniquement quand stdin est un TTY (interactif). En non-TTY (pipe, CI), comportement actuel préservé.

Implémentation suggérée

  • Librairie pour les prompts interactifs : dialoguer (Rust, 1M+ downloads, MIT)
  • Détection TTY : atty ou std::io::IsTerminal (Rust 1.70+)
  • Non-interactif : inchangé

Critères d'acceptance

  • rtk init -g sans autres flags → lance le wizard si TTY
  • rtk init -g --yes → setup complet sans prompt
  • rtk init -g --mode=hook-only → hook uniquement
  • rtk init -g --dev-hooks → install git pre-push hook depuis scripts/validate-docs.sh
  • Tous les anciens flags continuent de fonctionner
  • rtk init --show inchangé
  • Tests : pas de régression sur run() et show_config()

Priorité

Medium — améliore significativement le DX des nouveaux utilisateurs, mais l'existant fonctionne.

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort-largePlusieurs jours, nouveau moduleenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions