6.6 KiB
6.6 KiB
AI & gRPC Modularity Blueprint
Date: November 16, 2025 – Author: GPT-5.1 Codex
1. Scope & Goals
- Make AI/gRPC features optional without scattering
#ifdefguards. - Ensure Windows builds succeed regardless of whether AI tooling is enabled.
- Provide a migration path toward relocatable dependencies (
ext/) and cleaner preset defaults for macOS + custom tiling window manager workflows (sketchybar/yabai/skhd, Emacs/Spacemacs).
2. Current Touchpoints
| Surface | Key Paths | Notes |
|---|---|---|
| Editor UI | src/app/editor/agent/**, app/gui/app/agent_chat_widget.cc, app/editor/agent/agent_chat_history_popup.cc |
Widgets always compile when YAZE_ENABLE_GRPC=ON, but they include protobuf types directly. |
| Core Services | src/app/service/grpc_support.cmake, app/service/*.cc, app/test/test_recorder.cc |
yaze_grpc_support bundles servers, generated protos, and even CLI code (cli/service/planning/tile16_proposal_generator.cc). |
| CLI / z3ed | src/cli/agent.cmake, src/cli/service/agent/*.cc, src/cli/service/ai/*.cc, src/cli/service/gui/*.cc |
gRPC, Gemeni/Ollama (JSON + httplib/OpenSSL) all live in one static lib. |
| Build Flags | cmake/options.cmake, scattered #ifdef Z3ED_AI and #ifdef Z3ED_AI_AVAILABLE |
Flags do not describe GUI vs CLI vs runtime needs, so every translation unit drags in gRPC headers once YAZE_ENABLE_GRPC=ON. |
| Tests & Automation | src/app/test/test_manager.cc, scripts/agent_test_suite.sh, .github/workflows/ci.yml |
Tests assume AI features exist; Windows agents hit linker issues when that assumption breaks. |
3. Coupling Pain Points
- Single Monolithic
yaze_agent– Links SDL, GUI, emulator, Abseil, yaml, nlohmann_json, httplib, OpenSSL, and gRPC simultaneously. No stubs exist when only CLI or GUI needs certain services (src/cli/agent.cmake). - Editor Hard Links –
yaze_editorunconditionally linksyaze_agentwhenYAZE_MINIMAL_BUILDisOFF, so even ROM-editing-only builds drag in AI dependencies (src/app/editor/editor_library.cmake). - Shared Proto Targets –
yaze_grpc_supportconsumes CLI proto files, so editor-only builds still compile CLI automation code (src/app/service/grpc_support.cmake). - Preprocessor Guards – UI code mixes
Z3ED_AIandZ3ED_AI_AVAILABLE; CLI code checksZ3ED_AIwhile build system only definesZ3ED_AIwhenYAZE_ENABLE_AI=ON. These mismatches cause dead code paths and missing symbols.
4. Windows Build Blockers
- Runtime library mismatch – yaml-cpp and other dependencies are built
/MTwhileyaze_emuuses/MD, causing cascades ofLNK2038and_Lockit/libcpmtconflicts (logs/windows_ci_linker_error.log). - OpenSSL duplication –
yaze_agentlinks cpp-httplib with OpenSSL while gRPC pulls BoringSSL, leading to duplicate symbol errors (libssl.libvsssl.lib) in the same log. - Missing native dialogs –
FileDialogWrappersymbols fail to link when macOS-specific implementations are not excluded on Windows (also visible in the same log). - Preset drift –
win-aienables GRPC/AI without guaranteeing vcpkg/clang-cl or ROM assets;win-dbgdisables gRPC entirely so editor agents fail to compile because of unconditional includes.
5. Proposed Modularization
| Proposed CMake Option | Purpose | Default | Notes |
|---|---|---|---|
YAZE_BUILD_AGENT_UI |
Compile ImGui agent widgets (editor). | ON for GUI presets, OFF elsewhere. |
Controls app/editor/agent/** sources. |
YAZE_ENABLE_REMOTE_AUTOMATION |
Build/ship gRPC servers & automation bridges. | ON in *-ai presets. |
Owns yaze_grpc_support + proto generation. |
YAZE_ENABLE_AI_RUNTIME |
Include AI runtime (Gemini/Ollama, CLI planners). | ON in CLI/AI presets. |
Governs cli/service/ai/**. |
YAZE_ENABLE_AGENT_CLI |
Build z3ed with full agent features. |
ON when CLI requested. |
Allows z3ed to be disabled independently. |
Implementation guidelines:
- Split Targets
yaze_agent_core: command routing, ROM helpers, no AI.yaze_agent_ai: depends on JSON + OpenSSL + remote automation.yaze_agent_ui_bridge: tiny facade that editor links only whenYAZE_BUILD_AGENT_UI=ON.
- Proto Ownership
- Keep proto generation under
yaze_grpc_support, but do not add CLI sources to that target. Instead, expose headers/libs and let CLI link them conditionally.
- Keep proto generation under
- Stub Providers
- Provide header-compatible no-op classes (e.g.,
AgentChatWidgetBridge::Create()returningnullptr) when UI is disabled, removing the need for#ifdefin ImGui panels.
- Provide header-compatible no-op classes (e.g.,
- Dependency Injection
- Replace
#ifdef Z3ED_AI_AVAILABLEinagent_chat_widget.ccwith an interface returned fromAgentFeatures::MaybeCreateChatPanel().
- Replace
6. Preset & Feature Matrix
| Preset | GUI | CLI | GRPC | AI Runtime | Agent UI |
|---|---|---|---|---|---|
mac-dbg |
✅ | ✅ | ⚪ | ⚪ | ✅ |
mac-ai |
✅ | ✅ | ✅ | ✅ | ✅ |
lin-dbg |
✅ | ✅ | ⚪ | ⚪ | ✅ |
ci-windows |
✅ | ✅ | ⚪ | ⚪ | ⚪ (core only) |
ci-windows-ai (new nightly) |
✅ | ✅ | ✅ | ✅ | ✅ |
win-dbg |
✅ | ✅ | ⚪ | ⚪ | ✅ |
win-ai |
✅ | ✅ | ✅ | ✅ | ✅ |
Legend: ✅ enabled, ⚪ disabled.
7. Migration Steps
- Define Options in
cmake/options.cmakeand propagate via presets. - Restructure Libraries:
- Move CLI AI/runtime code into
yaze_agent_ai. - Add
yaze_agent_stubfor builds without AI. - Make
yaze_editorlink against stub/real target via generator expressions.
- Move CLI AI/runtime code into
- CMake Cleanup:
- Limit
yaze_grpc_supportto gRPC-only code. - Guard JSON/OpenSSL includes behind
YAZE_ENABLE_AI_RUNTIME.
- Limit
- Windows Hardening:
- Force
/MDeverywhere and ensure yaml-cpp inheritsCMAKE_MSVC_RUNTIME_LIBRARY. - Allow only one SSL provider based on feature set.
- Add preset validation in
scripts/verify-build-environment.ps1.
- Force
- CI/CD Split:
- Current
.github/workflows/ci.ymlruns GRPC on all platforms; adjust to run minimal Windows build plus nightly AI build to save time and reduce flakiness.
- Current
- Docs + Scripts:
- Update build guides to describe new options.
- Document how macOS users can integrate headless builds with sketchybar/yabai/skhd (focus on CLI usage + automation).
- External Dependencies:
- Relocate submodules to
ext/and update scripts so the new layout is enforced before toggling feature flags.
- Relocate submodules to
8. Deliverables
- This blueprint (
docs/internal/agents/ai-modularity.md). - Updated CMake options, presets, and stubs.
- Hardened Windows build scripts/logging.
- CI/CD workflow split + release automation updates.
- Documentation refresh & dependency relocation.