understand-dashboard

Par egonex-ai · understand-anything

Lancer le tableau de bord web interactif pour visualiser le graphe de connaissances d'une base de code

npx skills add https://github.com/egonex-ai/understand-anything --skill understand-dashboard

/understand-dashboard

Démarrez le tableau de bord Understand Anything pour visualiser le graphe de connaissances du projet actuel.

Instructions

  1. Déterminez le répertoire du projet et le répertoire des données :

    • Si $ARGUMENTS contient un chemin, utilisez-le comme répertoire du projet
    • Sinon, utilisez le répertoire de travail actuel
    • Préférez le répertoire de données hérité .understand-anything/ s'il existe, sinon utilisez .ua/

    Utilisez l'outil Bash pour résoudre :

    PROJECT_ARG="$ARGUMENTS"
    if [ -n "$PROJECT_ARG" ]; then
      PROJECT_DIR=$(cd "$PROJECT_ARG" 2>/dev/null && pwd -P)
    else
      PROJECT_DIR=$(pwd -P)
    fi
    
    if [ -z "$PROJECT_DIR" ] || [ ! -d "$PROJECT_DIR" ]; then
      echo "Error: Project directory not found: ${PROJECT_ARG:-$PWD}"
      exit 1
    fi
    
    if [ -d "$PROJECT_DIR/.understand-anything" ]; then
      UA_DIR="$PROJECT_DIR/.understand-anything"
    else
      UA_DIR="$PROJECT_DIR/.ua"
    fi
  2. Vérifiez que $UA_DIR/knowledge-graph.json existe dans le répertoire du projet. Si ce n'est pas le cas, informez l'utilisateur :

    No knowledge graph found. Run /understand first to analyze this project.

    Utilisez l'outil Bash pour vérifier :

    if [ ! -f "$UA_DIR/knowledge-graph.json" ]; then
      echo "No knowledge graph found. Run /understand first to analyze this project."
      exit 1
    fi
  3. Trouvez le code du tableau de bord. Le tableau de bord se trouve dans packages/dashboard/ relatif à la racine de ce plugin. Vérifiez ces chemins dans l'ordre et utilisez le premier qui existe :

    • ${CLAUDE_PLUGIN_ROOT}/packages/dashboard/ (racine du runtime Claude Code, priorité la plus élevée)
    • ~/.understand-anything-plugin/packages/dashboard/ (symlink universel, toutes les installations)
    • Deux niveaux au-dessus du chemin réel de ~/.agents/skills/understand-dashboard (repli auto-relatif)
    • Deux niveaux au-dessus du chemin réel de ~/.copilot/skills/understand-dashboard (repli des skills personnels Copilot)
    • Racines d'installation courantes basées sur clonage :
      • ~/.codex/understand-anything/understand-anything-plugin/packages/dashboard/
      • ~/.opencode/understand-anything/understand-anything-plugin/packages/dashboard/
      • ~/.pi/understand-anything/understand-anything-plugin/packages/dashboard/
      • ~/understand-anything/understand-anything-plugin/packages/dashboard/

    Utilisez l'outil Bash pour résoudre :

    SKILL_REAL=$(realpath ~/.agents/skills/understand-dashboard 2>/dev/null || readlink -f ~/.agents/skills/understand-dashboard 2>/dev/null || echo "")
    SELF_RELATIVE=$([ -n "$SKILL_REAL" ] && cd "$SKILL_REAL/../.." 2>/dev/null && pwd || echo "")
    COPILOT_SKILL_REAL=$(realpath ~/.copilot/skills/understand-dashboard 2>/dev/null || readlink -f ~/.copilot/skills/understand-dashboard 2>/dev/null || echo "")
    COPILOT_SELF_RELATIVE=$([ -n "$COPILOT_SKILL_REAL" ] && cd "$COPILOT_SKILL_REAL/../.." 2>/dev/null && pwd || echo "")
    
    PLUGIN_ROOT=""
    for candidate in \
      "${CLAUDE_PLUGIN_ROOT}" \
      "$HOME/.understand-anything-plugin" \
      "$SELF_RELATIVE" \
      "$COPILOT_SELF_RELATIVE" \
      "$HOME/.codex/understand-anything/understand-anything-plugin" \
      "$HOME/.opencode/understand-anything/understand-anything-plugin" \
      "$HOME/.pi/understand-anything/understand-anything-plugin" \
      "$HOME/understand-anything/understand-anything-plugin"; do
      if [ -n "$candidate" ] && [ -d "$candidate/packages/dashboard" ]; then
        PLUGIN_ROOT="$candidate"; break
      fi
    done
    
    if [ -z "$PLUGIN_ROOT" ]; then
      echo "Error: Cannot find the understand-anything plugin root."
      echo "Checked:"
      echo "  - ${CLAUDE_PLUGIN_ROOT:-<unset CLAUDE_PLUGIN_ROOT>}"
      echo "  - $HOME/.understand-anything-plugin"
      echo "  - ${SELF_RELATIVE:-<unresolved path derived from ~/.agents/skills/understand-dashboard>}"
      echo "  - ${COPILOT_SELF_RELATIVE:-<unresolved path derived from ~/.copilot/skills/understand-dashboard>}"
      echo "  - $HOME/.codex/understand-anything/understand-anything-plugin"
      echo "  - $HOME/.opencode/understand-anything/understand-anything-plugin"
      echo "  - $HOME/.pi/understand-anything/understand-anything-plugin"
      echo "  - $HOME/understand-anything/understand-anything-plugin"
      echo "Make sure you followed the installation instructions for your platform."
      exit 1
    fi
    
    DASHBOARD_DIR="$PLUGIN_ROOT/packages/dashboard"
  4. Chemin rapide — essayez d'abord la visionneuse précompilée (sans installation, sans compilation). Chaque version contient une archive visionneuse autonome ; exécutez-la verrouillée à la version du plugin installée :

    : "${PLUGIN_ROOT:?Run step 3 first so PLUGIN_ROOT is set}"
    : "${PROJECT_DIR:?Run step 1 first so PROJECT_DIR is set}"
    PLUGIN_VERSION=$(node -p "require('$PLUGIN_ROOT/package.json').version")
    VIEWER_URL="https://github.com/Egonex-AI/Understand-Anything/releases/download/v${PLUGIN_VERSION}/understand-anything-viewer.tgz"
    npx --yes "$VIEWER_URL" "$PROJECT_DIR"

    Exécutez-la en arrière-plan. Elle affiche la même ligne 🔑 Dashboard URL que le serveur de développement :

    • Si la ligne s'affiche, ignorez les étapes 5-6 et continuez à l'étape 7.
    • Si le processus se termine sans l'afficher (pas de ressource de version pour cette version, ou pas de réseau), revenez aux étapes 5-6.
  5. Repli : installez les dépendances et compilez si nécessaire :

    : "${PLUGIN_ROOT:?Run step 3 first so PLUGIN_ROOT is set}"
    DASHBOARD_DIR="${DASHBOARD_DIR:-$PLUGIN_ROOT/packages/dashboard}"
    cd "$DASHBOARD_DIR" && (pnpm install --frozen-lockfile 2>/dev/null || pnpm install)

    Ensuite, assurez-vous que le package core est construit (le tableau de bord en dépend) :

    : "${PLUGIN_ROOT:?Run step 3 first so PLUGIN_ROOT is set}"
    cd "$PLUGIN_ROOT" && pnpm --filter @understand-anything/core build
  6. Repli : démarrez le serveur de développement Vite pointant vers le graphe de connaissances du projet :

    : "${PROJECT_DIR:?Run step 1 first so PROJECT_DIR is set}"
    : "${DASHBOARD_DIR:?Run step 5 first so DASHBOARD_DIR is set}"
    cd "$DASHBOARD_DIR" && GRAPH_DIR="$PROJECT_DIR" npx vite --host 127.0.0.1

    Exécutez-le en arrière-plan pour que l'utilisateur puisse continuer à travailler.

  7. Capturez l'URL du jeton d'accès à partir de la sortie du serveur. Le serveur (visionneuse ou Vite) affiche une ligne comme :

    🔑  Dashboard URL: http://127.0.0.1:<PORT>?token=<TOKEN>

    Extrayez l'URL complète incluant le paramètre ?token=. Le jeton est requis pour accéder aux données du graphe de connaissances — sans lui, le tableau de bord affichera un portail « Access Token Required ».

  8. Signalez à l'utilisateur, en incluant l'URL complète avec jeton :

    Dashboard started at http://127.0.0.1:<PORT>?token=<TOKEN>
    Viewing: $UA_DIR/knowledge-graph.json
    
    The dashboard is running in the background. Press Ctrl+C in the terminal to stop it.

    Important : Incluez toujours le paramètre ?token= dans l'URL que vous partagez. Si vous l'omettez, l'utilisateur sera bloqué par le portail de jeton et devra trouver manuellement le jeton dans la sortie du terminal.

Notes

  • Le chemin rapide (étape 4) télécharge une visionneuse autonome verrouillée à la version à partir de la version GitHub — rien n'est installé dans le répertoire du plugin et aucune compilation ne s'exécute
  • Le tableau de bord s'ouvre automatiquement dans le navigateur par défaut (tant la visionneuse que l'option --open de Vite)
  • Si le port 5173 est déjà utilisé, le prochain port disponible est sélectionné (les deux chemins)
  • En repli, la variable d'environnement GRAPH_DIR indique au serveur de développement où trouver le graphe de connaissances

Skills similaires