feat(inspect): add inspect_cdo sub-action for Blueprint CDO inspection#329
feat(inspect): add inspect_cdo sub-action for Blueprint CDO inspection#329ChiR24 merged 4 commits intoChiR24:mainfrom
Conversation
Inspect any Blueprint's Class Default Object (CDO) without spawning actors via reflection. For Actor BPs, enumerate CDO components with effective overrides (SCS/SCS_Inherited/Native), including key fields (mesh, animClass, transform). Supports detailed/componentName/propertyNames filters. Updated CHANGELOG.md, editor-plugin-extension.md, handler-mapping.md. Added routing in EnvironmentHandlers.cpp to HandleInspectCdoAction.
- Wrap `inspect_cdo` implementation in `#if WITH_EDITOR` to ensure runtime safety (reflection on CDO/components). - Update CHANGELOG.md and code comments to describe "inferred source" classification via CDO component name matching against SCS variables (assumes standard UE 5.0-5.7 Blueprint compilation). - Simplify `LoadBlueprintAsset` call (direct function). - Add `#include "Animation/AnimInstance.h"`.
…on for agents - Read native components from CDO (effective overrides), SCS components from node templates (BP-added, full parent chain) - Add attachParent from SCS node tree for BP-added components - Fix LoadBlueprintAsset call (free function, not namespaced) - Add Animation/AnimInstance.h for UE 5.7 build compatibility - Add inspect_cdo to tool description so agents discover it - Soften source classification claim to "inferred" Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds an Changes
Sequence DiagramsequenceDiagram
actor Client
participant TS as TS Handler
participant Bridge as C++ Bridge (Subsystem)
participant Engine as Unreal Engine
Client->>TS: inspect_cdo(blueprintPath, options)
TS->>TS: build automation request
TS->>Bridge: executeAutomationRequest(action: "inspect_cdo", blueprintPath, ...)
Bridge->>Bridge: HandleInspectAction (classify global)
Bridge->>Bridge: Dispatch -> HandleInspectCdoAction
Bridge->>Engine: Load Blueprint asset (blueprintPath)
Engine-->>Bridge: Blueprint / GeneratedClass
Bridge->>Engine: Get Class Default Object (CDO)
Engine-->>Bridge: CDO
alt single component requested
Bridge->>Engine: Resolve component by name (native CDO -> SCS)
Engine-->>Bridge: Component template
Bridge->>Bridge: Export filtered properties
else enumerate all components
Bridge->>Engine: Enumerate native CDO components
Engine-->>Bridge: native list
Bridge->>Engine: Traverse Blueprint parents -> collect SCS templates
Engine-->>Bridge: SCS components with attachParent/source
Bridge->>Bridge: Merge/deduplicate -> build components array
Bridge->>Bridge: Optionally export cdoProperties / detailed properties
end
Bridge->>TS: Return JSON result (class, cdoProperties?, components)
TS->>Client: Cleaned inspection result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…load construction - Guard against null Payload before dereferencing in HandleInspectCdoAction - Put action after spread to prevent normalizedArgs.action override - Use normalizedArgs.objectPath (alias-normalized) for blueprintPath fallback Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/tools/handlers/inspect-handlers.ts (1)
686-692:⚠️ Potential issue | 🟠 MajorNormalize and pre-validate
blueprintPathbefore dispatchLine 691 still sends an unnormalized/raw value (and may pass an empty value), and Line 688 omits tool/action error context. This can fail at the C++ boundary with less actionable diagnostics.
Proposed fix
-import { normalizeArgs, resolveObjectPath, extractString, extractOptionalString } from './argument-helper.js'; +import { normalizeArgs, resolveObjectPath, extractString, extractOptionalString } from './argument-helper.js'; +import { normalizePath } from '../../utils/normalize.js'; ... case 'inspect_cdo': { - const inspectArgs = args as InspectArgs; - const res = await executeAutomationRequest(tools, 'inspect', { + const inspectArgs = normalizedArgs as InspectArgs; + const blueprintPathRaw = inspectArgs.blueprintPath ?? inspectArgs.objectPath; + const blueprintPath = typeof blueprintPathRaw === 'string' ? normalizePath(blueprintPathRaw) : ''; + if (!blueprintPath) { + throw new Error('inspect:inspect_cdo - blueprintPath is required'); + } + + const res = await executeAutomationRequest(tools, 'inspect', { ...normalizedArgs, action: 'inspect_cdo', - blueprintPath: inspectArgs.blueprintPath || normalizedArgs.objectPath as string, - }); + blueprintPath, + }, 'inspect:inspect_cdo - automation bridge not available'); return cleanObject(res) as Record<string, unknown>; }As per coding guidelines: "Validate action using
requireAction(args)and normalize paths usingnormalizePath()before sending parameters to the C++ bridge" and "Include tool and action names in all error messages for proper error context".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tools/handlers/inspect-handlers.ts` around lines 686 - 692, In the 'inspect_cdo' case, validate the requested action with requireAction(args) and normalize/pre-validate blueprintPath from InspectArgs before calling executeAutomationRequest: call normalizePath(...) on inspectArgs.blueprintPath (falling back to normalizedArgs.objectPath) and ensure it is non-empty (throw or return an error that includes tools and the action name if invalid); then pass the normalized blueprintPath in the payload to executeAutomationRequest and include tool and action context in any error messages sent to the C++ bridge so failures surface with proper diagnostics.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/tools/handlers/inspect-handlers.ts`:
- Around line 686-692: In the 'inspect_cdo' case, validate the requested action
with requireAction(args) and normalize/pre-validate blueprintPath from
InspectArgs before calling executeAutomationRequest: call normalizePath(...) on
inspectArgs.blueprintPath (falling back to normalizedArgs.objectPath) and ensure
it is non-empty (throw or return an error that includes tools and the action
name if invalid); then pass the normalized blueprintPath in the payload to
executeAutomationRequest and include tool and action context in any error
messages sent to the C++ bridge so failures surface with proper diagnostics.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 951c9963-0cb0-4334-80da-1ec41a9762fc
📒 Files selected for processing (2)
plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PropertyHandlers.cppsrc/tools/handlers/inspect-handlers.ts
✅ Files skipped from review due to trivial changes (1)
- plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PropertyHandlers.cpp
Summary
Add
inspect_cdoaction to theinspecttool. Inspect any Blueprint'sClass Default Object without spawning an actor. Reads CDO property values
via reflection; for Actor BPs enumerates all components (native from CDO
with effective overrides, BP-added from SCS templates with full parent chain).
Changes
inspect_cdoto inspect action enum withblueprintPath,detailed,propertyNamesinputsHandleInspectCdoActionin PropertyHandlers.cpp with thin dispatcher in EnvironmentHandlers.cppBuildComponentSummary,BuildScsSourceMap,FindCdoComponenthelpersRelated Issues
None
Type of Change
Testing
Pre-Merge Checklist