You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update docs: handler/runtime layer, reload workflow, Codex client, test counts
CLAUDE.md:
- Add streamable-http transport to architecture
- Document handler/runtime abstraction pattern
- Update 'adding a new tool' steps for handler layer
- Add Codex to client configuration list
- Document reload_plugin tool and ASGI reload path
- Update test count: 81 -> 140
implementation-plan.md:
- Mark CI setup tasks as done (Tier 1+2, Codecov, badges)
- Add reload workflow items as completed
- Add Codex client and handler/runtime layer as completed
- Update test count: 125 -> 184
- Add project_handler.gd to plugin file listing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
-**GDScript plugin**: `plugin/addons/godot_ai/` — canonical source; copied into `test_project/addons/` for testing
14
+
-**GDScript plugin**: `plugin/addons/godot_ai/` — canonical source; symlinked into `test_project/addons/` for testing
15
15
-**Protocol**: JSON over WebSocket. Request/response with `request_id` correlation. Handshake on connect.
16
16
-**Session model**: Multiple Godot editors can connect. Tools route through active session.
17
+
-**Handler/Runtime layer**: Shared handlers in `src/godot_ai/handlers/` contain tool logic. They depend on a `Runtime` protocol (`runtime/interface.py`), implemented by `DirectRuntime` for the in-process server. Tools and resources are thin wrappers that create a runtime and delegate.
17
18
18
19
## Key conventions
19
20
20
21
-**GDScript plugin is the canonical copy** in `plugin/`. `test_project/addons/godot_ai` is a symlink — no copy needed.
21
22
-**Error codes**: Defined in `protocol/errors.py` (Python) and `utils/error_codes.gd` (GDScript). Keep in sync.
22
-
-**Tools return `dict`**: `GodotClient.send()` returns `response.data` (a dict) or raises`GodotCommandError`. Tools just `return await app.client.send(...)`.
23
+
-**Tools return `dict`**: Handlers call `runtime.send_command(command, params)`which returns a dict or raises. Tools create a `DirectRuntime` and delegate to handlers.
23
24
-**Plugin runs on main thread**: All GDScript executes in `_process()` with a 4ms frame budget. Never block. Use `call_deferred` for scene tree mutations.
24
25
-**Scene paths are clean**: `/Main/Camera3D` format, not raw Godot internal paths. Use `ScenePath.from_node(node, scene_root)` in GDScript.
25
26
-**MCP logging**: Plugin prints `MCP | [recv] command(params)` / `MCP | [send] command -> ok` to Godot console. Controlled by `mcp_logging` var.
@@ -40,21 +41,26 @@ ruff format src/ tests/ # format
40
41
### Server lifecycle in dev
41
42
42
43
The plugin manages the server process:
43
-
-**Reload Plugin** in the Godot dock kills the old server, starts a new one from `.venv/bin/python -m godot_ai`
44
-
- After Reload Plugin, do `/mcp` in Claude Code to reconnect
45
-
46
-
The plugin prefers the local `.venv` over system-installed `godot-ai` so dev checkouts always use source code.
44
+
- On startup, plugin checks if port 8000 is already in use. If yes, uses existing server. If no, spawns `.venv/bin/python -m godot_ai --transport streamable-http --port 8000`.
45
+
- The plugin prefers the local `.venv` over system-installed `godot-ai` so dev checkouts always use source code.
47
46
48
47
For Python auto-reload during dev (no need to touch Godot):
This uses `src/godot_ai/asgi.py` to run uvicorn with its factory reload path. Uvicorn watches `src/` for changes and restarts the server process automatically. The plugin auto-reconnects.
52
+
53
+
### Plugin reload
54
+
55
+
The `reload_plugin` MCP tool triggers a live plugin reload inside Godot (`EditorInterface.set_plugin_enabled` off/on). Requires the server to be running externally (not managed by the plugin). The Python handler waits for the new session via `SessionRegistry.wait_for_session()`.
56
+
57
+
The Godot dock also has a **Start/Stop Dev Server** button for convenience.
0 commit comments