A Kate text editor plugin that wraps Claude Code using claude-code-acp.
cmake -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build buildcmake --install build --prefix ~/.localThen restart Kate and enable the plugin via: Settings > Configure Kate > Plugins > Enable "Kate Code"
- Plugin: KateCodePlugin, KateCodeView - Kate integration
- ACP: ACPService, ACPSession - JSON-RPC 2.0 over stdin/stdout to claude-code-acp
- MCP: MCPServer - Built-in MCP server executable for Kate editor tools
- UI: ChatWidget, ChatWebView, ChatInputWidget, PermissionDialog
- Util: KDEColorScheme - reads ~/.config/kdeglobals
src/plugin/KateCodePlugin.{h,cpp}- Plugin registration via K_PLUGIN_CLASS_WITH_JSONsrc/plugin/KateCodeView.{h,cpp}- Creates side panel tool view, provides Kate contextsrc/acp/ACPService.{h,cpp}- QProcess-based claude-code-acp subprocess managementsrc/acp/ACPSession.{h,cpp}- Protocol flow and session state managementsrc/acp/ACPModels.h- Data structures (Message, ToolCall, TodoItem, etc.)src/mcp/MCPServer.{h,cpp}- MCP protocol handler (initialize, tools/list, tools/call)src/mcp/main.cpp- MCP server entry point (stdio JSON-RPC loop)src/ui/ChatWidget.{h,cpp}- Main chat interface with ACP integrationsrc/ui/ChatWebView.{h,cpp}- QWebEngineView for HTML/CSS/JS renderingsrc/ui/ChatInputWidget.{h,cpp}- Multiline text input with send buttonsrc/ui/PermissionDialog.{h,cpp}- Modal dialog for tool approval requestssrc/config/SettingsStore.{h,cpp}- QSettings + KWallet storage, ACPProvider managementsrc/config/KateCodeConfigPage.{h,cpp}- Kate config page with provider table, diff colors, summariessrc/util/KDEColorScheme.{h,cpp}- KDE color extraction from kdeglobalssrc/web/chat.{html,css,js}- Web assets for chat interfacesrc/katecode.qrc- Qt resource file for web assetssrc/katecode.json- KPlugin metadata
- Must include
<KLocalizedString>for i18n() function - KF6 components needed: I18n, TextEditor, CoreAddons, XmlGui
- Qt6 components: Core, Widgets, WebEngineWidgets
- Use
createToolView()withKTextEditor::MainWindow::Leftfor side panel - K_PLUGIN_CLASS_WITH_JSON macro requires katecode.json in same directory
- Plugin views are children of MainWindow and cleaned up automatically
- JSON-RPC 2.0 over stdin/stdout with newline-delimited JSON
- Flow:
initialize(protocolVersion: 1) →session/new(cwd, mcpServers) →session/prompt - Streaming updates via
session/updatenotifications with sessionUpdate types:agent_message_start,agent_message_chunk,agent_message_endtool_call,tool_call_updateplan(todos)
- Permission requests via
session/request_permissionwith requestId that requires response
- Providers are defined by
ACPProviderstruct: id, description, executable, options, builtin flag - Two built-in providers (Claude Code, Vibe/Mistral) are hardcoded and cannot be deleted
- Custom providers are stored in QSettings via
beginWriteArray("ACP/customProviders") - Active provider selection persisted as
ACP/activeProviderstring id - Provider selector is a QComboBox in the ChatWidget header (disabled while connected)
- Unavailable executables shown grayed with "(not found)" suffix
- Settings page shows a QTableWidget for managing custom providers (add/edit/remove)
- Old
ACPBackendenum settings are auto-migrated on first launch
- QWebEngineView loads HTML from Qt resources (qrc:/katecode/web/chat.html)
- JavaScript functions exposed:
addMessage(),updateMessage(),finishMessage(),addToolCall(),updateToolCall() - C++ calls JavaScript via
page()->runJavaScript()with proper string escaping - CSS uses CSS variables for theming (ready for KDE color injection in Phase 4)
- Responsive layout with message bubbles, tool call display, and streaming indicator