From a5d98ad83ce8f9530079bb40b1dda585e9f9247c Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 16 Nov 2025 18:27:37 -0500 Subject: [PATCH] refactor: reorganize submodule structure and enhance CMake configuration - Moved all third-party libraries (SDL, ImGui, Asar, etc.) from `src/lib/` and `third_party/` to a new `ext/` directory for better organization and clarity in dependency management. - Updated CMake configuration to reflect the new paths, ensuring all targets and includes point to the `ext/` directory. - Enhanced CMake presets to support new build options for AI and gRPC features, improving modularity and build flexibility. - Added new feature flags for agent UI and remote automation, allowing for more granular control over build configurations. - Updated documentation to reflect changes in the project structure and build options, ensuring clarity for contributors and users. --- .github/actions/run-tests/action.yml | 15 ++- .github/workflows/ci.yml | 42 ++++++- .github/workflows/release.yml | 17 +++ .gitmodules | 28 ++--- CMakeLists.txt | 4 +- CMakePresets.json | 113 ++++++++++++++++-- README.md | 21 +++- cmake/asar.cmake | 2 +- cmake/dependencies/imgui.cmake | 10 +- cmake/dependencies/json.cmake | 11 +- cmake/options.cmake | 44 ++++++- cmake/sdl2.cmake | 18 +-- docs/internal/agents/ai-modularity.md | 100 ++++++++++++++++ docs/internal/legacy/BUILD-GUIDE.md | 4 +- docs/public/build/build-from-source.md | 37 +++++- .../developer/dependency-architecture.md | 7 +- {src/lib => ext}/SDL | 0 {src/lib => ext}/asar | 0 {third_party => ext}/httplib | 0 {src/lib => ext}/imgui | 0 {src/lib => ext}/imgui_test_engine | 0 {third_party => ext}/json | 0 {src/lib => ext}/nativefiledialog-extended | 0 scripts/README.md | 22 ++++ scripts/setup-vcpkg-windows.ps1 | 24 ++++ scripts/verify-build-environment.ps1 | 90 +++++++++++++- scripts/verify-build-environment.sh | 22 ++-- src/CMakeLists.txt | 2 +- src/app/app.cmake | 14 +-- src/app/editor/editor_library.cmake | 18 +-- src/app/net/net_library.cmake | 10 +- src/app/service/grpc_support.cmake | 12 +- src/app/test/test.cmake | 4 +- src/cli/agent.cmake | 70 +++++++---- src/core/CMakeLists.txt | 10 +- src/ios/yaze.xcodeproj/project.pbxproj | 20 ++-- src/util/util.cmake | 1 + test/CMakeLists.txt | 14 +-- test/e2e/README.md | 4 +- 39 files changed, 654 insertions(+), 156 deletions(-) create mode 100644 docs/internal/agents/ai-modularity.md rename {src/lib => ext}/SDL (100%) rename {src/lib => ext}/asar (100%) rename {third_party => ext}/httplib (100%) rename {src/lib => ext}/imgui (100%) rename {src/lib => ext}/imgui_test_engine (100%) rename {third_party => ext}/json (100%) rename {src/lib => ext}/nativefiledialog-extended (100%) diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml index 75009e34..6c5d907d 100644 --- a/.github/actions/run-tests/action.yml +++ b/.github/actions/run-tests/action.yml @@ -12,12 +12,21 @@ inputs: runs: using: 'composite' steps: + - name: Select test preset suffix + shell: bash + run: | + if [ "${{ inputs.preset }}" = "ci-windows-ai" ]; then + echo "CTEST_SUFFIX=-ai" >> $GITHUB_ENV + else + echo "CTEST_SUFFIX=" >> $GITHUB_ENV + fi + - name: Run stable tests if: inputs.test-type == 'stable' || inputs.test-type == 'all' shell: bash run: | cd build - ctest --preset stable \ + ctest --preset stable${CTEST_SUFFIX} \ --output-on-failure \ --output-junit stable_test_results.xml || true @@ -26,7 +35,7 @@ runs: shell: bash run: | cd build - ctest --preset unit \ + ctest --preset unit${CTEST_SUFFIX} \ --output-on-failure \ --output-junit unit_test_results.xml || true @@ -35,7 +44,7 @@ runs: shell: bash run: | cd build - ctest --preset integration \ + ctest --preset integration${CTEST_SUFFIX} \ --output-on-failure \ --output-junit integration_test_results.xml || true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1b10d54..0ec20122 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: os: macos-14 platform: macos preset: ci-macos - - name: "Windows 2022 (MSVC)" + - name: "Windows 2022 (Core)" os: windows-2022 platform: windows preset: ci-windows @@ -111,7 +111,7 @@ jobs: os: macos-14 platform: macos preset: ci-macos - - name: "Windows 2022" + - name: "Windows 2022 (Core)" os: windows-2022 platform: windows preset: ci-windows @@ -148,6 +148,44 @@ jobs: test-type: unit preset: ${{ matrix.preset }} + windows-agent: + name: "Windows Agent (Full Stack)" + runs-on: windows-2022 + needs: [build, test] + if: github.event_name != 'pull_request' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup build environment + uses: ./.github/actions/setup-build + with: + platform: windows + preset: ci-windows-ai + cache-key: ${{ hashFiles('cmake/dependencies.lock') }} + + - name: Build project + uses: ./.github/actions/build-project + with: + platform: windows + preset: ci-windows-ai + build-type: ${{ env.BUILD_TYPE }} + + - name: Run stable tests (agent stack) + uses: ./.github/actions/run-tests + with: + test-type: stable + preset: ci-windows-ai + + - name: Run unit tests (agent stack) + uses: ./.github/actions/run-tests + with: + test-type: unit + preset: ci-windows-ai + code-quality: name: "Code Quality" runs-on: ubuntu-22.04 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b2c183fe..31d51d14 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,6 +69,15 @@ jobs: cpack -G DragNDrop ls -la _CPack_Packages/ + - name: Create notarized bundle (macOS) + if: matrix.platform == 'macos' + shell: bash + run: | + chmod +x ./scripts/create-macos-bundle.sh + ./scripts/create-macos-bundle.sh ${{ env.VERSION }} yaze-${{ env.VERSION }}-bundle + mkdir -p build/_CPack_Packages/manual + mv yaze-${{ env.VERSION }}-bundle.dmg build/_CPack_Packages/manual/ || true + - name: Package artifacts (Windows) if: matrix.platform == 'windows' run: | @@ -151,6 +160,13 @@ jobs: with: path: ./artifacts + - name: Generate release checksums + run: | + cd artifacts + find . -type f \( -name "*.zip" -o -name "*.exe" -o -name "*.deb" -o -name "*.tar.gz" -o -name "*.dmg" \) -print0 \ + | sort -z \ + | xargs -0 sha256sum > checksums.txt + - name: Create Release uses: softprops/action-gh-release@v2 with: @@ -202,6 +218,7 @@ jobs: artifacts/yaze-macos-*/yaze-*.dmg artifacts/yaze-windows-*/yaze-*.exe artifacts/yaze-windows-*/yaze-*.zip + artifacts/checksums.txt draft: false prerelease: ${{ contains(env.VERSION, 'alpha') || contains(env.VERSION, 'beta') || contains(env.VERSION, 'rc') }} env: diff --git a/.gitmodules b/.gitmodules index 095e0c16..eace12ce 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,27 +1,27 @@ -[submodule "src/lib/imgui"] - path = src/lib/imgui +[submodule "ext/imgui"] + path = ext/imgui url = https://github.com/ocornut/imgui.git [submodule "assets/asm/alttp-hacker-workspace"] path = assets/asm/alttp-hacker-workspace url = https://github.com/scawful/alttp-hacker-workspace.git -[submodule "src/lib/SDL"] - path = src/lib/SDL +[submodule "ext/SDL"] + path = ext/SDL url = https://github.com/libsdl-org/SDL.git -[submodule "src/lib/asar"] - path = src/lib/asar +[submodule "ext/asar"] + path = ext/asar url = https://github.com/RPGHacker/asar.git -[submodule "src/lib/imgui_test_engine"] - path = src/lib/imgui_test_engine +[submodule "ext/imgui_test_engine"] + path = ext/imgui_test_engine url = https://github.com/ocornut/imgui_test_engine.git -[submodule "src/lib/nativefiledialog-extended"] - path = src/lib/nativefiledialog-extended +[submodule "ext/nativefiledialog-extended"] + path = ext/nativefiledialog-extended url = https://github.com/btzy/nativefiledialog-extended.git [submodule "assets/asm/usdasm"] path = assets/asm/usdasm url = https://github.com/spannerisms/usdasm.git -[submodule "third_party/json"] - path = third_party/json +[submodule "ext/json"] + path = ext/json url = https://github.com/nlohmann/json.git -[submodule "third_party/httplib"] - path = third_party/httplib +[submodule "ext/httplib"] + path = ext/httplib url = https://github.com/yhirose/cpp-httplib.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 712eb435..895dd29e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,9 @@ set(CMAKE_POLICY_VERSION_MINIMUM 3.5 CACHE STRING "Minimum policy version for su cmake_policy(SET CMP0091 NEW) # Ensure we consistently use the static MSVC runtime (/MT, /MTd) to match vcpkg static triplets -set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" CACHE STRING "" FORCE) +if(MSVC) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" CACHE STRING "" FORCE) +endif() cmake_policy(SET CMP0048 NEW) cmake_policy(SET CMP0077 NEW) diff --git a/CMakePresets.json b/CMakePresets.json index b641db41..4238f741 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -169,7 +169,28 @@ "YAZE_ENABLE_JSON": "ON", "YAZE_ENABLE_AI": "OFF", "YAZE_ENABLE_ROM_TESTS": "OFF", - "YAZE_MINIMAL_BUILD": "OFF" + "YAZE_MINIMAL_BUILD": "OFF", + "YAZE_BUILD_AGENT_UI": "OFF", + "YAZE_ENABLE_REMOTE_AUTOMATION": "OFF", + "YAZE_ENABLE_AI_RUNTIME": "OFF" + } + }, + { + "name": "ci-windows-ai", + "inherits": "windows-base", + "displayName": "CI Build - Windows (Agent)", + "description": "Full agent build with gRPC + AI runtime (runs outside PRs)", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "YAZE_BUILD_TESTS": "ON", + "YAZE_ENABLE_GRPC": "ON", + "YAZE_ENABLE_JSON": "ON", + "YAZE_ENABLE_AI": "ON", + "YAZE_ENABLE_ROM_TESTS": "OFF", + "YAZE_MINIMAL_BUILD": "OFF", + "YAZE_BUILD_AGENT_UI": "ON", + "YAZE_ENABLE_REMOTE_AUTOMATION": "ON", + "YAZE_ENABLE_AI_RUNTIME": "ON" } }, { @@ -215,7 +236,10 @@ "YAZE_BUILD_TESTS": "ON", "YAZE_ENABLE_GRPC": "OFF", "YAZE_ENABLE_JSON": "ON", - "YAZE_ENABLE_AI": "OFF" + "YAZE_ENABLE_AI": "OFF", + "YAZE_BUILD_AGENT_UI": "OFF", + "YAZE_ENABLE_REMOTE_AUTOMATION": "OFF", + "YAZE_ENABLE_AI_RUNTIME": "OFF" } }, { @@ -238,7 +262,10 @@ "YAZE_ENABLE_GRPC": "OFF", "YAZE_ENABLE_JSON": "ON", "YAZE_ENABLE_AI": "OFF", - "YAZE_ENABLE_LTO": "ON" + "YAZE_ENABLE_LTO": "ON", + "YAZE_BUILD_AGENT_UI": "OFF", + "YAZE_ENABLE_REMOTE_AUTOMATION": "OFF", + "YAZE_ENABLE_AI_RUNTIME": "OFF" } }, { @@ -252,7 +279,10 @@ "YAZE_ENABLE_GRPC": "OFF", "YAZE_ENABLE_JSON": "ON", "YAZE_ENABLE_AI": "OFF", - "YAZE_ENABLE_ROM_TESTS": "ON" + "YAZE_ENABLE_ROM_TESTS": "ON", + "YAZE_BUILD_AGENT_UI": "OFF", + "YAZE_ENABLE_REMOTE_AUTOMATION": "OFF", + "YAZE_ENABLE_AI_RUNTIME": "OFF" } }, { @@ -266,7 +296,10 @@ "YAZE_ENABLE_GRPC": "ON", "YAZE_ENABLE_JSON": "ON", "YAZE_ENABLE_AI": "ON", - "YAZE_ENABLE_ROM_TESTS": "ON" + "YAZE_ENABLE_ROM_TESTS": "ON", + "YAZE_BUILD_AGENT_UI": "ON", + "YAZE_ENABLE_REMOTE_AUTOMATION": "ON", + "YAZE_ENABLE_AI_RUNTIME": "ON" } }, { @@ -280,7 +313,10 @@ "YAZE_BUILD_CLI": "ON", "YAZE_ENABLE_GRPC": "ON", "YAZE_ENABLE_JSON": "ON", - "YAZE_ENABLE_AI": "ON" + "YAZE_ENABLE_AI": "ON", + "YAZE_BUILD_AGENT_UI": "OFF", + "YAZE_ENABLE_REMOTE_AUTOMATION": "ON", + "YAZE_ENABLE_AI_RUNTIME": "ON" } }, { @@ -293,7 +329,10 @@ "YAZE_BUILD_TESTS": "ON", "YAZE_ENABLE_GRPC": "OFF", "YAZE_ENABLE_JSON": "ON", - "YAZE_ENABLE_AI": "OFF" + "YAZE_ENABLE_AI": "OFF", + "YAZE_BUILD_AGENT_UI": "OFF", + "YAZE_ENABLE_REMOTE_AUTOMATION": "OFF", + "YAZE_ENABLE_AI_RUNTIME": "OFF" }, "architecture": { "value": "ARM64", @@ -308,7 +347,10 @@ "cacheVariables": { "CMAKE_BUILD_TYPE": "Release", "YAZE_BUILD_TESTS": "OFF", - "YAZE_ENABLE_LTO": "ON" + "YAZE_ENABLE_LTO": "ON", + "YAZE_BUILD_AGENT_UI": "OFF", + "YAZE_ENABLE_REMOTE_AUTOMATION": "OFF", + "YAZE_ENABLE_AI_RUNTIME": "OFF" } }, { @@ -321,7 +363,10 @@ "YAZE_BUILD_TESTS": "ON", "YAZE_ENABLE_GRPC": "OFF", "YAZE_ENABLE_JSON": "ON", - "YAZE_ENABLE_AI": "OFF" + "YAZE_ENABLE_AI": "OFF", + "YAZE_BUILD_AGENT_UI": "OFF", + "YAZE_ENABLE_REMOTE_AUTOMATION": "OFF", + "YAZE_ENABLE_AI_RUNTIME": "OFF" } }, { @@ -335,7 +380,10 @@ "YAZE_ENABLE_GRPC": "OFF", "YAZE_ENABLE_JSON": "ON", "YAZE_ENABLE_AI": "OFF", - "YAZE_ENABLE_LTO": "ON" + "YAZE_ENABLE_LTO": "ON", + "YAZE_BUILD_AGENT_UI": "OFF", + "YAZE_ENABLE_REMOTE_AUTOMATION": "OFF", + "YAZE_ENABLE_AI_RUNTIME": "OFF" } }, { @@ -349,7 +397,10 @@ "YAZE_ENABLE_GRPC": "ON", "YAZE_ENABLE_JSON": "ON", "YAZE_ENABLE_AI": "ON", - "YAZE_ENABLE_ROM_TESTS": "ON" + "YAZE_ENABLE_ROM_TESTS": "ON", + "YAZE_BUILD_AGENT_UI": "ON", + "YAZE_ENABLE_REMOTE_AUTOMATION": "ON", + "YAZE_ENABLE_AI_RUNTIME": "ON" } } ], @@ -397,6 +448,13 @@ "configuration": "RelWithDebInfo", "jobs": 12 }, + { + "name": "ci-windows-ai", + "configurePreset": "ci-windows-ai", + "displayName": "CI Build - Windows (AI)", + "configuration": "RelWithDebInfo", + "jobs": 12 + }, { "name": "coverage", "configurePreset": "coverage", @@ -532,6 +590,39 @@ "label": "integration" } } + }, + { + "name": "stable-ai", + "configurePreset": "ci-windows-ai", + "displayName": "Stable Tests (Agent Stack)", + "description": "Run stable tests against the ci-windows-ai preset", + "filter": { + "include": { + "label": "stable" + } + } + }, + { + "name": "unit-ai", + "configurePreset": "ci-windows-ai", + "displayName": "Unit Tests (Agent Stack)", + "description": "Run unit tests against the ci-windows-ai preset", + "filter": { + "include": { + "label": "unit" + } + } + }, + { + "name": "integration-ai", + "configurePreset": "ci-windows-ai", + "displayName": "Integration Tests (Agent Stack)", + "description": "Run integration tests against the ci-windows-ai preset", + "filter": { + "include": { + "label": "integration" + } + } } ], "packagePresets": [ diff --git a/README.md b/README.md index 11394b65..51d8537c 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ A cross-platform Zelda 3 ROM editor with a modern C++ GUI, Asar 65816 assembler - **Automation & AI**: `z3ed` exposes CLI/TUI automation, proposal workflows, and optional AI agents. - **Testing & CI hooks**: CMake presets, ROM-less test fixtures, and gRPC-based GUI automation support. - **Cross-platform toolchains**: Single source tree targeting MSVC, Clang, and GCC with identical presets. +- **Modular AI stack**: Toggle agent UI (`YAZE_BUILD_AGENT_UI`), remote automation/gRPC (`YAZE_ENABLE_REMOTE_AUTOMATION`), and AI runtimes (`YAZE_ENABLE_AI_RUNTIME`) per preset. ## Project Status `0.3.x` builds are in active development. Release automation is being reworked, so packaged builds may lag behind main. Follow `develop` for the most accurate view of current functionality. @@ -45,19 +46,37 @@ cmake --build --preset mac-dbg cmake --preset lin-dbg cmake --build --preset lin-dbg -# Windows +# Windows (core preset) cmake --preset win-dbg cmake --build --preset win-dbg --target yaze # Enable AI + gRPC tooling (any platform) cmake --preset mac-ai cmake --build --preset mac-ai --target yaze z3ed + +# Windows AI preset +cmake --preset win-ai +cmake --build --preset win-ai --target yaze z3ed ``` +### Agent Feature Flags + +| Option | Default | Effect | +| --- | --- | --- | +| `YAZE_BUILD_AGENT_UI` | `ON` when GUI builds are enabled | Compiles the chat/dialog widgets so the editor can host agent sessions. Turn this `OFF` when you want a lean GUI-only build. | +| `YAZE_ENABLE_REMOTE_AUTOMATION` | `ON` for `*-ai` presets | Builds the gRPC servers/clients and protobufs that power GUI automation. | +| `YAZE_ENABLE_AI_RUNTIME` | `ON` for `*-ai` presets | Enables Gemini/Ollama transports, proposal planning, and advanced routing logic. | +| `YAZE_ENABLE_AGENT_CLI` | `ON` when CLI builds are enabled | Compiles the conversational agent stack consumed by `z3ed`. Disable to skip the CLI entirely. | + +Windows `win-*` presets keep every switch `OFF` by default (`win-dbg`, `win-rel`, `ci-windows`) so MSVC builds stay fast. Use `win-ai`, `win-vs-ai`, or the new `ci-windows-ai` preset whenever you need remote automation or AI runtime features. + +All bundled third-party code (SDL, ImGui, ImGui Test Engine, Asar, nlohmann/json, cpp-httplib, nativefiledialog-extended) now lives under `ext/` for easier vendoring and cleaner include paths. + ## Applications & Workflows - **`./build/bin/yaze`** – full GUI editor with multi-session dockspace, theming, and ROM patching. - **`./build/bin/z3ed --tui`** – CLI/TUI companion for scripting, AI-assisted edits, and Asar workflows. - **`./build_ai/bin/yaze_test --unit|--integration|--e2e`** – structured test runner for quick regression checks. +- **`z3ed` + macOS automation** – pair the CLI with sketchybar/yabai/skhd or Emacs/Spacemacs to drive ROM workflows without opening the GUI. Typical commands: ```bash diff --git a/cmake/asar.cmake b/cmake/asar.cmake index 0946a1d9..31688d62 100644 --- a/cmake/asar.cmake +++ b/cmake/asar.cmake @@ -14,7 +14,7 @@ if(MSVC) endif() # Set Asar source directory -set(ASAR_SRC_DIR "${CMAKE_SOURCE_DIR}/src/lib/asar/src") +set(ASAR_SRC_DIR "${CMAKE_SOURCE_DIR}/ext/asar/src") # Add Asar as subdirectory add_subdirectory(${ASAR_SRC_DIR} EXCLUDE_FROM_ALL) diff --git a/cmake/dependencies/imgui.cmake b/cmake/dependencies/imgui.cmake index 202b7e92..018b6f1a 100644 --- a/cmake/dependencies/imgui.cmake +++ b/cmake/dependencies/imgui.cmake @@ -1,10 +1,10 @@ # Dear ImGui dependency management -# Uses the bundled ImGui in src/lib/imgui +# Uses the bundled ImGui in ext/imgui message(STATUS "Setting up Dear ImGui from bundled sources") -# Use the bundled ImGui from src/lib/imgui -set(IMGUI_DIR ${CMAKE_SOURCE_DIR}/src/lib/imgui) +# Use the bundled ImGui from ext/imgui +set(IMGUI_DIR ${CMAKE_SOURCE_DIR}/ext/imgui) # Create ImGui library with core files from bundled source add_library(ImGui STATIC @@ -35,7 +35,7 @@ message(STATUS "Created ImGui target from bundled source at ${IMGUI_DIR}") # Create ImGui Test Engine for test automation (if tests are enabled) if(YAZE_BUILD_TESTS) - set(IMGUI_TEST_ENGINE_DIR ${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine/imgui_test_engine) + set(IMGUI_TEST_ENGINE_DIR ${CMAKE_SOURCE_DIR}/ext/imgui_test_engine/imgui_test_engine) if(EXISTS ${IMGUI_TEST_ENGINE_DIR}) set(IMGUI_TEST_ENGINE_SOURCES @@ -53,7 +53,7 @@ if(YAZE_BUILD_TESTS) target_include_directories(ImGuiTestEngine PUBLIC ${IMGUI_DIR} ${IMGUI_TEST_ENGINE_DIR} - ${CMAKE_SOURCE_DIR}/src/lib + ${CMAKE_SOURCE_DIR}/ext ) target_compile_features(ImGuiTestEngine PUBLIC cxx_std_17) target_link_libraries(ImGuiTestEngine PUBLIC ImGui ${YAZE_SDL2_TARGETS}) diff --git a/cmake/dependencies/json.cmake b/cmake/dependencies/json.cmake index 6a06ab55..80ead608 100644 --- a/cmake/dependencies/json.cmake +++ b/cmake/dependencies/json.cmake @@ -4,14 +4,14 @@ if(NOT YAZE_ENABLE_JSON) return() endif() -message(STATUS "Setting up nlohmann_json with local third_party") +message(STATUS "Setting up nlohmann_json with local ext directory") -# Use the bundled nlohmann_json from third_party +# Use the bundled nlohmann_json from ext/json set(JSON_BuildTests OFF CACHE BOOL "" FORCE) set(JSON_Install OFF CACHE BOOL "" FORCE) set(JSON_MultipleHeaders OFF CACHE BOOL "" FORCE) -add_subdirectory(${CMAKE_SOURCE_DIR}/third_party/json EXCLUDE_FROM_ALL) +add_subdirectory(${CMAKE_SOURCE_DIR}/ext/json EXCLUDE_FROM_ALL) # Verify target is available if(TARGET nlohmann_json::nlohmann_json) @@ -25,10 +25,7 @@ else() endif() # Export for use in other CMake files -set(YAZE_JSON_TARGETS - nlohmann_json::nlohmann_json - PARENT_SCOPE -) +set(YAZE_JSON_TARGETS nlohmann_json::nlohmann_json CACHE INTERNAL "nlohmann_json targets") message(STATUS "nlohmann_json setup complete") diff --git a/cmake/options.cmake b/cmake/options.cmake index dd5b27ed..31f72ff1 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -3,7 +3,8 @@ # Core build options option(YAZE_BUILD_GUI "Build GUI application" ON) -option(YAZE_BUILD_CLI "Build CLI tools (z3ed)" ON) +option(YAZE_BUILD_CLI "Build CLI tools (shared libraries)" ON) +option(YAZE_BUILD_Z3ED "Build z3ed CLI executable" ON) option(YAZE_BUILD_EMU "Build emulator components" ON) option(YAZE_BUILD_LIB "Build static library" ON) option(YAZE_BUILD_TESTS "Build test suite" ON) @@ -13,6 +14,24 @@ option(YAZE_ENABLE_GRPC "Enable gRPC agent support" ON) option(YAZE_ENABLE_JSON "Enable JSON support" ON) option(YAZE_ENABLE_AI "Enable AI agent features" ON) +# Advanced feature toggles +option(YAZE_ENABLE_REMOTE_AUTOMATION + "Enable remote automation services (gRPC/protobuf servers + GUI automation clients)" + ${YAZE_ENABLE_GRPC}) +option(YAZE_ENABLE_AI_RUNTIME + "Enable AI runtime integrations (Gemini/Ollama, advanced routing, proposal planning)" + ${YAZE_ENABLE_AI}) +option(YAZE_BUILD_AGENT_UI + "Build ImGui-based agent/chat panels inside the GUI" + ${YAZE_BUILD_GUI}) +option(YAZE_ENABLE_AGENT_CLI + "Build the conversational agent CLI stack (z3ed agent commands)" + ${YAZE_BUILD_CLI}) + +if((YAZE_BUILD_CLI OR YAZE_BUILD_Z3ED) AND NOT YAZE_ENABLE_AGENT_CLI) + set(YAZE_ENABLE_AGENT_CLI ON CACHE BOOL "Build the conversational agent CLI stack (z3ed agent commands)" FORCE) +endif() + # Build optimizations option(YAZE_ENABLE_LTO "Enable link-time optimization" OFF) option(YAZE_ENABLE_SANITIZERS "Enable AddressSanitizer/UBSanitizer" OFF) @@ -33,6 +52,14 @@ option(YAZE_INSTALL_LIB "Install static library" OFF) option(YAZE_INSTALL_HEADERS "Install public headers" ON) # Set preprocessor definitions based on options +if(YAZE_ENABLE_REMOTE_AUTOMATION AND NOT YAZE_ENABLE_GRPC) + set(YAZE_ENABLE_GRPC ON CACHE BOOL "Enable gRPC agent support" FORCE) +endif() + +if(NOT YAZE_ENABLE_REMOTE_AUTOMATION) + set(YAZE_ENABLE_GRPC OFF CACHE BOOL "Enable gRPC agent support" FORCE) +endif() + if(YAZE_ENABLE_GRPC) add_compile_definitions(YAZE_WITH_GRPC) endif() @@ -41,6 +68,14 @@ if(YAZE_ENABLE_JSON) add_compile_definitions(YAZE_WITH_JSON) endif() +if(YAZE_ENABLE_AI_RUNTIME AND NOT YAZE_ENABLE_AI) + set(YAZE_ENABLE_AI ON CACHE BOOL "Enable AI agent features" FORCE) +endif() + +if(NOT YAZE_ENABLE_AI_RUNTIME) + set(YAZE_ENABLE_AI OFF CACHE BOOL "Enable AI agent features" FORCE) +endif() + if(YAZE_ENABLE_AI) add_compile_definitions(Z3ED_AI) endif() @@ -49,12 +84,17 @@ endif() message(STATUS "=== YAZE Build Configuration ===") message(STATUS "GUI Application: ${YAZE_BUILD_GUI}") message(STATUS "CLI Tools: ${YAZE_BUILD_CLI}") +message(STATUS "z3ed CLI: ${YAZE_BUILD_Z3ED}") message(STATUS "Emulator: ${YAZE_BUILD_EMU}") message(STATUS "Static Library: ${YAZE_BUILD_LIB}") message(STATUS "Tests: ${YAZE_BUILD_TESTS}") message(STATUS "gRPC Support: ${YAZE_ENABLE_GRPC}") +message(STATUS "Remote Automation: ${YAZE_ENABLE_REMOTE_AUTOMATION}") message(STATUS "JSON Support: ${YAZE_ENABLE_JSON}") -message(STATUS "AI Features: ${YAZE_ENABLE_AI}") +message(STATUS "AI Runtime: ${YAZE_ENABLE_AI_RUNTIME}") +message(STATUS "AI Features (legacy): ${YAZE_ENABLE_AI}") +message(STATUS "Agent UI Panels: ${YAZE_BUILD_AGENT_UI}") +message(STATUS "Agent CLI Stack: ${YAZE_ENABLE_AGENT_CLI}") message(STATUS "LTO: ${YAZE_ENABLE_LTO}") message(STATUS "Sanitizers: ${YAZE_ENABLE_SANITIZERS}") message(STATUS "Coverage: ${YAZE_ENABLE_COVERAGE}") diff --git a/cmake/sdl2.cmake b/cmake/sdl2.cmake index e75d86d9..9dd8c10a 100644 --- a/cmake/sdl2.cmake +++ b/cmake/sdl2.cmake @@ -27,14 +27,14 @@ if(WIN32) endif() # Fall back to bundled SDL if vcpkg not available or SDL2 not found - if(EXISTS "${CMAKE_SOURCE_DIR}/src/lib/SDL/CMakeLists.txt") + if(EXISTS "${CMAKE_SOURCE_DIR}/ext/SDL/CMakeLists.txt") message(STATUS "○ vcpkg SDL2 not found, using bundled SDL2") - add_subdirectory(src/lib/SDL) + add_subdirectory(ext/SDL) set(SDL_TARGETS SDL2-static) set(SDL2_INCLUDE_DIR - ${CMAKE_SOURCE_DIR}/src/lib/SDL/include - ${CMAKE_BINARY_DIR}/src/lib/SDL/include - ${CMAKE_BINARY_DIR}/src/lib/SDL/include-config-${CMAKE_BUILD_TYPE} + ${CMAKE_SOURCE_DIR}/ext/SDL/include + ${CMAKE_BINARY_DIR}/ext/SDL/include + ${CMAKE_BINARY_DIR}/ext/SDL/include-config-${CMAKE_BUILD_TYPE} ) set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) if(TARGET SDL2main) @@ -47,12 +47,12 @@ if(WIN32) endif() elseif(UNIX OR MINGW) # Non-Windows: use bundled SDL - add_subdirectory(src/lib/SDL) + add_subdirectory(ext/SDL) set(SDL_TARGETS SDL2-static) set(SDL2_INCLUDE_DIR - ${CMAKE_SOURCE_DIR}/src/lib/SDL/include - ${CMAKE_BINARY_DIR}/src/lib/SDL/include - ${CMAKE_BINARY_DIR}/src/lib/SDL/include-config-${CMAKE_BUILD_TYPE} + ${CMAKE_SOURCE_DIR}/ext/SDL/include + ${CMAKE_BINARY_DIR}/ext/SDL/include + ${CMAKE_BINARY_DIR}/ext/SDL/include-config-${CMAKE_BUILD_TYPE} ) set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) message(STATUS "Using bundled SDL2") diff --git a/docs/internal/agents/ai-modularity.md b/docs/internal/agents/ai-modularity.md new file mode 100644 index 00000000..dec2e921 --- /dev/null +++ b/docs/internal/agents/ai-modularity.md @@ -0,0 +1,100 @@ +# AI & gRPC Modularity Blueprint + +*Date: November 16, 2025 – Author: GPT-5.1 Codex* + +## 1. Scope & Goals + +- Make AI/gRPC features optional without scattering `#ifdef` guards. +- 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 + +1. **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`). +2. **Editor Hard Links** – `yaze_editor` unconditionally links `yaze_agent` when `YAZE_MINIMAL_BUILD` is `OFF`, so even ROM-editing-only builds drag in AI dependencies (`src/app/editor/editor_library.cmake`). +3. **Shared Proto Targets** – `yaze_grpc_support` consumes CLI proto files, so editor-only builds still compile CLI automation code (`src/app/service/grpc_support.cmake`). +4. **Preprocessor Guards** – UI code mixes `Z3ED_AI` and `Z3ED_AI_AVAILABLE`; CLI code checks `Z3ED_AI` while build system only defines `Z3ED_AI` when `YAZE_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 `/MT` while `yaze_emu` uses `/MD`, causing cascades of `LNK2038` and `_Lockit`/`libcpmt` conflicts (`logs/windows_ci_linker_error.log`). +- **OpenSSL duplication** – `yaze_agent` links cpp-httplib with OpenSSL while gRPC pulls BoringSSL, leading to duplicate symbol errors (`libssl.lib` vs `ssl.lib`) in the same log. +- **Missing native dialogs** – `FileDialogWrapper` symbols fail to link when macOS-specific implementations are not excluded on Windows (also visible in the same log). +- **Preset drift** – `win-ai` enables GRPC/AI without guaranteeing vcpkg/clang-cl or ROM assets; `win-dbg` disables 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: + +1. **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 when `YAZE_BUILD_AGENT_UI=ON`. +2. **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. +3. **Stub Providers** + - Provide header-compatible no-op classes (e.g., `AgentChatWidgetBridge::Create()` returning `nullptr`) when UI is disabled, removing the need for `#ifdef` in ImGui panels. +4. **Dependency Injection** + - Replace `#ifdef Z3ED_AI_AVAILABLE` in `agent_chat_widget.cc` with an interface returned from `AgentFeatures::MaybeCreateChatPanel()`. + +## 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 + +1. **Define Options** in `cmake/options.cmake` and propagate via presets. +2. **Restructure Libraries**: + - Move CLI AI/runtime code into `yaze_agent_ai`. + - Add `yaze_agent_stub` for builds without AI. + - Make `yaze_editor` link against stub/real target via generator expressions. +3. **CMake Cleanup**: + - Limit `yaze_grpc_support` to gRPC-only code. + - Guard JSON/OpenSSL includes behind `YAZE_ENABLE_AI_RUNTIME`. +4. **Windows Hardening**: + - Force `/MD` everywhere and ensure yaml-cpp inherits `CMAKE_MSVC_RUNTIME_LIBRARY`. + - Allow only one SSL provider based on feature set. + - Add preset validation in `scripts/verify-build-environment.ps1`. +5. **CI/CD Split**: + - Current `.github/workflows/ci.yml` runs GRPC on all platforms; adjust to run minimal Windows build plus nightly AI build to save time and reduce flakiness. +6. **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). +7. **External Dependencies**: + - Relocate submodules to `ext/` and update scripts so the new layout is enforced before toggling feature flags. + +## 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. + diff --git a/docs/internal/legacy/BUILD-GUIDE.md b/docs/internal/legacy/BUILD-GUIDE.md index 9ee93415..886677f9 100644 --- a/docs/internal/legacy/BUILD-GUIDE.md +++ b/docs/internal/legacy/BUILD-GUIDE.md @@ -108,7 +108,7 @@ Add `-v` suffix (e.g., `mac-dbg-v`) for verbose compiler warnings. **Problem**: Conflicting ImGui versions (bundled vs CPM download) **Fixes**: -- Used bundled ImGui from `src/lib/imgui/` instead of downloading +- Used bundled ImGui from `ext/imgui/` instead of downloading - Created proper ImGui static library target - Added `imgui_stdlib.cpp` for std::string support - Exported with `PARENT_SCOPE` @@ -118,7 +118,7 @@ Add `-v` suffix (e.g., `mac-dbg-v`) for verbose compiler warnings. **Fixes**: - Created `cmake/dependencies/json.cmake` -- Set up bundled `third_party/json/` +- Set up bundled `ext/json/` - Added include directories to all targets that need JSON #### 7. GTest and GMock ✅ diff --git a/docs/public/build/build-from-source.md b/docs/public/build/build-from-source.md index 48ee0452..cdd3a542 100644 --- a/docs/public/build/build-from-source.md +++ b/docs/public/build/build-from-source.md @@ -13,6 +13,7 @@ yaze uses a modern CMake build system with presets for easy configuration. This # With automatic fixes .\scripts\verify-build-environment.ps1 -FixIssues ``` +> Tip: After verification, run `.\scripts\setup-vcpkg-windows.ps1` to bootstrap vcpkg, ensure `clang-cl`/Ninja are installed, and cache the `x64-windows` triplet. ### macOS & Linux (Bash) ```bash @@ -53,6 +54,10 @@ cmake --preset win-dbg # Build the project cmake --build --preset win-dbg + +# Enable the full AI/gRPC stack +cmake --preset win-ai +cmake --build --preset win-ai ``` ### AI-Enabled Build (All Platforms) @@ -67,10 +72,31 @@ cmake --preset win-ai cmake --build --preset win-ai ``` +## Feature Toggles & Windows Profiles + +### Windows Presets + +| Preset | Purpose | +| --- | --- | +| `win-dbg`, `win-rel`, `ci-windows` | Core builds without agent UI, gRPC, or AI runtimes. Fastest option for MSVC/clang-cl. | +| `win-ai`, `win-vs-ai` | Full agent stack for local development (UI panels + remote automation + AI runtime). | +| `ci-windows-ai` | Nightly/weekly CI preset that exercises the entire automation stack on Windows. | + +### Agent Feature Flags + +| Option | Default | Effect | +| --- | --- | --- | +| `YAZE_BUILD_AGENT_UI` | `ON` when `YAZE_BUILD_GUI=ON` | Builds the ImGui widgets used by the chat/agent panels. | +| `YAZE_ENABLE_REMOTE_AUTOMATION` | `ON` for `*-ai` presets | Adds gRPC/protobuf services plus GUI automation clients. | +| `YAZE_ENABLE_AI_RUNTIME` | `ON` for `*-ai` presets | Enables Gemini/Ollama transports, proposal planning, and advanced routing logic. | +| `YAZE_ENABLE_AGENT_CLI` | `ON` when `YAZE_BUILD_CLI=ON` | Compiles the conversational agent stack consumed by `z3ed`. | + +Combine these switches to match your workflow: keep everything `OFF` for lightweight GUI hacking or turn them `ON` for automation-heavy work with sketchybar/yabai/skhd, tmux, or remote runners. + ## 3. Dependencies - **Required**: CMake 3.16+, C++23 Compiler (GCC 13+, Clang 16+, MSVC 2019+), Git. -- **Bundled**: All other dependencies (SDL2, ImGui, Abseil, Asar, GoogleTest, etc.) are included as Git submodules or managed by CMake's `FetchContent`. No external package manager is required for a basic build. +- **Bundled**: All other dependencies (SDL2, ImGui, Asar, nlohmann/json, cpp-httplib, GoogleTest, etc.) live under the `ext/` directory or are managed by CMake's `FetchContent`. No external package manager is required for a basic build. - **Optional**: - **gRPC**: For GUI test automation. Can be enabled with `-DYAZE_WITH_GRPC=ON`. - **vcpkg (Windows)**: Can be used for faster gRPC builds on Windows (optional). @@ -95,7 +121,8 @@ sudo apt-get install -y build-essential cmake ninja-build pkg-config \ ### Windows - **Visual Studio 2022** is required, with the "Desktop development with C++" workload. -- The `verify-build-environment.ps1` script will help identify any missing components. +- The updated `verify-build-environment.ps1` script checks clang-cl, Ninja, vcpkg caches, and ROM assets. +- Run `.\scripts\setup-vcpkg-windows.ps1` once per machine to bootstrap vcpkg and prefetch SDL2/yaml-cpp. - For building with gRPC, see the "Windows Build Optimization" section below. ## 5. Testing @@ -171,6 +198,7 @@ open build/yaze.xcodeproj - **vcpkg**: Only fast packages (SDL2, yaml-cpp) - 2 minutes - **gRPC**: Built via FetchContent (v1.75.1) - cached after first build - **Caching**: Aggressive multi-tier caching (vcpkg + FetchContent + sccache) +- **Agent matrix**: A dedicated `ci-windows-ai` job runs outside pull requests to exercise the full gRPC + AI runtime stack. - **Expected time**: - First build: ~10-15 minutes - Cached build: ~3-5 minutes @@ -188,9 +216,8 @@ open build/yaze.xcodeproj For desktop development, you can use vcpkg for faster gRPC builds: ```powershell -# Install vcpkg -git clone https://github.com/Microsoft/vcpkg.git -cd vcpkg && .\bootstrap-vcpkg.bat +# Bootstrap vcpkg and prefetch packages +.\scripts\setup-vcpkg-windows.ps1 # Configure with vcpkg cmake -B build -DYAZE_USE_VCPKG_GRPC=ON -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake diff --git a/docs/public/developer/dependency-architecture.md b/docs/public/developer/dependency-architecture.md index cba3193a..9c1c6caa 100644 --- a/docs/public/developer/dependency-architecture.md +++ b/docs/public/developer/dependency-architecture.md @@ -18,6 +18,10 @@ can treat it as a quick reference while editing. | `YAZE_ENABLE_GRPC` | `OFF` | Pulls in gRPC/protobuf for automation and remote control features. | | `YAZE_MINIMAL_BUILD` | `OFF` | Skips optional editors/assets. Useful for CI smoke builds. | | `YAZE_BUILD_LIB` | `OFF` | Produces the `yaze_core` INTERFACE target used by external tooling. | +| `YAZE_BUILD_AGENT_UI` | `ON` when `YAZE_BUILD_GUI` is `ON` | Compiles ImGui chat widgets. Disable for lighter GUI builds. | +| `YAZE_ENABLE_REMOTE_AUTOMATION` | `OFF` in `win-*` core presets | Builds gRPC servers/clients plus proto generation. | +| `YAZE_ENABLE_AI_RUNTIME` | `OFF` in `win-*` core presets | Enables Gemini/Ollama transports, proposal planning, and advanced routing code. | +| `YAZE_ENABLE_AGENT_CLI` | `ON` when `YAZE_BUILD_CLI` is `ON` | Compiles the conversational agent stack used by `z3ed`. | Use the canned presets from `CMakePresets.json` so these options stay consistent across platforms: `mac-dbg`, `mac-ai`, `lin-dbg`, `win-dbg`, etc. The `*-ai` presets enable both @@ -58,12 +62,13 @@ alone. Touching editor UI code does **not** require rebuilding `yaze_emulator`. ### 4. Tooling & Export Targets - **`yaze_agent`** (`src/cli/agent`): shared logic behind the CLI and AI workflows. Built whenever - `YAZE_BUILD_Z3ED` is enabled. + `YAZE_ENABLE_AGENT_CLI` is enabled (automatically true when `YAZE_BUILD_Z3ED=ON`). When both the CLI and the agent UI are disabled, CMake now emits a lightweight stub target so GUI-only builds don't drag in unnecessary dependencies. - **`z3ed` binary** (`src/cli/z3ed.cmake`): links `yaze_agent`, `yaze_zelda3`, `yaze_gfx`, and Abseil/FTXUI. - **`yaze_core_lib`** (`src/core`): static library that exposes project management helpers and the Asar integration. When `YAZE_BUILD_LIB=ON` it can be consumed by external tools. - **`yaze_test_support`** (`src/app/test`): harness for the in-editor dashboard and `yaze_test`. +- **`yaze_grpc_support`**: server-only aggregation of gRPC/protobuf code, gated by `YAZE_ENABLE_REMOTE_AUTOMATION`. CLI clients (`cli/service/gui/**`, `cli/service/planning/**`) now live solely in `yaze_agent` so GUI builds can opt out entirely. ### 5. Final Binaries - **`yaze`**: GUI editor. Links every layer plus `yaze_test_support` when tests are enabled. diff --git a/src/lib/SDL b/ext/SDL similarity index 100% rename from src/lib/SDL rename to ext/SDL diff --git a/src/lib/asar b/ext/asar similarity index 100% rename from src/lib/asar rename to ext/asar diff --git a/third_party/httplib b/ext/httplib similarity index 100% rename from third_party/httplib rename to ext/httplib diff --git a/src/lib/imgui b/ext/imgui similarity index 100% rename from src/lib/imgui rename to ext/imgui diff --git a/src/lib/imgui_test_engine b/ext/imgui_test_engine similarity index 100% rename from src/lib/imgui_test_engine rename to ext/imgui_test_engine diff --git a/third_party/json b/ext/json similarity index 100% rename from third_party/json rename to ext/json diff --git a/src/lib/nativefiledialog-extended b/ext/nativefiledialog-extended similarity index 100% rename from src/lib/nativefiledialog-extended rename to ext/nativefiledialog-extended diff --git a/scripts/README.md b/scripts/README.md index d52910a6..68df5930 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -115,3 +115,25 @@ cmake --build build --target build_cleaner - Other: `YAZE_AGENT_SOURCES`, `YAZE_TEST_SOURCES` The script intelligently preserves conditional blocks (if/endif) and excludes conditional files from the main source list. + +## verify-build-environment.\* + +`verify-build-environment.ps1` (Windows) and `verify-build-environment.sh` (macOS/Linux) are the primary diagnostics for contributors. They now: + +- Check for `clang-cl`, Ninja, NASM, Visual Studio workloads, and VS Code (optional). +- Validate vcpkg bootstrap status plus `vcpkg/installed` cache contents. +- Warn about missing ROM assets (`zelda3.sfc`, `assets/zelda3.sfc`, etc.). +- Offer `-FixIssues` and `-CleanCache` switches to repair Git config, resync submodules, and wipe stale build directories. + +Run the script once per machine (and rerun after major toolchain updates) to ensure presets such as `win-dbg`, `win-ai`, `mac-ai`, and `ci-windows-ai` have everything they need. + +## setup-vcpkg-windows.ps1 + +Automates the vcpkg bootstrap flow on Windows: + +1. Clones and bootstraps vcpkg (if not already present). +2. Verifies that `git`, `clang-cl`, and Ninja are available, printing friendly instructions when they are missing. +3. Installs the default triplet (`x64-windows` or `arm64-windows` when detected) and confirms that `vcpkg/installed/` is populated. +4. Reminds you to rerun `.\scripts\verify-build-environment.ps1 -FixIssues` to double-check the environment. + +Use it immediately after cloning the repository or whenever you need to refresh your local dependency cache before running `win-ai` or `ci-windows-ai` presets. diff --git a/scripts/setup-vcpkg-windows.ps1 b/scripts/setup-vcpkg-windows.ps1 index 5b5a0542..af857287 100644 --- a/scripts/setup-vcpkg-windows.ps1 +++ b/scripts/setup-vcpkg-windows.ps1 @@ -65,6 +65,22 @@ if (-not (Test-Command "git")) { Write-Status "✓ Git found" "Success" +# Check for clang-cl +if (Test-Command "clang-cl") { + $clangVersion = & clang-cl --version 2>&1 | Select-Object -First 1 + Write-Status "✓ clang-cl detected: $clangVersion" "Success" +} else { + Write-Status "⚠ clang-cl not found. Install the \"LLVM tools for Visual Studio\" component for faster builds." "Warning" +} + +# Check for Ninja +if (Test-Command "ninja") { + $ninjaVersion = & ninja --version 2>&1 + Write-Status "✓ Ninja detected: version $ninjaVersion" "Success" +} else { + Write-Status "⚠ Ninja not found. Install via: choco install ninja (required for win-dbg/win-ai presets)" "Warning" +} + # Clone vcpkg if needed if (-not (Test-Path "vcpkg")) { Write-Status "Cloning vcpkg..." "Warning" @@ -102,6 +118,12 @@ Write-Status "Installing dependencies for triplet: $Triplet" "Warning" & $vcpkgExe install --triplet $Triplet if ($LASTEXITCODE -eq 0) { Write-Status "✓ Dependencies installed successfully" "Success" + $installedPath = "vcpkg\installed\$Triplet" + if (Test-Path $installedPath) { + Write-Status "✓ Cached packages under $installedPath" "Success" + } else { + Write-Status "⚠ vcpkg install folder missing (expected $installedPath). Builds may rebuild dependencies on first run." "Warning" + } } else { Write-Status "⚠ Some dependencies may not have installed correctly" "Warning" } @@ -112,4 +134,6 @@ Write-Status "========================================" "Info" Write-Status "" Write-Status "You can now build YAZE using:" "Warning" Write-Status " .\scripts\build-windows.ps1" "White" +Write-Status "" +Write-Status "For ongoing diagnostics run: .\scripts\verify-build-environment.ps1 -FixIssues" "Info" Write-Status "" \ No newline at end of file diff --git a/scripts/verify-build-environment.ps1 b/scripts/verify-build-environment.ps1 index 4a3e0b55..6f80a5ac 100644 --- a/scripts/verify-build-environment.ps1 +++ b/scripts/verify-build-environment.ps1 @@ -56,12 +56,14 @@ function Get-CMakeVersion { function Test-GitSubmodules { $submodules = @( - "src/lib/SDL", + "ext/SDL", "src/lib/abseil-cpp", - "src/lib/asar", - "src/lib/imgui", - "third_party/json", - "third_party/httplib" + "ext/asar", + "ext/imgui", + "ext/json", + "ext/httplib", + "ext/imgui_test_engine", + "ext/nativefiledialog-extended" ) $allPresent = $true @@ -165,6 +167,36 @@ function Test-Vcpkg { } } +function Test-VcpkgCache { + $vcpkgPath = Join-Path $PSScriptRoot ".." "vcpkg" + $installedDir = Join-Path $vcpkgPath "installed" + + if (-not (Test-Path $installedDir)) { + return + } + + $triplets = @("x64-windows", "arm64-windows") + $hasPackages = $false + + foreach ($triplet in $triplets) { + $tripletDir = Join-Path $installedDir $triplet + if (Test-Path $tripletDir) { + $count = (Get-ChildItem $tripletDir -Force | Measure-Object).Count + if ($count -gt 0) { + $hasPackages = $true + Write-Status "vcpkg cache populated for $triplet" "Success" + } + } + } + + if (-not $hasPackages) { + Write-Status "vcpkg/installed is empty. Run scripts\\setup-vcpkg-windows.ps1 to prefetch dependencies." "Warning" + $script:warnings += "vcpkg cache empty - builds may spend extra time compiling dependencies." + } else { + $script:success += "vcpkg cache ready for Windows presets" + } +} + function Test-CMakeCache { $buildDirs = @("build", "build-windows", "build-test", "build-ai", "out/build") $cacheIssues = $false @@ -279,6 +311,25 @@ function Test-Ninja { } } +function Test-ClangCL { + Write-Status "Checking clang-cl compiler..." "Step" + if (Test-Command "clang-cl") { + try { + $clangVersion = & clang-cl --version 2>&1 | Select-Object -First 1 + Write-Status "clang-cl found: $clangVersion" "Success" + $script:success += "clang-cl available (recommended for win-* presets)" + return $true + } catch { + Write-Status "clang-cl command exists but version check failed" "Warning" + return $true + } + } else { + Write-Status "clang-cl not found (LLVM toolset for MSVC missing?)" "Warning" + $script:warnings += "Install the \"LLVM tools for Visual Studio\" component or enable clang-cl via Visual Studio Installer." + return $false + } +} + function Test-NASM { Write-Status "Checking NASM assembler..." "Step" if (Test-Command "nasm") { @@ -346,6 +397,28 @@ function Test-VSCode { } } +function Test-RomAssets { + Write-Status "Checking for local Zelda 3 ROM assets..." "Step" + $romPaths = @( + "zelda3.sfc", + "assets/zelda3.sfc", + "assets/zelda3.yaze", + "Roms/zelda3.sfc" + ) + + foreach ($relativePath in $romPaths) { + $fullPath = Join-Path $PSScriptRoot ".." $relativePath + if (Test-Path $fullPath) { + Write-Status "Found ROM asset at '$relativePath'" "Success" + $script:success += "ROM asset available for GUI/editor smoke tests" + return + } + } + + Write-Status "No ROM asset detected. Place a clean 'zelda3.sfc' in the repo root or assets/ directory." "Warning" + $script:warnings += "ROM assets missing - GUI workflows that load ROMs will fail until one is provided." +} + function Test-CMakePresets { Write-Status "Validating CMakePresets.json..." "Step" @@ -492,8 +565,9 @@ if (Test-Command "git") { $script:issuesFound += "Git not installed or not in PATH" } -# Step 3: Check Build Tools (Ninja and NASM) +# Step 3: Check Build Tools (Ninja, clang-cl, NASM) Test-Ninja | Out-Null +Test-ClangCL | Out-Null Test-NASM | Out-Null # Step 4: Check Visual Studio @@ -528,6 +602,7 @@ Test-CMakePresets | Out-Null # Step 7: Check vcpkg Test-Vcpkg | Out-Null +Test-VcpkgCache | Out-Null # Step 8: Check Git Submodules Write-Status "Checking git submodules..." "Step" @@ -564,6 +639,9 @@ if (Test-CMakeCache) { } } +# Step 10: Check ROM assets +Test-RomAssets | Out-Null + # ============================================================================ # Summary Report # ============================================================================ diff --git a/scripts/verify-build-environment.sh b/scripts/verify-build-environment.sh index 81a56f5d..26a2fe90 100755 --- a/scripts/verify-build-environment.sh +++ b/scripts/verify-build-environment.sh @@ -90,12 +90,14 @@ function get_cmake_version() { function test_git_submodules() { local submodules=( - "src/lib/SDL" - "src/lib/abseil-cpp" - "src/lib/asar" - "src/lib/imgui" - "third_party/json" - "third_party/httplib" + "ext/SDL" + "src/lib/abseil-cpp" + "ext/asar" + "ext/imgui" + "ext/json" + "ext/httplib" + "ext/imgui_test_engine" + "ext/nativefiledialog-extended" ) local all_present=1 @@ -242,14 +244,14 @@ function test_dependency_compatibility() { write_status "Testing dependency configuration..." "Step" # Check httplib configuration - if [[ -f "third_party/httplib/CMakeLists.txt" ]]; then - write_status "httplib found in third_party" "Success" + if [[ -f "ext/httplib/CMakeLists.txt" ]]; then + write_status "httplib found in ext/" "Success" SUCCESS+=("httplib header-only library available") fi # Check json library - if [[ -d "third_party/json/include" ]]; then - write_status "nlohmann/json found in third_party" "Success" + if [[ -d "ext/json/include" ]]; then + write_status "nlohmann/json found in ext/" "Success" SUCCESS+=("nlohmann/json header-only library available") fi } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ede6abdb..34824570 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -77,7 +77,7 @@ if(YAZE_BUILD_TESTS OR NOT YAZE_MINIMAL_BUILD) endif() # Include gRPC support library (consolidates all protobuf/gRPC usage) -if(YAZE_ENABLE_GRPC) +if(YAZE_ENABLE_REMOTE_AUTOMATION) include(app/service/grpc_support.cmake) endif() diff --git a/src/app/app.cmake b/src/app/app.cmake index 72ffb48c..f38cad40 100644 --- a/src/app/app.cmake +++ b/src/app/app.cmake @@ -47,8 +47,8 @@ if(APPLE) target_include_directories(yaze_app_objcxx PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/app - ${CMAKE_SOURCE_DIR}/src/lib - ${CMAKE_SOURCE_DIR}/src/lib/imgui + ${CMAKE_SOURCE_DIR}/ext + ${CMAKE_SOURCE_DIR}/ext/imgui ${CMAKE_SOURCE_DIR}/incl ${PROJECT_BINARY_DIR} ) @@ -75,8 +75,8 @@ target_precompile_headers(yaze_app_core_lib PRIVATE target_include_directories(yaze_app_core_lib PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/app - ${CMAKE_SOURCE_DIR}/src/lib - ${CMAKE_SOURCE_DIR}/src/lib/imgui + ${CMAKE_SOURCE_DIR}/ext + ${CMAKE_SOURCE_DIR}/ext/imgui ${CMAKE_SOURCE_DIR}/incl ${SDL2_INCLUDE_DIR} ${PROJECT_BINARY_DIR} @@ -96,15 +96,15 @@ target_link_libraries(yaze_app_core_lib PUBLIC # Link nativefiledialog-extended for Windows/Linux file dialogs if(WIN32 OR (UNIX AND NOT APPLE)) - add_subdirectory(${CMAKE_SOURCE_DIR}/src/lib/nativefiledialog-extended ${CMAKE_BINARY_DIR}/nfd EXCLUDE_FROM_ALL) + add_subdirectory(${CMAKE_SOURCE_DIR}/ext/nativefiledialog-extended ${CMAKE_BINARY_DIR}/nfd EXCLUDE_FROM_ALL) target_link_libraries(yaze_app_core_lib PUBLIC nfd) - target_include_directories(yaze_app_core_lib PUBLIC ${CMAKE_SOURCE_DIR}/src/lib/nativefiledialog-extended/src/include) + target_include_directories(yaze_app_core_lib PUBLIC ${CMAKE_SOURCE_DIR}/ext/nativefiledialog-extended/src/include) endif() # gRPC Services (Optional) if(YAZE_WITH_GRPC) target_include_directories(yaze_app_core_lib PRIVATE - ${CMAKE_SOURCE_DIR}/third_party/json/include) + ${CMAKE_SOURCE_DIR}/ext/json/include) target_compile_definitions(yaze_app_core_lib PRIVATE YAZE_WITH_JSON) # Link to consolidated gRPC support library diff --git a/src/app/editor/editor_library.cmake b/src/app/editor/editor_library.cmake index b309d0a3..e493c1bc 100644 --- a/src/app/editor/editor_library.cmake +++ b/src/app/editor/editor_library.cmake @@ -57,7 +57,7 @@ set( app/editor/ui/workspace_manager.cc ) -if(YAZE_ENABLE_GRPC) +if(YAZE_BUILD_AGENT_UI) list(APPEND YAZE_APP_EDITOR_SRC app/editor/agent/agent_editor.cc app/editor/agent/agent_chat_widget.cc @@ -95,9 +95,9 @@ target_precompile_headers(yaze_editor PRIVATE target_include_directories(yaze_editor PUBLIC ${CMAKE_SOURCE_DIR}/src - ${CMAKE_SOURCE_DIR}/src/lib - ${CMAKE_SOURCE_DIR}/src/lib/imgui - ${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine + ${CMAKE_SOURCE_DIR}/ext + ${CMAKE_SOURCE_DIR}/ext/imgui + ${CMAKE_SOURCE_DIR}/ext/imgui_test_engine ${CMAKE_SOURCE_DIR}/incl ${SDL2_INCLUDE_DIR} ${PROJECT_BINARY_DIR} @@ -114,11 +114,13 @@ target_link_libraries(yaze_editor PUBLIC ImGui ) -# Link agent library for AI features (always available when not in minimal build) -if(NOT YAZE_MINIMAL_BUILD) +# Link agent runtime only when agent UI panels are enabled +if(YAZE_BUILD_AGENT_UI AND NOT YAZE_MINIMAL_BUILD) if(TARGET yaze_agent) target_link_libraries(yaze_editor PUBLIC yaze_agent) - message(STATUS "✓ yaze_editor linked to yaze_agent") + message(STATUS "✓ yaze_editor linked to yaze_agent (UI panels)") + else() + message(WARNING "Agent UI requested but yaze_agent target not found") endif() endif() @@ -126,7 +128,7 @@ endif() if(YAZE_WITH_JSON) target_include_directories(yaze_editor PUBLIC - ${CMAKE_SOURCE_DIR}/third_party/json/include) + ${CMAKE_SOURCE_DIR}/ext/json/include) if(TARGET nlohmann_json::nlohmann_json) target_link_libraries(yaze_editor PUBLIC nlohmann_json::nlohmann_json) diff --git a/src/app/net/net_library.cmake b/src/app/net/net_library.cmake index a2754813..8090887b 100644 --- a/src/app/net/net_library.cmake +++ b/src/app/net/net_library.cmake @@ -29,10 +29,10 @@ target_precompile_headers(yaze_net PRIVATE target_include_directories(yaze_net PUBLIC ${CMAKE_SOURCE_DIR}/src - ${CMAKE_SOURCE_DIR}/src/lib - ${CMAKE_SOURCE_DIR}/src/lib/imgui - ${CMAKE_SOURCE_DIR}/third_party/json/include - ${CMAKE_SOURCE_DIR}/third_party/httplib + ${CMAKE_SOURCE_DIR}/ext + ${CMAKE_SOURCE_DIR}/ext/imgui + ${CMAKE_SOURCE_DIR}/ext/json/include + ${CMAKE_SOURCE_DIR}/ext/httplib ${PROJECT_BINARY_DIR} ) @@ -47,7 +47,7 @@ target_link_libraries(yaze_net PUBLIC if(YAZE_WITH_JSON) # Link nlohmann_json which provides the include directories automatically target_link_libraries(yaze_net PUBLIC nlohmann_json::nlohmann_json) - target_include_directories(yaze_net PUBLIC ${CMAKE_SOURCE_DIR}/third_party/httplib) + target_include_directories(yaze_net PUBLIC ${CMAKE_SOURCE_DIR}/ext/httplib) target_compile_definitions(yaze_net PUBLIC YAZE_WITH_JSON) # Add threading support (cross-platform) diff --git a/src/app/service/grpc_support.cmake b/src/app/service/grpc_support.cmake index 8f857a80..be963a42 100644 --- a/src/app/service/grpc_support.cmake +++ b/src/app/service/grpc_support.cmake @@ -21,10 +21,6 @@ set( # Test infrastructure app/test/test_recorder.cc app/test/test_script_parser.cc - - # CLI agent gRPC client code (only files that actually exist) - cli/service/planning/tile16_proposal_generator.cc - cli/service/gui/gui_automation_client.cc ) add_library(yaze_grpc_support STATIC ${YAZE_GRPC_SOURCES}) @@ -36,9 +32,9 @@ target_precompile_headers(yaze_grpc_support PRIVATE target_include_directories(yaze_grpc_support PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/app - ${CMAKE_SOURCE_DIR}/src/lib - ${CMAKE_SOURCE_DIR}/src/lib/imgui - ${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine + ${CMAKE_SOURCE_DIR}/ext + ${CMAKE_SOURCE_DIR}/ext/imgui + ${CMAKE_SOURCE_DIR}/ext/imgui_test_engine ${CMAKE_SOURCE_DIR}/incl ${SDL2_INCLUDE_DIR} ${PROJECT_BINARY_DIR} @@ -60,7 +56,7 @@ target_link_libraries(yaze_grpc_support PUBLIC # Add JSON support if(YAZE_WITH_JSON) target_include_directories(yaze_grpc_support PUBLIC - ${CMAKE_SOURCE_DIR}/third_party/json/include) + ${CMAKE_SOURCE_DIR}/ext/json/include) target_compile_definitions(yaze_grpc_support PUBLIC YAZE_WITH_JSON) endif() diff --git a/src/app/test/test.cmake b/src/app/test/test.cmake index fa8eca82..a28ebc9c 100644 --- a/src/app/test/test.cmake +++ b/src/app/test/test.cmake @@ -26,7 +26,7 @@ target_precompile_headers(yaze_test_support PRIVATE target_include_directories(yaze_test_support PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/incl - ${CMAKE_SOURCE_DIR}/src/lib + ${CMAKE_SOURCE_DIR}/ext ${PROJECT_BINARY_DIR} ) @@ -43,7 +43,7 @@ target_link_libraries(yaze_test_support PUBLIC # Add gRPC dependencies if test harness is enabled if(YAZE_WITH_GRPC) target_include_directories(yaze_test_support PRIVATE - ${CMAKE_SOURCE_DIR}/third_party/json/include) + ${CMAKE_SOURCE_DIR}/ext/json/include) target_compile_definitions(yaze_test_support PRIVATE YAZE_WITH_JSON) # Link to consolidated gRPC support library diff --git a/src/cli/agent.cmake b/src/cli/agent.cmake index 58f961ba..28a39d68 100644 --- a/src/cli/agent.cmake +++ b/src/cli/agent.cmake @@ -1,4 +1,21 @@ -set(YAZE_AGENT_SOURCES +set(_YAZE_NEEDS_AGENT FALSE) +if(YAZE_ENABLE_AGENT_CLI AND (YAZE_BUILD_CLI OR YAZE_BUILD_Z3ED)) + set(_YAZE_NEEDS_AGENT TRUE) +endif() +if(YAZE_BUILD_AGENT_UI) + set(_YAZE_NEEDS_AGENT TRUE) +endif() +if(YAZE_BUILD_TESTS AND NOT YAZE_MINIMAL_BUILD) + set(_YAZE_NEEDS_AGENT TRUE) +endif() + +if(NOT _YAZE_NEEDS_AGENT) + add_library(yaze_agent INTERFACE) + message(STATUS "yaze_agent stubbed out (agent CLI/UI disabled)") + return() +endif() + +set(YAZE_AGENT_CORE_SOURCES # Core infrastructure cli/flags.cc cli/handlers/agent.cc @@ -30,31 +47,19 @@ set(YAZE_AGENT_SOURCES cli/handlers/rom/rom_commands.cc cli/handlers/tools/gui_commands.cc cli/handlers/tools/resource_commands.cc - cli/service/agent/advanced_routing.cc - cli/service/agent/agent_pretraining.cc cli/service/agent/conversational_agent_service.cc cli/service/agent/enhanced_tui.cc cli/service/agent/learned_knowledge_service.cc cli/service/agent/prompt_manager.cc - cli/service/agent/proposal_executor.cc cli/service/agent/simple_chat_session.cc cli/service/agent/todo_manager.cc cli/service/agent/tool_dispatcher.cc cli/service/agent/vim_mode.cc - cli/service/ai/ai_action_parser.cc - cli/service/ai/ai_gui_controller.cc - cli/service/ai/ai_service.cc - cli/service/ai/ollama_ai_service.cc - cli/service/ai/prompt_builder.cc - cli/service/ai/service_factory.cc - cli/service/ai/vision_action_refiner.cc cli/service/command_registry.cc cli/service/gui/gui_action_generator.cc - cli/service/gui/gui_automation_client.cc cli/service/net/z3ed_network_client.cc cli/service/planning/policy_evaluator.cc cli/service/planning/proposal_registry.cc - cli/service/planning/tile16_proposal_generator.cc cli/service/resources/command_context.cc cli/service/resources/command_handler.cc cli/service/resources/resource_catalog.cc @@ -70,16 +75,36 @@ set(YAZE_AGENT_SOURCES # ROM commands ) -# gRPC-dependent sources (only added when gRPC is enabled) -if(YAZE_ENABLE_GRPC) +# AI runtime sources +if(YAZE_ENABLE_AI_RUNTIME) + list(APPEND YAZE_AGENT_CORE_SOURCES + cli/service/agent/advanced_routing.cc + cli/service/agent/agent_pretraining.cc + cli/service/agent/proposal_executor.cc + cli/service/ai/ai_action_parser.cc + cli/service/ai/ai_gui_controller.cc + cli/service/ai/ai_service.cc + cli/service/ai/ollama_ai_service.cc + cli/service/ai/prompt_builder.cc + cli/service/ai/service_factory.cc + cli/service/ai/vision_action_refiner.cc + ) +endif() + +set(YAZE_AGENT_SOURCES ${YAZE_AGENT_CORE_SOURCES}) + +# gRPC-dependent sources (only added when remote automation is enabled) +if(YAZE_ENABLE_REMOTE_AUTOMATION) list(APPEND YAZE_AGENT_SOURCES cli/service/agent/agent_control_server.cc cli/service/agent/emulator_service_impl.cc cli/handlers/tools/emulator_commands.cc + cli/service/gui/gui_automation_client.cc + cli/service/planning/tile16_proposal_generator.cc ) endif() -if(YAZE_ENABLE_JSON) +if(YAZE_ENABLE_AI_RUNTIME AND YAZE_ENABLE_JSON) list(APPEND YAZE_AGENT_SOURCES cli/service/ai/gemini_ai_service.cc) endif() @@ -106,23 +131,26 @@ target_include_directories(yaze_agent PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/incl - ${CMAKE_SOURCE_DIR}/third_party/httplib - ${CMAKE_SOURCE_DIR}/third_party/json/include + ${CMAKE_SOURCE_DIR}/ext/httplib ${CMAKE_SOURCE_DIR}/src/lib ${CMAKE_SOURCE_DIR}/src/cli/handlers ) +if(YAZE_ENABLE_AI_RUNTIME AND YAZE_ENABLE_JSON) + target_include_directories(yaze_agent PUBLIC ${CMAKE_SOURCE_DIR}/ext/json/include) +endif() + if(SDL2_INCLUDE_DIR) target_include_directories(yaze_agent PUBLIC ${SDL2_INCLUDE_DIR}) endif() -if(YAZE_ENABLE_JSON) +if(YAZE_ENABLE_AI_RUNTIME AND YAZE_ENABLE_JSON) target_link_libraries(yaze_agent PUBLIC nlohmann_json::nlohmann_json) target_compile_definitions(yaze_agent PUBLIC YAZE_WITH_JSON) # Only link OpenSSL if gRPC is NOT enabled (to avoid duplicate symbol errors) # When gRPC is enabled, it brings its own OpenSSL which we'll use instead - if(NOT YAZE_ENABLE_GRPC) + if(NOT YAZE_ENABLE_REMOTE_AUTOMATION) find_package(OpenSSL) if(OpenSSL_FOUND) target_compile_definitions(yaze_agent PUBLIC CPPHTTPLIB_OPENSSL_SUPPORT) @@ -150,7 +178,7 @@ if(YAZE_ENABLE_JSON) endif() # Add gRPC support for GUI automation -if(YAZE_ENABLE_GRPC) +if(YAZE_ENABLE_REMOTE_AUTOMATION) # Link to consolidated gRPC support library target_link_libraries(yaze_agent PUBLIC yaze_grpc_support) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 4ca8c4f7..cdd47a40 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -10,7 +10,7 @@ # Add ASAR library subdirectory # TODO: Fix ASAR CMakeLists.txt macro errors -# add_subdirectory(${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar ${CMAKE_BINARY_DIR}/asar) +# add_subdirectory(${CMAKE_SOURCE_DIR}/ext/asar/src/asar ${CMAKE_BINARY_DIR}/asar) # Core library sources set(YAZE_CORE_LIB_SOURCES @@ -28,10 +28,10 @@ target_compile_features(yaze_core_lib PUBLIC cxx_std_20) target_include_directories(yaze_core_lib PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/app # Needed for app/gui/core/icons.h temporarily - ${CMAKE_SOURCE_DIR}/src/lib/asar/src - ${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar - ${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar-dll-bindings/c - ${CMAKE_SOURCE_DIR}/src/lib/imgui # Needed for ImGui in project.cc temporarily + ${CMAKE_SOURCE_DIR}/ext/asar/src + ${CMAKE_SOURCE_DIR}/ext/asar/src/asar + ${CMAKE_SOURCE_DIR}/ext/asar/src/asar-dll-bindings/c + ${CMAKE_SOURCE_DIR}/ext/imgui # Needed for ImGui in project.cc temporarily ${CMAKE_SOURCE_DIR}/incl ${PROJECT_BINARY_DIR} ) diff --git a/src/ios/yaze.xcodeproj/project.pbxproj b/src/ios/yaze.xcodeproj/project.pbxproj index 3d04a449..ff6e3939 100644 --- a/src/ios/yaze.xcodeproj/project.pbxproj +++ b/src/ios/yaze.xcodeproj/project.pbxproj @@ -936,9 +936,9 @@ /* Begin PBXFileReference section */ 05318E0E274C397200A8DE2E /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; }; - 07A82ED62139413C0078D120 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../yaze/src/lib/imgui/imgui_internal.h; sourceTree = ""; }; - 07A82ED72139413C0078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = /Users/scawful/Code/yaze/src/lib/imgui/imgui_widgets.cpp; sourceTree = ""; }; - 5079822D257677DB0038A28D /* imgui_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_tables.cpp; path = /Users/scawful/Code/yaze/src/lib/imgui/imgui_tables.cpp; sourceTree = ""; }; + 07A82ED62139413C0078D120 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../yaze/ext/imgui/imgui_internal.h; sourceTree = ""; }; + 07A82ED72139413C0078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = /Users/scawful/Code/yaze/ext/imgui/imgui_widgets.cpp; sourceTree = ""; }; + 5079822D257677DB0038A28D /* imgui_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_tables.cpp; path = /Users/scawful/Code/yaze/ext/imgui/imgui_tables.cpp; sourceTree = ""; }; 8307E7C420E9F9C900473790 /* yaze.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = yaze.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8307E7DA20E9F9C900473790 /* yaze.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = yaze.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8309BD8E253CCAAA0045E2A1 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; @@ -955,9 +955,9 @@ 83BBE9EA20EB471700295997 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; 83BBE9EB20EB471700295997 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; }; 83BBE9EE20EB471C00295997 /* ModelIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ModelIO.framework; path = System/Library/Frameworks/ModelIO.framework; sourceTree = SDKROOT; }; - 83BBEA0120EB54E700295997 /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = /Users/scawful/Code/yaze/src/lib/imgui/imgui_draw.cpp; sourceTree = ""; }; - 83BBEA0220EB54E700295997 /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = /Users/scawful/Code/yaze/src/lib/imgui/imgui_demo.cpp; sourceTree = ""; }; - 83BBEA0320EB54E700295997 /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = /Users/scawful/Code/yaze/src/lib/imgui/imgui.cpp; sourceTree = ""; }; + 83BBEA0120EB54E700295997 /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = /Users/scawful/Code/yaze/ext/imgui/imgui_draw.cpp; sourceTree = ""; }; + 83BBEA0220EB54E700295997 /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = /Users/scawful/Code/yaze/ext/imgui/imgui_demo.cpp; sourceTree = ""; }; + 83BBEA0320EB54E700295997 /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = /Users/scawful/Code/yaze/ext/imgui/imgui.cpp; sourceTree = ""; }; 83BBEA0420EB54E700295997 /* imconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = imconfig.h; sourceTree = ""; }; E318D8472C59C08300091322 /* app_delegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = app_delegate.h; sourceTree = ""; }; E318D8482C59C08300091322 /* app_delegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = app_delegate.mm; sourceTree = ""; }; @@ -1066,10 +1066,10 @@ E318D8F22C59C08300091322 /* common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = ""; }; E318D8F62C59C08300091322 /* rom.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rom.cc; sourceTree = ""; }; E318D8F72C59C08300091322 /* rom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rom.h; sourceTree = ""; }; - E318D9942C59CDF800091322 /* imgui_impl_sdl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_sdl2.cpp; path = ../../yaze/src/lib/imgui/backends/imgui_impl_sdl2.cpp; sourceTree = ""; }; - E318D9972C59D0C400091322 /* imgui_impl_sdlrenderer2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_sdlrenderer2.cpp; path = ../../yaze/src/lib/imgui/backends/imgui_impl_sdlrenderer2.cpp; sourceTree = ""; }; - E318D99B2C59D0E500091322 /* imgui_stdlib.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_stdlib.cpp; path = ../../yaze/src/lib/imgui/misc/cpp/imgui_stdlib.cpp; sourceTree = ""; }; - E318D99C2C59D0E500091322 /* imgui_stdlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_stdlib.h; path = ../../yaze/src/lib/imgui/misc/cpp/imgui_stdlib.h; sourceTree = ""; }; + E318D9942C59CDF800091322 /* imgui_impl_sdl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_sdl2.cpp; path = ../../yaze/ext/imgui/backends/imgui_impl_sdl2.cpp; sourceTree = ""; }; + E318D9972C59D0C400091322 /* imgui_impl_sdlrenderer2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_sdlrenderer2.cpp; path = ../../yaze/ext/imgui/backends/imgui_impl_sdlrenderer2.cpp; sourceTree = ""; }; + E318D99B2C59D0E500091322 /* imgui_stdlib.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_stdlib.cpp; path = ../../yaze/ext/imgui/misc/cpp/imgui_stdlib.cpp; sourceTree = ""; }; + E318D99C2C59D0E500091322 /* imgui_stdlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_stdlib.h; path = ../../yaze/ext/imgui/misc/cpp/imgui_stdlib.h; sourceTree = ""; }; E318D9A02C59DFD200091322 /* libpng16.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpng16.a; path = "../../../opt/anaconda3/pkgs/libpng-1.6.37-ha441bb4_0/lib/libpng16.a"; sourceTree = ""; }; E318D9A32C5A4FBD00091322 /* algorithm_test.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = algorithm_test.cc; sourceTree = ""; }; E318D9A42C5A4FBD00091322 /* algorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = algorithm.h; sourceTree = ""; }; diff --git a/src/util/util.cmake b/src/util/util.cmake index 4f317e70..60bb28c2 100644 --- a/src/util/util.cmake +++ b/src/util/util.cmake @@ -31,6 +31,7 @@ target_include_directories(yaze_util PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/incl ${CMAKE_SOURCE_DIR}/src/lib + ${CMAKE_SOURCE_DIR}/ext ${PROJECT_BINARY_DIR} ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c556db7b..c96e6299 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,13 +13,13 @@ if(YAZE_BUILD_TESTS) ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/incl ${CMAKE_SOURCE_DIR}/test - ${CMAKE_SOURCE_DIR}/src/lib - ${CMAKE_SOURCE_DIR}/src/lib/imgui - ${CMAKE_SOURCE_DIR}/src/lib/imgui/backends - ${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine - ${CMAKE_SOURCE_DIR}/src/lib/SDL/include - ${CMAKE_SOURCE_DIR}/third_party/json/include - ${CMAKE_BINARY_DIR}/src/lib/SDL/include + ${CMAKE_SOURCE_DIR}/ext + ${CMAKE_SOURCE_DIR}/ext/imgui + ${CMAKE_SOURCE_DIR}/ext/imgui/backends + ${CMAKE_SOURCE_DIR}/ext/imgui_test_engine + ${CMAKE_SOURCE_DIR}/ext/SDL/include + ${CMAKE_SOURCE_DIR}/ext/json/include + ${CMAKE_BINARY_DIR}/ext/SDL/include ${PROJECT_BINARY_DIR} ) diff --git a/test/e2e/README.md b/test/e2e/README.md index 8d0cf4da..2ca5645b 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -93,7 +93,7 @@ Key methods available: - `ctx->LogError("message", ...)` - Log error - `ctx->Yield()` - Yield to allow UI to update -Full API: `src/lib/imgui_test_engine/imgui_te_engine.h` +Full API: `ext/imgui_test_engine/imgui_te_engine.h` ## Test Logging @@ -163,7 +163,7 @@ Potential tests to add: ## References -- **ImGui Test Engine**: `src/lib/imgui_test_engine/` +- **ImGui Test Engine**: `ext/imgui_test_engine/` - **Test Registration**: `test/yaze_test.cc` - **Test Utilities**: `test/test_utils.h` - **Working Examples**: See existing tests in this directory