MCPcopy Index your code
hub / github.com/eliran89c/klama

github.com/eliran89c/klama @v0.1.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.4 ↗ · + Follow
125 symbols 411 edges 19 files 39 documented · 31%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Klama Logo

Klama - AI-powered DevOps Debugging Assistant

Klama is a CLI tool that helps diagnose and troubleshoot DevOps-related issues using AI-powered assistance. It interacts with language models to interpret user queries, suggest and execute safe commands, and provide insights based on the results. Currently, Klama supports Kubernetes (K8s) debugging, with plans to expand to other DevOps domains in the future.

How it works

  1. Klama sends your DevOps-related query to the AI model.
  2. The AI, acting as a DevOps expert, interprets the query and may suggest commands to gather more information.
  3. If a command is suggested, Klama will ask for your approval before executing it.
  4. The command is executed if approved, and the output is sent back to the AI for further analysis.
  5. This process repeats until the AI has enough information to provide a final answer.
  6. Klama presents the AI's findings and any relevant information.

This approach ensures safety and gives users full control over the commands run in their environment.

Requirements

  • Access to a Kubernetes cluster (for K8s-related command execution)

Installation

You have several options to install Klama:

Option 1: macOS (Using Homebrew)

If you're on macOS, you can use Homebrew to install Klama:

brew install eliran89c/tap/klama

Option 2: Pre-built Binaries (Linux and Windows)

You can download pre-built binaries for Linux and Windows from the releases page on GitHub. Choose the appropriate binary for your operating system and architecture.

Option 3: Using Go

You can install Klama directly from GitHub using Go:

go install github.com/eliran89c/klama@latest

This will download the source code, compile it, and install the klama binary in your $GOPATH/bin directory. Make sure your $GOPATH/bin is in your system's PATH.

Configuration

Klama requires a YAML configuration file to set up the AI model. The configuration file is searched for in the following order:

  1. Custom location specified by the --config flag
  2. $XDG_CONFIG_HOME/klama/config.yaml (usually ~/.config/klama/config.yaml)
  3. $HOME/.klama.yaml

If no configuration file is found, a default configuration will be created at $XDG_CONFIG_HOME/klama/config.yaml.

Required Configuration

The following fields are required in your configuration:

  • agent.name: The name of the AI model
  • agent.base_url: The API endpoint for the AI model

Klama will not run if these required fields are missing from the configuration file.

OpenAI API Compatibility

Klama requires an OpenAI or OpenAI-compatible server to function. The application has been tested with the following frameworks and services:

While these have been specifically tested, any server that implements the OpenAI API should be compatible with Klama.

Sample Configuration File (.klama.yaml)

Create a file named .klama.yaml in your home directory or in the directory where you run Klama. Here's an example of what the file should contain:

agent:
  name: "anthropic.claude-3-5-sonnet-20240620-v1:0"  # Required
  base_url: "https://bedrock-gateway.example.com/api/v1"  # Required
  auth_token: ""  # Set via KLAMA_AGENT_TOKEN environment variable
  azure_api_version: "" # Required only when working with Azure AI
  pricing: # Optional, will be used to calculate session price
    input: 0.003  # Price per 1K input tokens (optional)
    output: 0.015 # Price per 1K output tokens (optional)

Environment Variables

You can set the authentication token using an environment variable:

  • KLAMA_AGENT_TOKEN: Set the authentication token for the agent model

Example:

export KLAMA_AGENT_TOKEN="your-agent-token-here"

Command-Line Configuration

You can specify a custom configuration file location using the --config flag:

klama --config /path/to/your/config.yaml k8s

Usage

Currently, Klama provides one main subcommand:

k8s: Interact with the Kubernetes debugging assistant

Run Klama with the k8s subcommand to start a Kubernetes debugging session:

klama k8s

This will start an interactive session where you can ask Kubernetes-related questions and get AI-powered assistance.

Flags

  • --config: Specify a custom configuration file location
  • --debug: Enable debug mode. (Saves output to klama.debug file)

Example with flags:

klama k8s --debug --config /path/to/config.yaml

If Klama fails to start due to missing or invalid configuration, it will provide an error message indicating the issue. Ensure that your configuration file is properly formatted and contains all required fields before running Klama.

Future Developments

While Klama currently focuses on Kubernetes debugging, there are plans to expand its capabilities to cover other DevOps domains in the future. Stay tuned for updates!

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Extension points exported contracts — how you extend this code

Agent (Interface)
Agent represents the interface for interacting with an AI agent. [2 implementers]
internal/ui/ui.go
Executer (Interface)
Executer represents the interface for executing commands. [2 implementers]
internal/ui/ui.go

Core symbols most depended-on inside this repo

InitialModel
called by 18
internal/ui/ui.go
Run
called by 17
internal/ui/ui.go
updateChat
called by 9
internal/ui/ui.go
Reset
called by 7
internal/ui/ui.go
NewTerminalExecuter
called by 6
internal/executer/terminal.go
think
called by 6
internal/ui/ui.go
Debugf
called by 5
internal/logger/logger.go
Update
called by 5
internal/ui/ui.go

Shape

Function 52
Method 45
Struct 21
TypeAlias 5
Interface 2

Languages

Go100%

Modules by API surface

internal/ui/ui.go34 symbols
internal/ui/ui_test.go23 symbols
internal/executer/terminal.go11 symbols
internal/llm/llm_test.go7 symbols
internal/executer/terminal_test.go7 symbols
internal/llm/types.go6 symbols
internal/llm/llm.go6 symbols
internal/agent/agent.go6 symbols
config/config.go6 symbols
internal/logger/logger.go3 symbols
internal/llm/models.go3 symbols
internal/agent/agent_test.go3 symbols

For agents

$ claude mcp add klama \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact