An AI assistant integrated into Kate that replicates Zed Editor's agent functionality: LLM chat, tool execution, context from open buffers, and iteration loops.
- Real-time chat with token streaming support
- Compatible with any OpenAI-compatible API (OpenAI, Anthropic, Ollama, LM Studio, etc.)
- Flexible configuration: API key, base URL, model, system prompt
The plugin automatically executes tools based on LLM instructions:
| Tool | Description |
|---|---|
| ReadFile | Reads files from the filesystem |
| EditFile | Modifies files with applyable diffs |
| Grep | Searches patterns in the project |
| Terminal | Executes commands (sandboxed) |
| WebSearch | Searches via DuckDuckGo |
Security sandboxing: Terminal commands block rm, curl, wget, sh, bash, cp, mv, python, perl, ruby for protection.
- Automatically detects files open in Kate
- Injects context into LLM prompts (limit: 2000 characters)
- Configurable toggle in settings
- LLM β Tool β Result β LLM (automatic cycle)
- Up to 20 iterations to prevent infinite loops
- Tool output displayed inline in the chat
- Automatic thread saving to JSON files
- Conversation history loading
- Path:
~/.config/kate/agents/
Three modes for different scenarios:
| Profile | Use |
|---|---|
| Write | Code writing, substantial changes |
| Ask | Questions, explanations, debugging |
| Minimal | Concise responses, reduced context |
- Type
@for file autocomplete - Fuzzy search on project paths
- Support for URLs and web searches
- Side-by-side preview before applying changes
- Multi-file support
- Explicit user confirmation required
- Timestamped backups before every modification:
.bak.YYYYMMDD-HHMMSS - Maximum 5 backups per file (oldest are deleted)
- Easy recovery of previous file versions
- Inline suggestions while typing
- Accept with Tab key
- Implemented via KTextEditor InlineNoteProvider API
- Right-click in editor β "Ask agent about this"
- Sends current selection to the agent
Accessible from: Settings β Configure Kate β Plugins β Kate Agent
Available settings:
- API Key
- Base URL (for self-hosted providers)
- Model (e.g.,
gpt-4,claude-3,llama3) - Custom system prompt
- Buffer context toggle (enabled by default)
- Kate β₯ 23.08 (KTextEditor KF6)
- Qt 6.4+
- CMake 3.16+
- GCC/Clang with C++17 support
cd kate-agent-plugin
cmake -S . -B build
cmake --build build -j$(nproc)
sudo cmake --install build# Copy the library
sudo cp build/libkateagentplugin.so \
/usr/lib/x86_64-linux-gnu/qt6/plugins/kf6/ktexteditor/
# Copy the metadata file
sudo cp src/kateagentplugin.json \
/usr/lib/x86_64-linux-gnu/qt6/plugins/kf6/ktexteditor/- Open Kate
- Go to
Settings β Configure Kate β Plugins - Enable Kate Agent Plugin
- Restart Kate
- Press
Ctrl+Alt+Ato open the panel
- Open the Agent panel (
Ctrl+Alt+A) - Click the gear icon (βοΈ)
- Enter:
- API Key: Your API key
- Base URL:
https://api.openai.com/v1(or self-hosted) - Model:
gpt-4o,claude-3-5-sonnet,llama3:70b, etc. - System prompt: (optional) customize behavior
- Type your request in the input field
- Use
@to mention specific files - Select the profile (Write/Ask/Minimal)
- Press Enter
The agent will respond and can:
- Read files
- Execute searches
- Modify code (with confirmation)
- Execute safe commands
When the agent proposes changes:
- Tab: Accept the suggestion
- Esc: Reject
- Shift+Tab: Accept line by line
Before important modifications:
- Click the "checkpoint" icon in the panel
- A timestamped backup will be created
- Recover from
file.bak.YYYYMMDD-HHMMSS
Problem: The plugin cannot access Kate's integrated LSP Client.
What's missing:
- Jump to definition (CTRL+click)
- Cross-file symbol search
- Hover information
- Intelligent completion based on LSP
Current fallback:
- Regex search on open files
- Works only for symbols in documents currently open in Kate
- Does not index the entire project
Temporary solution:
- Enable Kate's "LSP Client" plugin (
Settings β Configure Kate β Plugins) - Install appropriate language servers (clangd, rust-analyzer, pylsp)
- Kate will handle them internally (but my plugin cannot use them directly)
Future plan:
- Wait for KTextEditor to expose a public API for the LSP client
- Or implement a standalone LSP client (complex, not priority)
| Feature | Status | Notes |
|---|---|---|
| Multi-file edit (batch) | Diff preview works, batch editing no | |
| Codebase indexing | β No | Only open files, not entire project |
| LSP hover | β No | Requires exposed LSP API |
| Go to definition | β No | Requires real LSP |
| Test UI/E2E | 4/7 unit tests passing |
# Run all tests
cd build
ctest --output-on-failure
# Specific tests
./tests/test_configmanager
./tests/test_checkpointmanager
./tests/test_editorcontext
./tests/test_threadjsonstoragecmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build -j$(nproc)# Install to ~/.local
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=$HOME/.local
cmake --build build
cmake --install build
# Manually copy to ~/.local/lib/qt6/plugins/ktexteditor/Set environment variable:
export KATEAGENT_DEBUG=1
kate