载入中...
搜索中...
未找到
EditorMcpProjector.cpp
浏览该文件的文档.
2
3#include "common/Capability.h"
6#include "editor/EditorHost.h"
7
8#include <algorithm>
9#include <set>
10
11namespace eve::editor {
12
14 static EditorMcpProjector projector;
15 return projector;
16}
17
20 return eve::editing::failed<void>(EditorStatus::Unsupported, RuleId("editor.mcp.mode"),
21 "Only MCP export mode Commands (A) is supported");
22 host_ = host;
23 mode_ = mode;
24 return eve::editing::applied<void>();
25}
26
27void EditorMcpProjector::detach() { host_ = nullptr; }
28
29std::unordered_set<std::string> EditorMcpProjector::mountedOwners() const {
30 std::unordered_set<std::string> owners;
31 if (!host_) return owners;
32 for (const std::string& owner : host_->mountedOwnerNames()) owners.insert(owner);
33 return owners;
34}
35
36std::unordered_set<std::string> EditorMcpProjector::mountedTargetTypes() const {
37 std::unordered_set<std::string> types;
38 if (!host_) return types;
39 for (const std::string& type : host_->mountedTargetTypeNames()) types.insert(type);
40 return types;
41}
42
44 EditorValue::Array incomplete;
45 eve::cap::forEach<editing::IEditorPackageProvider>([&](editing::IEditorPackageProvider* provider) {
46 if (!provider) return;
47 const editing::EditorPackage& package = provider->package();
48 if (!package.incomplete) return;
50 item["owner"] = package.ownerModule;
51 item["reason"] = "package.incomplete";
52 incomplete.emplace_back(std::move(item));
53 });
54
55 std::set<std::string> packagedTypes;
56 eve::cap::forEach<editing::IEditorPackageProvider>([&](editing::IEditorPackageProvider* provider) {
57 if (!provider) return;
58 const editing::EditorPackage& package = provider->package();
59 if (package.incomplete) return;
60 for (const editing::EditorTargetTypeSpec& target : package.targetTypes) packagedTypes.insert(target.type);
61 });
62
63 EditorValue::Array orphans;
64 eve::cap::forEach<IEditorAutomationTargetFactory>([&](IEditorAutomationTargetFactory* factory) {
65 if (!factory) return;
66 for (const std::string_view type : factory->types()) {
67 if (packagedTypes.contains(std::string(type))) continue;
68 orphans.emplace_back(std::string(type));
69 }
70 });
71 std::sort(orphans.begin(), orphans.end(), [](const EditorValue& left, const EditorValue& right) {
72 const auto* leftString = left.getIf<std::string>();
73 const auto* rightString = right.getIf<std::string>();
74 return (leftString ? *leftString : std::string{}) < (rightString ? *rightString : std::string{});
75 });
76
78 report["incompletePackages"] = std::move(incomplete);
79 report["orphanFactoryTypes"] = std::move(orphans);
80 report["mode"] = "commands";
81 report["attached"] = isAttached();
82 if (host_) report["hostId"] = host_->workspace().getId();
83 return eve::editing::applied<EditorValue>(EditorValue(std::move(report)));
84}
85
86} // namespace eve::editor
LogicalId target
HexVec3 left
HexVec3 right
std::shared_ptr< OceanGpuSpectrum > owner
UIHostHandle host
Move-only operation result carrying either a value or Status.
Definition Result.h:176
Capability-discovered package advertisement from a domain editor module.
Deterministic owning value tree shared by authoring hosts.
std::vector< Value > Array
std::map< std::string, Value > Object
Composition runtime that discovers EditorPackage providers and installs them.
Definition EditorHost.h:53
std::vector< std::string > mountedOwnerNames() const
Mounted package owner names. @cost Linear in mounted package count; returns an owning vector copy.
EditorWorkspace & workspace()
Workspace receiving merged panels.
Definition EditorHost.h:89
std::vector< std::string > mountedTargetTypeNames() const
Target types contributed by mounted packages. @cost Linear in mounted target types; returns a sorted ...
Host-scoped MCP projection over IEditorAutomation discovery.
Result< EditorValue > auditCompleteness() const
Audit incomplete packages and orphan automation factories.
void detach()
Clear the active attachment.
EditorHost * host() const
Borrowed attached host, or null.
std::unordered_set< std::string > mountedOwners() const
Mounted owner allowlist, empty when detached (no filter). @cost Linear in mounted package count; retu...
Result< void > attach(EditorHost *host, EditorMcpExportMode mode=EditorMcpExportMode::Commands)
Attach a borrowed host as the active MCP projection scope.
std::unordered_set< std::string > mountedTargetTypes() const
Mounted target type allowlist, empty when detached (no filter). @cost Linear in mounted target types;...
bool isAttached() const
True when a host is attached.
EditorMcpExportMode mode() const
Active export mode.
const std::string & getId() const
Stable project-defined workspace id.
Multi-provider extension point for domain-specific automation target creation.
virtual std::vector< std::string_view > types() const =0
Stable target type names this factory accepts.
EditorMcpProjector & editorMcpProjector()
Process-wide projector used by EditorAutomationProvider and eve.mcp.attachEditor.
eve::editing::Value EditorValue
Compatibility alias for the UI-independent authoring value tree.
Definition EditorValue.h:8
eve::editing::RuleId RuleId
Definition EditorIds.h:32
EditorMcpExportMode
MCP export mode for an attached EditorHost.
@ Commands
Mode A: keep eve_editor_* with schema enrichment (default).
Single domain-editor deliverable for Host discover/autoMount.
Target type advertised for automation create, with optional createSchema.