This document outlines the phased development plan for integrating AI and agentic capabilities into the Kudou editor. The plan progresses from foundational UI to advanced, specialized AI systems.
Create a new, dockable panel in the editor to serve as the primary user interface for all future AI and agentic features. This establishes the physical space where the user will interact with the AI.
- A dockable panel named "AI Agent" that can be positioned alongside the "Scene" and "Inspector" docks.
- A basic UI layout inside the dock, containing a
RichTextLabelfor conversation history and aTextEditorLineEditfor user input.
editor/ai/agent_dock.h: Header defining theAgentDockclass, inheriting from aControlnode (e.g.,VBoxContainer).editor/ai/agent_dock.cpp: Implementation forAgentDock, responsible for creating and managing its child UI nodes.editor/ai/SCsub: The SCons build script for the neweditor/aidirectory.
editor/editor_node.h: Add a member variable pointer for our dock:class AgentDock; AgentDock *agent_dock;.editor/editor_node.cpp: In an initialization function (like_readyor_initialize_docks), instantiateAgentDock, give it a name and icon, and add it to aDockSlot(e.g.,dock_slot[DOCK_SLOT_RIGHT_UL]).editor/SCsub: AddSConscript("ai/SCsub")to include the new directory in the editor build module.
Bring the Agent Dock to life by enabling it to communicate with external LLM APIs and understand the user's current project context. This phase makes the agent useful.
- API Integration: Connect the dock's input to an external LLM API (e.g., OpenAI, Anthropic, or a local server) and display the response.
- File Context: Allow the user to select a file in the
FileSystemDockand have its contents automatically included in the prompt context. - Auto-Context Parser: Automatically analyze a selected GDScript file to find related scripts, attached nodes, and scene dependencies to build a more comprehensive context package for the LLM.
- Persistent Settings: Create a new section in the Editor Settings to store API keys, model preferences, and other AI-related configurations.
editor/filesystem_dock.h&.cpp: To connect to its signals (likefile_selected) to know what the user is clicking on.core/io/file_access.h&.cpp: The core class for reading the raw text content of selected script files.modules/gdscript/gdscript_parser.h&.cpp: Crucial for auto-context. Used to parse a script into an Abstract Syntax Tree (AST) to identify functions, variables, and dependencies.modules/gdscript/gdscript_analyzer.h&.cpp: Works with the parser to perform deeper semantic analysis, resolving types and node paths ($Node/Path).scene/resources/packed_scene.h&.cpp: To programmatically load and inspect.tscnfiles to understand the scene hierarchy and how scripts are attached to nodes.core/io/resource_loader.h: Use itsget_dependenciesmethod to quickly find all files a given scene or script relies on.- New File:
editor/ai/context_parser.h&.cpp: A new helper class to encapsulate the logic of using the above tools to build a final, concise context string.
core/io/http_client.h&.cpp: A low-level, non-blocking HTTP client in the C++ core, ideal for making robust API requests without freezing the editor.editor/editor_settings.h&.cpp: To add and manage a new settings category (e.g., "AI" or "Kudou") for storing API keys and model choices securely.core/os/os.h: To useshell_open()for the "open in web chat" feature, which would format a URL with the context and open it in the user's default browser.
Evolve the agent from a general-purpose assistant into a specialized Godot expert capable of understanding the engine's API on a deep level and directly modifying project files.
- Documentation-Aware Chat (RAG): Implement a Retrieval-Augmented Generation (RAG) system. When a user asks a question, Kudou will first search the Godot documentation for relevant articles and API references, then pass those findings along with the user's question to the LLM. This provides highly accurate, context-specific answers about how to use Godot.
- Agentic Code Generation: Grant the agent the ability to apply its suggestions directly to the open script in the
CodeEditor, for example, by inserting a function or refactoring a block of code with user approval.
doc/classes/*.xml: This directory (and similar ones in modules) contains the entire Godot class reference in a structured XML format. This is the source data for our RAG system.core/io/xml_parser.h&.cpp: The primary tool for parsing the.xmldocumentation files to extract class descriptions, method signatures, properties, and signals.core/string/fuzzy_search.h&.cpp: A potential built-in tool for the "retrieval" step. We can load key terms from the docs into this class to quickly find relevant topics based on the user's query. For more advanced needs, we might integrate a proper vector database library.- New File:
editor/ai/doc_retriever.h&.cpp: A new class responsible for pre-processing the XML docs on startup, storing them in a searchable index (usingFuzzySearchor another method), and providing a function to retrieve relevant doc snippets for a given query.
editor/code_editor.h&.cpp: This is the module for the main script editor. We will need to interact with theCodeEditsub-node within it.scene/gui/text_edit.h&.cpp: The baseTextEditclass provides the low-level API for programmatically interacting with the text:get_text(),insert_text_at_caret(),select(), andget_selected_text(). This is how the agent will "type" into the editor.modules/gdscript/gdscript_language_server.h&.cpp: For advanced refactoring, the agent could interface with the Language Server Protocol (LSP). This would allow it to trigger formatting, request diagnostics, or perform more complex, language-aware transformations.