More refactoring

This commit is contained in:
2026-04-04 02:58:23 -04:00
parent 7c884e84cb
commit ba63a40641
21 changed files with 176 additions and 104 deletions

View File

@@ -33,8 +33,8 @@ see:
``` ```
There are tons of commands built in: Graph_Dump, There are tons of commands built in: Graph_Dump,
GraphNode_Create, GraphPin_Connect, GraphNode_Add, GraphPin_Connect,
BlueprintComponent_Create, Widget_Create, and so forth. BlueprintComponent_Add, Widget_Add, and so forth.
Using these commands, it's possible to examine and modify Using these commands, it's possible to examine and modify
blueprints, widgets, and materials. blueprints, widgets, and materials.
@@ -131,7 +131,7 @@ You might be interested in seeing the "user manual" for the
plugin. To get that, you type this: plugin. To get that, you type this:
``` ```
$ ue-wingman.py UserManual $ ue-wingman.py Documentation_Manual
``` ```
Of course, you're not the intended user: your AI agent is. Of course, you're not the intended user: your AI agent is.
@@ -141,7 +141,7 @@ User Manual says, among other things, that the AI agent can
get a listing of built-in commands. You can see that too: get a listing of built-in commands. You can see that too:
``` ```
$ ue-wingman.py ShowCommands $ ue-wingman.py Documentation_Commands
``` ```
With these two commands at your disposal, you'll have a better With these two commands at your disposal, you'll have a better

View File

@@ -10,7 +10,7 @@
#include "EdGraph/EdGraph.h" #include "EdGraph/EdGraph.h"
#include "EdGraphSchema_K2.h" #include "EdGraphSchema_K2.h"
#include "Kismet2/BlueprintEditorUtils.h" #include "Kismet2/BlueprintEditorUtils.h"
#include "BlueprintGraph_Create.generated.h" #include "BlueprintGraph_Add.generated.h"
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -18,7 +18,7 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
UCLASS() UCLASS()
class UWing_BlueprintGraph_Create : public UWingHandler class UWing_BlueprintGraph_Add : public UWingHandler
{ {
GENERATED_BODY() GENERATED_BODY()

View File

@@ -8,7 +8,7 @@
#include "Engine/Blueprint.h" #include "Engine/Blueprint.h"
#include "EdGraph/EdGraph.h" #include "EdGraph/EdGraph.h"
#include "Kismet2/BlueprintEditorUtils.h" #include "Kismet2/BlueprintEditorUtils.h"
#include "BlueprintGraph_Delete.generated.h" #include "BlueprintGraph_Remove.generated.h"
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -16,7 +16,7 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
UCLASS() UCLASS()
class UWing_BlueprintGraph_Delete : public UWingHandler class UWing_BlueprintGraph_Remove : public UWingHandler
{ {
GENERATED_BODY() GENERATED_BODY()

View File

@@ -0,0 +1,33 @@
#pragma once
#include "CoreMinimal.h"
#include "WingHandler.h"
#include "WingFetcher.h"
#include "WingServer.h"
#include "WingTypes.h"
#include "WingProperty.h"
#include "WingManual.h"
#include "Documentation_Commands.generated.h"
UCLASS()
class UWing_Documentation_Commands : public UWingHandler
{
GENERATED_BODY()
public:
UPROPERTY(meta=(Optional, Description="Substring filter for command names"))
FString Query;
UPROPERTY(meta=(Optional, Description="If true, return full details including parameter types and descriptions"))
bool Verbose = false;
virtual void Register() override
{
UWingServer::AddHandler(this,
TEXT("List all the main commands with their descriptions."));
}
virtual void Handle() override
{
WingManual::Commands(EWingHandlerKind::Normal, Query, Verbose);
}
};

View File

@@ -0,0 +1,33 @@
#pragma once
#include "CoreMinimal.h"
#include "WingHandler.h"
#include "WingFetcher.h"
#include "WingServer.h"
#include "WingTypes.h"
#include "WingProperty.h"
#include "WingManual.h"
#include "Documentation_CreateAssets.generated.h"
UCLASS()
class UWing_Documentation_CreateAssets : public UWingHandler
{
GENERATED_BODY()
public:
UPROPERTY(meta=(Optional, Description="Substring filter for command names"))
FString Query;
UPROPERTY(meta=(Optional, Description="If true, return full details including parameter types and descriptions"))
bool Verbose = false;
virtual void Register() override
{
UWingServer::AddHandler(this,
TEXT("List all the create commands that create new assets."));
}
virtual void Handle() override
{
WingManual::Commands(EWingHandlerKind::Normal, Query, Verbose);
}
};

View File

@@ -3,10 +3,10 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "WingHandler.h" #include "WingHandler.h"
#include "WingManual.h" #include "WingManual.h"
#include "UserManual.generated.h" #include "Documentation_Manual.generated.h"
UCLASS() UCLASS()
class UWing_UserManual : public UWingHandler class UWing_Documentation_Manual : public UWingHandler
{ {
GENERATED_BODY() GENERATED_BODY()

View File

@@ -8,7 +8,7 @@
#include "Engine/Blueprint.h" #include "Engine/Blueprint.h"
#include "EdGraphSchema_K2.h" #include "EdGraphSchema_K2.h"
#include "Kismet2/BlueprintEditorUtils.h" #include "Kismet2/BlueprintEditorUtils.h"
#include "EventDispatcher_Create.generated.h" #include "EventDispatcher_Add.generated.h"
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -16,7 +16,7 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
UCLASS() UCLASS()
class UWing_EventDispatcher_Create : public UWingHandler class UWing_EventDispatcher_Add : public UWingHandler
{ {
GENERATED_BODY() GENERATED_BODY()

View File

@@ -7,7 +7,7 @@
#include "WingUtils.h" #include "WingUtils.h"
#include "Engine/Blueprint.h" #include "Engine/Blueprint.h"
#include "Kismet2/BlueprintEditorUtils.h" #include "Kismet2/BlueprintEditorUtils.h"
#include "EventDispatcher_Delete.generated.h" #include "EventDispatcher_Remove.generated.h"
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -15,7 +15,7 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
UCLASS() UCLASS()
class UWing_EventDispatcher_Delete : public UWingHandler class UWing_EventDispatcher_Remove : public UWingHandler
{ {
GENERATED_BODY() GENERATED_BODY()

View File

@@ -10,7 +10,7 @@
#include "EdGraph/EdGraph.h" #include "EdGraph/EdGraph.h"
#include "EdGraph/EdGraphNode.h" #include "EdGraph/EdGraphNode.h"
#include "EdGraph/EdGraphSchema.h" #include "EdGraph/EdGraphSchema.h"
#include "GraphNode_Create.generated.h" #include "GraphNode_Add.generated.h"
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -36,7 +36,7 @@ struct FSpawnNodeEntry
UCLASS() UCLASS()
class UWing_GraphNode_Create : public UWingHandler class UWing_GraphNode_Add : public UWingHandler
{ {
GENERATED_BODY() GENERATED_BODY()

View File

@@ -10,7 +10,7 @@
#include "MaterialGraph/MaterialGraphNode.h" #include "MaterialGraph/MaterialGraphNode.h"
#include "Materials/Material.h" #include "Materials/Material.h"
#include "IMaterialEditor.h" #include "IMaterialEditor.h"
#include "GraphNode_Delete.generated.h" #include "GraphNode_Remove.generated.h"
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -18,7 +18,7 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
UCLASS() UCLASS()
class UWing_GraphNode_Delete : public UWingHandler class UWing_GraphNode_Remove : public UWingHandler
{ {
GENERATED_BODY() GENERATED_BODY()

View File

@@ -35,7 +35,7 @@ public:
UWingServer::AddHandler(this, UWingServer::AddHandler(this,
TEXT("Search the action database for node types that can be spawned in a graph. " TEXT("Search the action database for node types that can be spawned in a graph. "
"Works with any graph type (Blueprint, Material, etc.). " "Works with any graph type (Blueprint, Material, etc.). "
"Returns full action names for use with GraphNode_Create.")); "Returns full action names for use with GraphNode_Add."));
} }
virtual void Handle() override virtual void Handle() override
{ {

View File

@@ -1,71 +0,0 @@
#pragma once
#include "CoreMinimal.h"
#include "WingHandler.h"
#include "WingFetcher.h"
#include "WingServer.h"
#include "WingTypes.h"
#include "WingProperty.h"
#include "WingManual.h"
#include "ShowCommands.generated.h"
UCLASS()
class UWing_ShowCommands : public UWingHandler
{
GENERATED_BODY()
public:
UPROPERTY(meta=(Optional, Description="Substring filter for command names"))
FString Query;
UPROPERTY(meta=(Optional, Description="If true, return full details including parameter types and descriptions"))
bool Verbose = false;
UPROPERTY(meta=(Optional, Description="Kind of command: Normal, or Create"))
EWingHandlerKind Kind = EWingHandlerKind::Normal;
virtual void Register() override
{
UWingServer::AddHandler(this,
TEXT("List all available commands with their descriptions."));
}
virtual void Handle() override
{
FString QueryLower = Query.ToLower();
FString PrevGroup;
for (const FWingHandlerConfig& H : UWingServer::AllHandlers())
{
if (H.Kind != Kind) continue;
if (!H.Name.ToLower().Contains(QueryLower)) continue;
// Blank line between groups
if (!Verbose)
{
FString Group = WingUtils::GetHandlerGroup(H.Class.Get());
if (Group != PrevGroup)
{
if (!PrevGroup.IsEmpty())
WingOut::Stdout.Print(TEXT("\n"));
PrevGroup = Group;
}
}
if (Verbose)
{
WingManual::PrintHandlerHelp(H);
}
else
{
WingManual::PrintHandlerPrototype(H);
}
}
if (Kind == EWingHandlerKind::Normal)
{
WingOut::Stdout.Printf(TEXT(
"\n"
"You can also use ShowCommands with Kind=Create to see commands that create new assets.\n"
"\n"));
}
}
};

View File

@@ -0,0 +1,46 @@
#pragma once
#include "CoreMinimal.h"
#include "WingServer.h"
#include "WingHandler.h"
#include "UObject/UObjectHash.h"
#include "SysInfo_PackageContents.generated.h"
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
UCLASS()
class UWing_SysInfo_PackageContents : public UWingHandler
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, meta=(Description="Package path, e.g. /Game/Testing/BP_Test"))
FString Package;
virtual void Register() override
{
UWingServer::AddHandler(this,
TEXT("Print the name and type of every object in a package."));
}
virtual void Handle() override
{
UPackage* Pkg = LoadPackage(nullptr, *Package, LOAD_None);
if (!Pkg)
{
WingOut::Stdout.Printf(TEXT("ERROR: Could not load package '%s'\n"), *Package);
return;
}
TArray<UObject*> Objects;
GetObjectsWithPackage(Pkg, Objects);
for (UObject* Obj : Objects)
{
WingOut::Stdout.Printf(TEXT("%s %s\n"), *Obj->GetClass()->GetName(), *Obj->GetPathName());
}
}
};

View File

@@ -5,7 +5,7 @@
#include "WingServer.h" #include "WingServer.h"
#include "WingFetcher.h" #include "WingFetcher.h"
#include "WingVariables.h" #include "WingVariables.h"
#include "Variables_Create.generated.h" #include "Variables_Add.generated.h"
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -13,7 +13,7 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
UCLASS() UCLASS()
class UWing_Variables_Create : public UWingHandler class UWing_Variables_Add : public UWingHandler
{ {
GENERATED_BODY() GENERATED_BODY()

View File

@@ -11,7 +11,7 @@
#include "Blueprint/UserWidget.h" #include "Blueprint/UserWidget.h"
#include "Kismet2/BlueprintEditorUtils.h" #include "Kismet2/BlueprintEditorUtils.h"
#include "Components/PanelWidget.h" #include "Components/PanelWidget.h"
#include "Widget_Create.generated.h" #include "Widget_Add.generated.h"
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -19,7 +19,7 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
UCLASS() UCLASS()
class UWing_Widget_Create : public UWingHandler class UWing_Widget_Add : public UWingHandler
{ {
GENERATED_BODY() GENERATED_BODY()

View File

@@ -9,7 +9,7 @@
#include "Blueprint/WidgetTree.h" #include "Blueprint/WidgetTree.h"
#include "Components/PanelWidget.h" #include "Components/PanelWidget.h"
#include "Kismet2/BlueprintEditorUtils.h" #include "Kismet2/BlueprintEditorUtils.h"
#include "Widget_Delete.generated.h" #include "Widget_Remove.generated.h"
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -17,7 +17,7 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
UCLASS() UCLASS()
class UWing_Widget_Delete : public UWingHandler class UWing_Widget_Remove : public UWingHandler
{ {
GENERATED_BODY() GENERATED_BODY()

View File

@@ -27,7 +27,7 @@ public:
{ {
UWingServer::AddHandler(this, UWingServer::AddHandler(this,
TEXT("Search for widget types that can be added to a Widget Blueprint. " TEXT("Search for widget types that can be added to a Widget Blueprint. "
"Returns names for use with Widget_Create.")); "Returns names for use with Widget_Add."));
} }
virtual void Handle() override virtual void Handle() override
{ {

View File

@@ -177,7 +177,7 @@ void WingManual::PrintManual(TSet<Section> Sections, const FWingHandlerConfig* H
"\n Float F (InstanceEditable)" "\n Float F (InstanceEditable)"
"\n String S = This is the default value" "\n String S = This is the default value"
"\n" "\n"
"\n The commands Variables_Create, Variables_Modify," "\n The commands Variables_Add, Variables_Modify,"
"\n and Variables_Remove can be used to edit: " "\n and Variables_Remove can be used to edit: "
"\n blueprint variables, graph local variables, graph input" "\n blueprint variables, graph local variables, graph input"
"\n variables, graph output variables, and custom" "\n variables, graph output variables, and custom"
@@ -274,13 +274,14 @@ void WingManual::PrintManual(TSet<Section> Sections, const FWingHandlerConfig* H
{ {
WingOut::Stdout.Print(TEXT( WingOut::Stdout.Print(TEXT(
"\n COMMANDS YOU SHOULD KNOW ABOUT AND REMEMBER:" "\n COMMANDS YOU SHOULD KNOW ABOUT AND REMEMBER:"
"\n UserManual: this explanation" "\n Documentation_Manual: this explanation"
"\n ShowCommands: a full list of all the commands" "\n Documentation_Commands: a list of all the main commands"
"\n Documentation_CreateAssets: Additional commands that create new assets"
"\n Blueprint_Dump: a summary of any blueprint" "\n Blueprint_Dump: a summary of any blueprint"
"\n Graph_Dump: a fairly detailed listing of any Graph" "\n Graph_Dump: a fairly detailed listing of any Graph"
"\n Property_Dump: show information on many objects" "\n Property_Dump: show information on many objects"
"\n" "\n"
"\n You can use ShowCommands(Query=SomeCommand,Verbose=true)" "\n You can use Documentation_Commands(Query=SomeCommand,Verbose=true)"
"\n to get detailed help for a specific command." "\n to get detailed help for a specific command."
"\n" "\n"
)); ));
@@ -288,6 +289,35 @@ void WingManual::PrintManual(TSet<Section> Sections, const FWingHandlerConfig* H
if (Abridged) if (Abridged)
{ {
WingOut::Stdout.Printf(TEXT("\nUse command 'UserManual' to see the full manual.\n")); WingOut::Stdout.Printf(TEXT("\nUse command 'Documentation_Manual' to see the full manual.\n"));
}
}
void WingManual::Commands(EWingHandlerKind Kind, const FString& Query, bool Verbose)
{
FString QueryLower = Query.ToLower();
FString PrevGroup;
for (const FWingHandlerConfig& H : UWingServer::AllHandlers())
{
if (H.Kind != Kind) continue;
if (!H.Name.ToLower().Contains(QueryLower)) continue;
// Blank line between groups
if (!Verbose)
{
FString Group = WingUtils::GetHandlerGroup(H.Class.Get());
if (Group != PrevGroup)
{
if (!PrevGroup.IsEmpty())
WingOut::Stdout.Print(TEXT("\n"));
PrevGroup = Group;
}
}
if (Verbose)
PrintHandlerHelp(H);
else
PrintHandlerPrototype(H);
} }
} }

View File

@@ -307,7 +307,7 @@ void UWingServer::TryCallHandler(const FString &Line)
if (!Request->TryGetStringField(TEXT("command"), Command)) if (!Request->TryGetStringField(TEXT("command"), Command))
{ {
WingOut::Stdout.Printf(TEXT("Request does not contain 'command' parameter")); WingOut::Stdout.Printf(TEXT("Request does not contain 'command' parameter"));
WingOut::Stdout.Printf(TEXT("We recommend sending command='UserManual'.")); WingOut::Stdout.Printf(TEXT("We recommend sending command='Documentation_Manual'."));
return; return;
} }
Request->RemoveField(TEXT("command")); Request->RemoveField(TEXT("command"));

View File

@@ -23,4 +23,5 @@ public:
static void PrintHandlerDescription(const FWingHandlerConfig& Handler); static void PrintHandlerDescription(const FWingHandlerConfig& Handler);
static void PrintHandlerHelp(const FWingHandlerConfig& Handler); static void PrintHandlerHelp(const FWingHandlerConfig& Handler);
static void PrintManual(TSet<Section> Sections, const FWingHandlerConfig* Handler, bool Abridged); static void PrintManual(TSet<Section> Sections, const FWingHandlerConfig* Handler, bool Abridged);
static void Commands(EWingHandlerKind Kind, const FString& Query, bool Verbose);
}; };

View File

@@ -19,7 +19,7 @@ TOOL_DESCRIPTION = (
"Send a command to the Unreal Editor's UE Wingman plugin. " "Send a command to the Unreal Editor's UE Wingman plugin. "
"The 'command' field specifies which operation to perform; " "The 'command' field specifies which operation to perform; "
"additional fields are command-specific parameters. " "additional fields are command-specific parameters. "
'Use {"command": "UserManual"} to get an overview. ' 'Use {"command": "Documentation_Manual"} to get an overview. '
"If the editor is not running, the call will return an error; " "If the editor is not running, the call will return an error; "
"just ask the user to start the editor and try again." "just ask the user to start the editor and try again."
) )