Skip to content

Feature: Update kdm analyze command to be interactive #139

@utkarsh232005

Description

@utkarsh232005

🎯 Goal

Convert the kdm analyze command from static text output into a split-pane diagnostic dashboard with an error list, AI-powered explanations, and executable fix suggestions.


📌 Current Behavior

kdm analyze scans Kubernetes resources for configuration errors and operational problems. Supports AI-powered troubleshooting explanations.

Key Options:

Flag Description
-n, --namespace <ns> Limit to a specific namespace
-f, --filter <filter> Run a specific analyzer (e.g., Pod, Ingress)
-e, --explain AI-powered diagnosis explanations
-b, --backend <backend> Force a specific AI backend
-o, --output <format> Output format: text or json
-a, --anonymize Mask resource names in AI prompt

Example usage:

kdm analyze
kdm analyze -n default --explain
kdm analyze --explain --backend ollama --language spanish

🚀 Proposed Interactive Dashboard

Layout

┌───────────────────┬──────────────────────────────────────┐
│   Errors (3)      │   AI Explanation                     │
├───────────────────┼──────────────────────────────────────┤
│                   │                                      │
│ > ✖ CrashLoop     │  Cause:                              │
│   ✖ DNS Error     │  Container exceeded memory limit.    │
│   ✖ OOMKilled     │                                      │
│                   │  Fix:                                │
│                   │  kubectl edit deployment app          │
│                   │                                      │
│                   │  Increase memory:                    │
│                   │  512Mi -> 1Gi                        │
│                   │                                      │
│                   │  Press ENTER to execute fix.          │
├───────────────────┴──────────────────────────────────────┤
│  N:Namespace  B:Backend  ENTER:Execute Fix  Q:Quit       │
└──────────────────────────────────────────────────────────┘

User Flow

  1. User runs kdm analyze → left panel lists detected errors, right panel is empty.
  2. Use / to select an error on the left.
  3. The right panel asynchronously loads the AI explanation (loading spinner while fetching).
  4. If a fix command is suggested, highlight it and press Enter to execute it directly.
  5. Press n to open a namespace selector popup:
  Select namespace:
  > default
    production
    staging
  1. Press b to switch the AI backend provider.

Keyboard Shortcuts

Key Action
/ Navigate error list
Enter Execute suggested fix command
n Switch namespace
b Change AI backend
Q Quit

Recommended Libraries

Component Library
Markdown rendering marked + custom terminal renderer
Links terminal-link
Spinner ink-spinner
Split layout Ink <Box> flexbox

📋 Contribution Workflow

  1. Fork the repo and create a feature branch (e.g., feature/interactive-kdm-analyze).
  2. Implement the interactive TUI for kdm analyze using the layout and flow described above.
  3. Submit a PR explicitly linked to this issue (e.g., Closes #139).
  4. 📸 Include a screenshot or recording of the implemented UI in your PR to verify the new dashboard experience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions