Use this file to discover all available pages before exploring further.
Integrate your Koog agents directly with IntelliJ IDEA using the Agent Communication Protocol (ACP). This enables AI-powered coding assistance with full IDE context awareness.
The Agent Communication Protocol (ACP) is a standardized protocol developed by JetBrains that enables seamless integration of AI agents with development environments.Key Features:
Bidirectional communication via JSON-RPC over stdio
package ai.coding.appimport ai.coding.client.runTerminalClientimport com.agentclientprotocol.transport.PipeTransportimport kotlinx.coroutines.coroutineScopesuspend fun main() = coroutineScope { val token = System.getenv("OPENAI_API_KEY") ?: error("OPENAI_API_KEY env variable is not set") val pipe = PipeTransport.create(this) // Start agent server val agentSupport = createAgentSupport(token) val server = AgentServer(agentSupport, pipe.serverTransport) server.start() // Start client runTerminalClient(pipe.clientTransport)}
Run it:
OPENAI_API_KEY=your_key ./gradlew run --args='ai.coding.app.PipeApp'
User: Review the KoogAgentSupport.kt file and suggest improvementsAgent: [Reads file, analyzes code]I've reviewed the file. Here are my suggestions:1. Add error handling for null sessionId2. Extract agent creation into a factory class3. Add KDoc comments to public methodsWould you like me to implement these changes?
User: Extract the agent initialization logic from AcpAgent.kt into a separate AgentFactory classAgent: [Reads AcpAgent.kt, creates new AgentFactory.kt, updates AcpAgent.kt]I've created a new AgentFactory class and updated AcpAgent.kt to use it. The changes improve code organization and make the agent creation logic reusable.Changes:- Created src/main/kotlin/ai/coding/agent/AgentFactory.kt- Refactored AcpAgent.kt to use the factory- Added documentation
User: There's a null pointer exception in the session creation. Can you fix it?Agent: [Searches for session creation code, identifies issue, makes fix]Found the issue in KoogAgentSupport.kt line 42. The sessionId wasn't being validated before use.I've added null checking and a meaningful error message.
User: Add a new tool for searching code using regexAgent: [Creates RegexSearchTool.kt, updates tool registry]I've added a RegexSearchTool that searches files using regular expressions.New files:- src/main/kotlin/ai/coding/agent/tools/RegexSearchTool.ktUpdated:- KoogTools.kt to include the new toolThe tool supports searching across multiple files with pattern matching.
Modify the agent creation to use different models:
// Use GPT-4 TurbollmModel = OpenAIModels.Chat.GPT4Turbo// Use Claudeval executor = simpleAnthropicExecutor(anthropicKey)llmModel = AnthropicModels.Claude_3_5_Sonnet// Use local model via Ollamaval executor = simpleOllamaExecutor("http://localhost:11434")llmModel = OllamaModels.CodeLlama
systemPrompt = """ You are a senior Kotlin developer and code reviewer. Your expertise includes: - Kotlin best practices and idioms - Clean code principles - Design patterns - Performance optimization When reviewing code: 1. Check for potential bugs and edge cases 2. Suggest performance improvements 3. Recommend better abstractions 4. Ensure code follows Kotlin conventions Always explain your reasoning and provide examples.""".trimIndent()