diff --git a/PROGRESS.md b/PROGRESS.md index f804c37..912b3af 100644 --- a/PROGRESS.md +++ b/PROGRESS.md @@ -382,7 +382,7 @@ vcpkg's imgui 1.91.9 removed the `sdl2-binding` feature (only `sdl3-binding` exi ## What's Next -Sprint 5 in progress. Step 138 (type-aware code generation) done. Next: Step 139 (library compatibility matrix). +Sprint 5 in progress. Step 139 (library compatibility matrix) done. Next: Step 140 (constructive coding tests). --- @@ -484,5 +484,6 @@ Sprint 5 in progress. Step 138 (type-aware code generation) done. Next: Step 139 | 2026-02-09 | Codex | Step 136: Agent preferImports/strictMode policy checks on mutations with warnings or blocking. 4/4 tests pass. | | 2026-02-09 | Codex | Step 137: Composition builder panel with pipeline generation and code insertion. 4/4 tests pass. | | 2026-02-09 | Codex | Step 138: Type-aware C++ generation via library call mappings. 2/2 tests pass. | +| 2026-02-09 | Codex | Step 139: Library compatibility matrix with default mappings. 3/3 tests pass. | | 2026-02-09 | Codex | Added FEATURE_REQUESTS.md to track security vulnerability awareness and semantic library annotations for future sprints. | | 2026-02-09 | Codex | Added LLM tooling + MCP bridge feature request to FEATURE_REQUESTS.md. | diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index d55e566..c86208e 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -770,6 +770,10 @@ add_executable(step138_test tests/step138_test.cpp) target_include_directories(step138_test PRIVATE src) target_link_libraries(step138_test PRIVATE nlohmann_json::nlohmann_json) +add_executable(step139_test tests/step139_test.cpp) +target_include_directories(step139_test PRIVATE src) +target_link_libraries(step139_test PRIVATE nlohmann_json::nlohmann_json) + find_package(SDL2 CONFIG REQUIRED) find_package(OpenGL REQUIRED) find_package(glad CONFIG REQUIRED) diff --git a/editor/src/LibraryCompatibility.h b/editor/src/LibraryCompatibility.h new file mode 100644 index 0000000..389c4e9 --- /dev/null +++ b/editor/src/LibraryCompatibility.h @@ -0,0 +1,38 @@ +#pragma once +#include +#include +#include + +class LibraryCompatibility { +public: + void addMapping(const std::string& fromLibrary, + const std::string& fromLang, + const std::string& toLibrary, + const std::string& toLang) { + mappings_[key(fromLibrary, fromLang)].push_back({toLibrary, toLang}); + } + + std::vector> getMappings( + const std::string& fromLibrary, + const std::string& fromLang) const { + auto it = mappings_.find(key(fromLibrary, fromLang)); + if (it == mappings_.end()) return {}; + return it->second; + } + + void loadDefaultMappings() { + addMapping("numpy", "python", "Eigen", "cpp"); + addMapping("numpy", "python", "ndarray", "rust"); + addMapping("pandas", "python", "dataframe", "rust"); + addMapping("pandas", "python", "DataFrame", "cpp"); + addMapping("requests", "python", "reqwest", "rust"); + addMapping("requests", "python", "cpr", "cpp"); + } + +private: + static std::string key(const std::string& lib, const std::string& lang) { + return lib + "|" + lang; + } + + std::unordered_map>> mappings_; +}; diff --git a/editor/tests/step139_test.cpp b/editor/tests/step139_test.cpp new file mode 100644 index 0000000..46c90e6 --- /dev/null +++ b/editor/tests/step139_test.cpp @@ -0,0 +1,43 @@ +// Step 139 TDD Test: Library compatibility matrix +#include "LibraryCompatibility.h" +#include + +static void expect(bool cond, const std::string& name, int& passed, int& failed) { + if (cond) { + std::cout << "Test " << (passed + failed + 1) << " PASS: " << name << "\n"; + ++passed; + } else { + std::cout << "Test " << (passed + failed + 1) << " FAIL: " << name << "\n"; + ++failed; + } +} + +int main() { + int passed = 0; + int failed = 0; + + LibraryCompatibility compat; + compat.loadDefaultMappings(); + auto mappings = compat.getMappings("numpy", "python"); + expect(!mappings.empty(), "numpy mappings present", passed, failed); + bool hasEigen = false; + for (const auto& entry : mappings) { + if (entry.first == "Eigen" && entry.second == "cpp") { + hasEigen = true; + } + } + expect(hasEigen, "numpy -> Eigen mapping", passed, failed); + + compat.addMapping("numpy", "python", "armadillo", "cpp"); + auto mappings2 = compat.getMappings("numpy", "python"); + bool hasArma = false; + for (const auto& entry : mappings2) { + if (entry.first == "armadillo" && entry.second == "cpp") { + hasArma = true; + } + } + expect(hasArma, "custom mapping added", passed, failed); + + std::cout << "\n=== Step 139 Results: " << passed << " passed, " << failed << " failed ===\n"; + return failed == 0 ? 0 : 1; +} diff --git a/sprint5_plan.md b/sprint5_plan.md index a50680e..b2d124d 100644 --- a/sprint5_plan.md +++ b/sprint5_plan.md @@ -146,7 +146,7 @@ what's already available. Cross-language projection respects library type mappings. *Modifies:* `CrossLanguageProjector.h`, `Generator.h` -- [ ] **Step 139: Library compatibility matrix** +- [x] **Step 139: Library compatibility matrix** Track which libraries have equivalents across languages. Example: `numpy` (Python) ↔ `Eigen` (C++) ↔ `ndarray` (Rust). When projecting code cross-language, suggest equivalent libraries.