Step 656: apiary browser panel model
This commit is contained in:
@@ -4783,4 +4783,13 @@ target_link_libraries(step655_test PRIVATE
|
|||||||
tree_sitter_javascript tree_sitter_typescript
|
tree_sitter_javascript tree_sitter_typescript
|
||||||
tree_sitter_java tree_sitter_rust tree_sitter_go)
|
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)
|
# Step 12: Dear ImGui shell scaffolding created (main.cpp exists but not built due to dependencies)
|
||||||
|
|||||||
36
editor/src/ApiaryBrowserPanelModel.h
Normal file
36
editor/src/ApiaryBrowserPanelModel.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
// Step 656: Apiary browser panel model
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
struct ApiaryToolEntry {
|
||||||
|
std::string name;
|
||||||
|
std::string version;
|
||||||
|
std::string language;
|
||||||
|
std::vector<std::string> capabilities;
|
||||||
|
std::string docSummary;
|
||||||
|
std::string sourcePath;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ApiaryBrowserPanelModel {
|
||||||
|
public:
|
||||||
|
static std::vector<ApiaryToolEntry> filterByCapability(const std::vector<ApiaryToolEntry>& entries,
|
||||||
|
const std::string& capability) {
|
||||||
|
if (capability.empty()) return entries;
|
||||||
|
std::vector<ApiaryToolEntry> 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;
|
||||||
|
}
|
||||||
|
};
|
||||||
29
editor/tests/step656_test.cpp
Normal file
29
editor/tests/step656_test.cpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// Step 656: Apiary browser panel (12 tests)
|
||||||
|
|
||||||
|
#include "ApiaryBrowserPanelModel.h"
|
||||||
|
#include <iostream>
|
||||||
|
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: "<<m<<"\n"; ++f; }
|
||||||
|
#define C(c,m) if(!(c)){F(m);return;}
|
||||||
|
|
||||||
|
static std::vector<ApiaryToolEntry> 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<ApiaryToolEntry> 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: "<<p<<"/"<<(p+f)<<" passed\n";return f?1:0;}
|
||||||
24
progress.md
24
progress.md
@@ -13504,3 +13504,27 @@ counts and per-job display formatting.
|
|||||||
- `editor/src/SwarmStatusPanelModel.h` (`46` <= `600`)
|
- `editor/src/SwarmStatusPanelModel.h` (`46` <= `600`)
|
||||||
- `editor/tests/step655_test.cpp` within test-file size guidance (`27` lines)
|
- `editor/tests/step655_test.cpp` within test-file size guidance (`27` lines)
|
||||||
- Header-only architecture and naming conventions remain aligned with `ARCHITECTURE.md`
|
- Header-only architecture and naming conventions remain aligned with `ARCHITECTURE.md`
|
||||||
|
|
||||||
|
### Step 656: Apiary browser panel
|
||||||
|
**Status:** PASS (12/12 tests)
|
||||||
|
|
||||||
|
Adds apiary browser panel modeling for tool listing, capability filtering, and
|
||||||
|
tool title/source metadata presentation.
|
||||||
|
|
||||||
|
**Files added:**
|
||||||
|
- `editor/src/ApiaryBrowserPanelModel.h` - apiary panel model
|
||||||
|
- `editor/tests/step656_test.cpp` - 12 tests for filtering and metadata behavior
|
||||||
|
|
||||||
|
**Files modified:**
|
||||||
|
- `editor/CMakeLists.txt` - `step656_test` target
|
||||||
|
|
||||||
|
**Verification run:**
|
||||||
|
- `cmake -S editor -B editor/build-native` - PASS
|
||||||
|
- `cmake --build editor/build-native --target step656_test step655_test` - PASS
|
||||||
|
- `./editor/build-native/step656_test` - PASS (12/12)
|
||||||
|
- `./editor/build-native/step655_test` - PASS (12/12) regression coverage
|
||||||
|
|
||||||
|
**Architecture gate check:**
|
||||||
|
- `editor/src/ApiaryBrowserPanelModel.h` (`36` <= `600`)
|
||||||
|
- `editor/tests/step656_test.cpp` within test-file size guidance (`29` lines)
|
||||||
|
- Header-only architecture and naming conventions remain aligned with `ARCHITECTURE.md`
|
||||||
|
|||||||
Reference in New Issue
Block a user