diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 2569382..4a3755f 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -4783,4 +4783,13 @@ target_link_libraries(step655_test PRIVATE tree_sitter_javascript tree_sitter_typescript tree_sitter_java tree_sitter_rust tree_sitter_go) +add_executable(step656_test tests/step656_test.cpp) +target_include_directories(step656_test PRIVATE src) +target_link_libraries(step656_test PRIVATE + nlohmann_json::nlohmann_json + unofficial::tree-sitter::tree-sitter + tree_sitter_python tree_sitter_cpp tree_sitter_elisp + tree_sitter_javascript tree_sitter_typescript + tree_sitter_java tree_sitter_rust tree_sitter_go) + # Step 12: Dear ImGui shell scaffolding created (main.cpp exists but not built due to dependencies) diff --git a/editor/src/ApiaryBrowserPanelModel.h b/editor/src/ApiaryBrowserPanelModel.h new file mode 100644 index 0000000..bdce4ad --- /dev/null +++ b/editor/src/ApiaryBrowserPanelModel.h @@ -0,0 +1,36 @@ +#pragma once +// Step 656: Apiary browser panel model + +#include +#include + +struct ApiaryToolEntry { + std::string name; + std::string version; + std::string language; + std::vector capabilities; + std::string docSummary; + std::string sourcePath; +}; + +class ApiaryBrowserPanelModel { +public: + static std::vector filterByCapability(const std::vector& entries, + const std::string& capability) { + if (capability.empty()) return entries; + std::vector out; + for (const auto& e : entries) { + for (const auto& cap : e.capabilities) { + if (cap == capability) { + out.push_back(e); + break; + } + } + } + return out; + } + + static std::string title(const ApiaryToolEntry& entry) { + return entry.name + " v" + entry.version; + } +}; diff --git a/editor/tests/step656_test.cpp b/editor/tests/step656_test.cpp new file mode 100644 index 0000000..b6022ec --- /dev/null +++ b/editor/tests/step656_test.cpp @@ -0,0 +1,29 @@ +// Step 656: Apiary browser panel (12 tests) + +#include "ApiaryBrowserPanelModel.h" +#include +static int p=0,f=0; +#define T(n) { std::cout<<" "<<#n<<"... "; } +#define P() { std::cout<<"PASS\n"; ++p; } +#define F(m) { std::cout<<"FAIL: "< tools(){ +return {{"nexus","1.0","cpp",{"db","jobs"},"nexus tool","/mnt/nas/swarm_tools/nexus.cpp"}, +{"drone","2.1","rust",{"jobs","executor"},"drone tool","/mnt/nas/swarm_tools/drone.rs"}, +{"vision","0.9","python",{"cv"},"vision tool","/mnt/nas/swarm_tools/vision.py"}};} + +void t1(){T(empty_capability_returns_all);auto r=ApiaryBrowserPanelModel::filterByCapability(tools(),"");C(r.size()==3,"all");P();} +void t2(){T(filter_jobs_returns_two);auto r=ApiaryBrowserPanelModel::filterByCapability(tools(),"jobs");C(r.size()==2,"jobs");P();} +void t3(){T(filter_cv_returns_one);auto r=ApiaryBrowserPanelModel::filterByCapability(tools(),"cv");C(r.size()==1,"cv");P();} +void t4(){T(filter_missing_returns_zero);auto r=ApiaryBrowserPanelModel::filterByCapability(tools(),"none");C(r.empty(),"none");P();} +void t5(){T(filter_preserves_order);auto r=ApiaryBrowserPanelModel::filterByCapability(tools(),"jobs");C(r[0].name=="nexus"&&r[1].name=="drone","order");P();} +void t6(){T(title_includes_name);C(ApiaryBrowserPanelModel::title(tools()[0]).find("nexus")!=std::string::npos,"name");P();} +void t7(){T(title_includes_version);C(ApiaryBrowserPanelModel::title(tools()[0]).find("1.0")!=std::string::npos,"version");P();} +void t8(){T(source_path_is_preserved);C(tools()[1].sourcePath.find("drone.rs")!=std::string::npos,"source");P();} +void t9(){T(language_field_available);C(tools()[2].language=="python","lang");P();} +void t10(){T(doc_summary_field_available);C(tools()[0].docSummary=="nexus tool","doc");P();} +void t11(){T(capability_match_is_exact);auto r=ApiaryBrowserPanelModel::filterByCapability(tools(),"job");C(r.empty(),"exact");P();} +void t12(){T(filter_handles_single_entry);std::vector one={tools()[0]};auto r=ApiaryBrowserPanelModel::filterByCapability(one,"db");C(r.size()==1,"single");P();} + +int main(){std::cout<<"Step 656: Apiary browser panel\n";t1();t2();t3();t4();t5();t6();t7();t8();t9();t10();t11();t12();std::cout<<"\nResults: "<