@alpsckr/unitycli 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/contracts/command-contract.json +109 -217
- package/contracts/package-files.json +374 -294
- package/contracts/stable-session/direct-call-semantics.json +8 -2
- package/contracts/tool-completion-contract.json +148 -672
- package/dist/bridge/admission.d.ts +17 -1
- package/dist/bridge/admission.js +2 -0
- package/dist/bridge/admission.js.map +1 -1
- package/dist/bridge/domains/asset.js +3 -1
- package/dist/bridge/domains/asset.js.map +1 -1
- package/dist/bridge/domains/camera.js +39 -7
- package/dist/bridge/domains/camera.js.map +1 -1
- package/dist/bridge/domains/console.js +2 -1
- package/dist/bridge/domains/console.js.map +1 -1
- package/dist/bridge/domains/doctor.d.ts +3 -0
- package/dist/bridge/domains/doctor.js +8 -0
- package/dist/bridge/domains/doctor.js.map +1 -0
- package/dist/bridge/domains/editor.js +0 -4
- package/dist/bridge/domains/editor.js.map +1 -1
- package/dist/bridge/domains/game-object.js +4 -12
- package/dist/bridge/domains/game-object.js.map +1 -1
- package/dist/bridge/domains/graphics.js +1 -16
- package/dist/bridge/domains/graphics.js.map +1 -1
- package/dist/bridge/domains/object.js +3 -0
- package/dist/bridge/domains/object.js.map +1 -1
- package/dist/bridge/domains/physics.js +1 -2
- package/dist/bridge/domains/physics.js.map +1 -1
- package/dist/bridge/domains/profiler.js +18 -7
- package/dist/bridge/domains/profiler.js.map +1 -1
- package/dist/bridge/domains/project-tool.js +4 -0
- package/dist/bridge/domains/project-tool.js.map +1 -1
- package/dist/bridge/domains/reflection.js +10 -2
- package/dist/bridge/domains/reflection.js.map +1 -1
- package/dist/bridge/domains/runtime-tool.js +3 -0
- package/dist/bridge/domains/runtime-tool.js.map +1 -1
- package/dist/bridge/domains/scene.js +3 -8
- package/dist/bridge/domains/scene.js.map +1 -1
- package/dist/bridge/domains/screenshot.js +30 -6
- package/dist/bridge/domains/screenshot.js.map +1 -1
- package/dist/bridge/domains/ui.js +3 -1
- package/dist/bridge/domains/ui.js.map +1 -1
- package/dist/bridge/index.d.ts +5 -5
- package/dist/bridge/index.js +6 -9
- package/dist/bridge/index.js.map +1 -1
- package/dist/bridge/registry.js +3 -5
- package/dist/bridge/registry.js.map +1 -1
- package/dist/bridge/session-supervisor.d.ts +6 -3
- package/dist/bridge/session-supervisor.js +122 -34
- package/dist/bridge/session-supervisor.js.map +1 -1
- package/dist/bridge/types.d.ts +6 -5
- package/dist/bridge/types.js +16 -2
- package/dist/bridge/types.js.map +1 -1
- package/dist/catalog-protocol.d.ts +64 -0
- package/dist/catalog-protocol.js +460 -0
- package/dist/catalog-protocol.js.map +1 -0
- package/dist/cli-commands/command.js +84 -61
- package/dist/cli-commands/command.js.map +1 -1
- package/dist/cli-commands/extensions.js +70 -50
- package/dist/cli-commands/extensions.js.map +1 -1
- package/dist/cli-commands/instances.js +1 -1
- package/dist/cli-commands/instances.js.map +1 -1
- package/dist/cli-process-owners.d.ts +6 -0
- package/dist/cli-process-owners.js +27 -0
- package/dist/cli-process-owners.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +20 -5
- package/dist/cli.js.map +1 -1
- package/dist/contracts/command-contract.js +14 -4
- package/dist/contracts/command-contract.js.map +1 -1
- package/dist/doctor.d.ts +4 -6
- package/dist/doctor.js +429 -398
- package/dist/doctor.js.map +1 -1
- package/dist/editor-blocker-observer.d.ts +2 -1
- package/dist/editor-blocker-observer.js +40 -13
- package/dist/editor-blocker-observer.js.map +1 -1
- package/dist/extension-availability.d.ts +27 -9
- package/dist/extension-availability.js +96 -56
- package/dist/extension-availability.js.map +1 -1
- package/dist/extensions/descriptor-loader.d.ts +2 -2
- package/dist/extensions/descriptor-loader.js +3 -4
- package/dist/extensions/descriptor-loader.js.map +1 -1
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/installer.d.ts +24 -7
- package/dist/extensions/installer.js +142 -66
- package/dist/extensions/installer.js.map +1 -1
- package/dist/extensions/registry.js +3 -5
- package/dist/extensions/registry.js.map +1 -1
- package/dist/extensions/state-contract.d.ts +11 -0
- package/dist/extensions/state-contract.js +50 -0
- package/dist/extensions/state-contract.js.map +1 -0
- package/dist/instances.d.ts +13 -1
- package/dist/instances.js +26 -0
- package/dist/instances.js.map +1 -1
- package/dist/package-manager.d.ts +0 -24
- package/dist/package-manager.js +5 -58
- package/dist/package-manager.js.map +1 -1
- package/dist/project-tool-discovery.d.ts +5 -2
- package/dist/project-tool-discovery.js +22 -18
- package/dist/project-tool-discovery.js.map +1 -1
- package/dist/runtime-code.js +1 -1
- package/dist/runtime-code.js.map +1 -1
- package/dist/tool-name.d.ts +4 -0
- package/dist/tool-name.js +15 -0
- package/dist/tool-name.js.map +1 -0
- package/dist/tools/.generated-completion-registry.d.ts +2 -0
- package/dist/tools/.generated-completion-registry.js +763 -325
- package/dist/tools/.generated-completion-registry.js.map +1 -1
- package/dist/tools/.generated-registry.d.ts +6 -11
- package/dist/tools/.generated-registry.js +6 -11
- package/dist/tools/.generated-registry.js.map +1 -1
- package/dist/tools/.generated-schemas.js +11 -16
- package/dist/tools/.generated-schemas.js.map +1 -1
- package/dist/tools/asset/refresh-status.d.ts +3 -0
- package/dist/tools/asset/refresh-status.js +12 -0
- package/dist/tools/asset/refresh-status.js.map +1 -0
- package/dist/tools/asset/refresh.js +7 -3
- package/dist/tools/asset/refresh.js.map +1 -1
- package/dist/tools/build/player-status.d.ts +3 -0
- package/dist/tools/build/player-status.js +12 -0
- package/dist/tools/build/player-status.js.map +1 -0
- package/dist/tools/build/run.js +1 -1
- package/dist/tools/build/run.js.map +1 -1
- package/dist/tools/catalog-control.d.ts +22 -0
- package/dist/tools/catalog-control.js +335 -0
- package/dist/tools/catalog-control.js.map +1 -0
- package/dist/tools/catalog.d.ts +7 -9
- package/dist/tools/catalog.js +66 -45
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tools/commands.d.ts +1 -1
- package/dist/tools/commands.js +44 -11
- package/dist/tools/commands.js.map +1 -1
- package/dist/tools/define.js +3 -2
- package/dist/tools/define.js.map +1 -1
- package/dist/tools/dispatcher.d.ts +53 -6
- package/dist/tools/dispatcher.js +277 -108
- package/dist/tools/dispatcher.js.map +1 -1
- package/dist/tools/editor/compile.js +1 -1
- package/dist/tools/editor/compile.js.map +1 -1
- package/dist/tools/editor/play-mode-status.d.ts +3 -0
- package/dist/tools/editor/play-mode-status.js +12 -0
- package/dist/tools/editor/play-mode-status.js.map +1 -0
- package/dist/tools/editor/readiness.d.ts +0 -1
- package/dist/tools/editor/readiness.js +0 -1
- package/dist/tools/editor/readiness.js.map +1 -1
- package/dist/tools/editor/refresh.d.ts +7 -3
- package/dist/tools/editor/refresh.js +20 -15
- package/dist/tools/editor/refresh.js.map +1 -1
- package/dist/tools/editor/state.d.ts +2 -2
- package/dist/tools/editor/state.js +13 -12
- package/dist/tools/editor/state.js.map +1 -1
- package/dist/tools/metadata/derived.js +1 -7
- package/dist/tools/metadata/derived.js.map +1 -1
- package/dist/tools/metadata/status.js +1 -12
- package/dist/tools/metadata/status.js.map +1 -1
- package/dist/tools/metadata/types.d.ts +0 -2
- package/dist/tools/navmesh/live.js +1 -1
- package/dist/tools/navmesh/live.js.map +1 -1
- package/dist/tools/occlusion/live.js +1 -1
- package/dist/tools/occlusion/live.js.map +1 -1
- package/dist/tools/package/deploy.js +2 -2
- package/dist/tools/package/deploy.js.map +1 -1
- package/dist/tools/package/embed.js +1 -1
- package/dist/tools/package/embed.js.map +1 -1
- package/dist/tools/package/install-status.d.ts +3 -0
- package/dist/tools/package/install-status.js +12 -0
- package/dist/tools/package/install-status.js.map +1 -0
- package/dist/tools/package/install.js +3 -3
- package/dist/tools/package/install.js.map +1 -1
- package/dist/tools/package/live-resolve.js +45 -12
- package/dist/tools/package/live-resolve.js.map +1 -1
- package/dist/tools/package/registry-clear.js.map +1 -1
- package/dist/tools/package/registry-set.js.map +1 -1
- package/dist/tools/package/remove-status.d.ts +3 -0
- package/dist/tools/package/remove-status.js +12 -0
- package/dist/tools/package/remove-status.js.map +1 -0
- package/dist/tools/package/remove.js +3 -3
- package/dist/tools/package/remove.js.map +1 -1
- package/dist/tools/package/resolve.js +3 -3
- package/dist/tools/package/resolve.js.map +1 -1
- package/dist/tools/package/restore.js +2 -2
- package/dist/tools/package/restore.js.map +1 -1
- package/dist/tools/package/scoped-registry-add.js.map +1 -1
- package/dist/tools/status/support.d.ts +13 -0
- package/dist/tools/status/support.js +28 -0
- package/dist/tools/status/support.js.map +1 -0
- package/dist/tools/test/cancel.js +2 -2
- package/dist/tools/test/cancel.js.map +1 -1
- package/dist/tools/test/run-status.d.ts +3 -0
- package/dist/tools/test/run-status.js +12 -0
- package/dist/tools/test/run-status.js.map +1 -0
- package/dist/tools/test/run.js +7 -4
- package/dist/tools/test/run.js.map +1 -1
- package/dist/tools/tools/group-summaries.js +10 -14
- package/dist/tools/tools/group-summaries.js.map +1 -1
- package/docs/architecture.md +4 -4
- package/docs/availability-differences.md +4 -4
- package/docs/command-execution.md +4 -3
- package/docs/error-codes.md +13 -5
- package/docs/extensions.md +1 -7
- package/docs/risk-and-side-effects.md +4 -3
- package/docs/safety-boundaries.md +3 -1
- package/docs/target-and-instance.md +1 -1
- package/docs/tool-discovery.md +17 -10
- package/docs/tool-execution.md +18 -7
- package/extensions/cinemachine/unitypkg/Editor/UnityCliExtensionAssembly.cs +3 -0
- package/extensions/hdrp/unitypkg/Editor/UnityCliExtensionAssembly.cs +3 -0
- package/extensions/probuilder/unitypkg/Editor/UnityCliExtensionAssembly.cs +3 -0
- package/extensions/urp/unitypkg/Editor/UnityCliExtensionAssembly.cs +3 -0
- package/extensions/vfx-graph/unitypkg/Editor/UnityCliExtensionAssembly.cs +3 -0
- package/package.json +2 -4
- package/skills/unitycli/SKILL.md +35 -42
- package/skills/unitycli/manifest.json +1 -1
- package/skills/unitycli/references/operation-protocol.md +3 -3
- package/unitypkg/Editor/AssemblyInfo.cs +5 -0
- package/unitypkg/Editor/Bridge/BridgeCommandRegistry.cs +49 -14
- package/unitypkg/Editor/Bridge/BridgeHttpServer.cs +9 -35
- package/unitypkg/Editor/Bridge/BridgeQueueState.cs +672 -0
- package/unitypkg/Editor/Bridge/BridgeWorkQueue.cs +970 -120
- package/unitypkg/Editor/BridgeStartupStateMachine.cs +59 -1
- package/unitypkg/Editor/Commands/ProjectToolCommands.cs +4 -0
- package/unitypkg/Editor/Commands/RuntimeToolCommands.cs +3 -0
- package/unitypkg/Editor/Generated/UnityCliToolCompletionRegistry.g.cs +379 -14
- package/unitypkg/Editor/Infrastructure/CodeExecSupport.cs +28 -13
- package/unitypkg/Editor/Infrastructure/RegistryOwnershipResolver.cs +132 -105
- package/unitypkg/Editor/Infrastructure/UnityCliActiveOperation.cs +138 -29
- package/unitypkg/Editor/Infrastructure/UnityCliAdmission.cs +1856 -237
- package/unitypkg/Editor/Infrastructure/UnityCliDoctorDiagnostics.cs +220 -0
- package/unitypkg/Editor/Infrastructure/UnityCliDurableStatusCoordinator.cs +118 -0
- package/unitypkg/Editor/Infrastructure/UnityCliEditorStateSnapshot.cs +2 -1
- package/unitypkg/Editor/Infrastructure/UnityCliHierarchyPager.cs +203 -0
- package/unitypkg/Editor/Infrastructure/UnityCliInstanceCleanup.cs +2 -1
- package/unitypkg/Editor/Infrastructure/UnityCliInstanceRegistry.cs +201 -63
- package/unitypkg/Editor/Infrastructure/UnityCliJson.cs +2 -3
- package/unitypkg/Editor/Infrastructure/UnityCliLiveBuildCoordinator.cs +289 -46
- package/unitypkg/Editor/Infrastructure/UnityCliLiveRefreshCoordinator.cs +87 -53
- package/unitypkg/Editor/Infrastructure/UnityCliNavMeshBakeCoordinator.cs +4 -4
- package/unitypkg/Editor/Infrastructure/UnityCliObjectRef.cs +128 -25
- package/unitypkg/Editor/Infrastructure/UnityCliObjectSerializer.cs +435 -327
- package/unitypkg/Editor/Infrastructure/UnityCliOcclusionBakeCoordinator.cs +4 -4
- package/unitypkg/Editor/Infrastructure/UnityCliOperationCoordinator.cs +351 -53
- package/unitypkg/Editor/Infrastructure/UnityCliPackageResolveCoordinator.cs +118 -18
- package/unitypkg/Editor/Infrastructure/UnityCliPackageResolveState.cs +20 -1
- package/unitypkg/Editor/Infrastructure/UnityCliReadGeneration.cs +97 -0
- package/unitypkg/Editor/Infrastructure/UnityCliReflection.cs +644 -133
- package/unitypkg/Editor/Infrastructure/UnityCliReloadOperation.cs +128 -41
- package/unitypkg/Editor/Infrastructure/UnityCliRuntimeExecutor.cs +14 -84
- package/unitypkg/Editor/Infrastructure/UnityCliSerializer.cs +220 -0
- package/unitypkg/Editor/Infrastructure/UnityCliSessionMutationLease.cs +69 -29
- package/unitypkg/Editor/Infrastructure/UnityCliTestRunCoordinator.cs +440 -54
- package/unitypkg/Editor/Infrastructure/UnityCliWaiter.cs +128 -35
- package/unitypkg/Editor/ProjectTools/IUnityCliTool.cs +9 -1
- package/unitypkg/Editor/ProjectTools/OfficialAttributeToolRegistry.cs +32 -31
- package/unitypkg/Editor/ProjectTools/ProjectToolRegistry.cs +607 -458
- package/unitypkg/Editor/ProjectTools/ProjectToolSchemaValidator.cs +35 -7
- package/unitypkg/Editor/ProjectTools/RegisteredTool.cs +501 -60
- package/unitypkg/Editor/ProjectTools/UnityCliProjectToolContext.cs +21 -0
- package/unitypkg/Editor/ProjectTools/UnityCliSchemaDeriver.cs +36 -7
- package/unitypkg/Editor/ProjectTools/UnityCliToolName.cs +30 -0
- package/unitypkg/Editor/Properties/AssemblyInfo.cs +3 -0
- package/unitypkg/Editor/Tools/asset/get-data.cs +16 -7
- package/unitypkg/Editor/Tools/build/BuildSceneStateTool.cs +23 -3
- package/unitypkg/Editor/Tools/build/BuildToolDtos.cs +2 -1
- package/unitypkg/Editor/Tools/build/scene/add.cs +6 -3
- package/unitypkg/Editor/Tools/build/scene/disable.cs +1 -1
- package/unitypkg/Editor/Tools/build/scene/enable.cs +1 -1
- package/unitypkg/Editor/Tools/build/scene/list.cs +1 -1
- package/unitypkg/Editor/Tools/build/scene/remove.cs +13 -3
- package/unitypkg/Editor/Tools/camera/CameraToolSupport.cs +38 -38
- package/unitypkg/Editor/Tools/camera/multiview.cs +13 -6
- package/unitypkg/Editor/Tools/camera/screenshot.cs +14 -7
- package/unitypkg/Editor/Tools/component/get.cs +16 -9
- package/unitypkg/Editor/Tools/component/modify.cs +6 -4
- package/unitypkg/Editor/Tools/console/clear.cs +7 -6
- package/unitypkg/Editor/Tools/console/get.cs +48 -16
- package/unitypkg/Editor/Tools/editor/EditorToolSupport.cs +143 -28
- package/unitypkg/Editor/Tools/editor/menu-items.cs +1 -1
- package/unitypkg/Editor/Tools/editor/play.cs +2 -11
- package/unitypkg/Editor/Tools/editor/selection.cs +1 -1
- package/unitypkg/Editor/Tools/editor/stop.cs +2 -11
- package/unitypkg/Editor/Tools/editor/windows.cs +1 -1
- package/unitypkg/Editor/Tools/go/GameObjectToolSupport.cs +54 -4
- package/unitypkg/Editor/Tools/go/delete.cs +1 -1
- package/unitypkg/Editor/Tools/go/find.cs +167 -70
- package/unitypkg/Editor/Tools/graphics/GraphicsToolSupport.cs +25 -0
- package/unitypkg/Editor/Tools/graphics/light-probe-group.cs +9 -3
- package/unitypkg/Editor/Tools/graphics/pipeline-info.cs +1 -1
- package/unitypkg/Editor/Tools/graphics/pipeline-settings.cs +1 -1
- package/unitypkg/Editor/Tools/graphics/quality.cs +2 -2
- package/unitypkg/Editor/Tools/graphics/reflection-probe.cs +3 -3
- package/unitypkg/Editor/Tools/graphics/stats.cs +1 -1
- package/unitypkg/Editor/Tools/object/ObjectToolSupport.cs +4 -4
- package/unitypkg/Editor/Tools/object/get-data.cs +9 -7
- package/unitypkg/Editor/Tools/object/modify.cs +7 -5
- package/unitypkg/Editor/Tools/physics/raycast.cs +24 -6
- package/unitypkg/Editor/Tools/prefab/stage.cs +1 -1
- package/unitypkg/Editor/Tools/profiler/ProfilerFrameDebuggerSupport.cs +94 -21
- package/unitypkg/Editor/Tools/profiler/ProfilerMemorySnapshotSupport.cs +397 -10
- package/unitypkg/Editor/Tools/profiler/ProfilerToolSupport.cs +18 -4
- package/unitypkg/Editor/Tools/profiler/frame-debugger/enable.cs +1 -1
- package/unitypkg/Editor/Tools/profiler/frame-debugger/events.cs +88 -87
- package/unitypkg/Editor/Tools/profiler/hierarchy.cs +278 -112
- package/unitypkg/Editor/Tools/profiler/memory-snapshot/compare.cs +9 -5
- package/unitypkg/Editor/Tools/profiler/memory-snapshot/list.cs +37 -35
- package/unitypkg/Editor/Tools/profiler/memory-snapshot/take.cs +99 -97
- package/unitypkg/Editor/Tools/project/info.cs +1 -1
- package/unitypkg/Editor/Tools/project/layers.cs +1 -1
- package/unitypkg/Editor/Tools/project/tags.cs +1 -1
- package/unitypkg/Editor/Tools/reflection/method/call.cs +9 -7
- package/unitypkg/Editor/Tools/reflection/method/find.cs +27 -37
- package/unitypkg/Editor/Tools/reflection/type/schema.cs +24 -28
- package/unitypkg/Editor/Tools/scene/gameobject/component.cs +8 -5
- package/unitypkg/Editor/Tools/scene/gameobject/components.cs +10 -7
- package/unitypkg/Editor/Tools/scene/gameobject-support.cs +104 -8
- package/unitypkg/Editor/Tools/scene/gameobject.cs +37 -16
- package/unitypkg/Editor/Tools/scene/hierarchy.cs +146 -142
- package/unitypkg/Editor/Tools/screenshot/EditorElementCaptureToolSupport.cs +77 -25
- package/unitypkg/Editor/Tools/screenshot/ScreenshotToolSupport.cs +315 -95
- package/unitypkg/Editor/Tools/screenshot/editor-element.cs +7 -5
- package/unitypkg/Editor/Tools/screenshot/game-view.cs +35 -21
- package/unitypkg/Editor/Tools/screenshot/isolated-object.cs +29 -23
- package/unitypkg/Editor/Tools/screenshot/orbit.cs +37 -25
- package/unitypkg/Editor/Tools/screenshot/scene-view.cs +25 -18
- package/unitypkg/Editor/Tools/screenshot/screen.cs +177 -17
- package/unitypkg/Editor/Tools/screenshot/surround.cs +83 -79
- package/unitypkg/Editor/Tools/ui/render-preview.cs +16 -11
- package/unitypkg/Editor/UnityCliBridge.cs +97 -34
- package/unitypkg/Runtime/Infrastructure/UnityCliRuntimeBridge.cs +753 -122
- package/unitypkg/Runtime/Properties/AssemblyInfo.cs +5 -0
- package/unitypkg/Runtime/UnityCli.Runtime.asmdef +1 -1
- package/unitypkg/Shared/AssemblyInfo.cs +4 -0
- package/unitypkg/Shared/UnityCliAdmissionPool.cs +265 -75
- package/unitypkg/Shared/UnityCliBridgeQueuePolicy.cs +410 -0
- package/unitypkg/Shared/UnityCliBridgeWorkItemState.cs +47 -0
- package/unitypkg/Shared/UnityCliExceptionProjection.cs +151 -0
- package/unitypkg/Shared/UnityCliQueuePublication.cs +30 -0
- package/unitypkg/Shared/UnityCliRequestBudget.cs +352 -0
- package/unitypkg/Shared/UnityCliRuntimeRequestPublication.cs +107 -0
- package/unitypkg/Tests/Editor/UnityCli.Editor.Tests.asmdef +2 -2
- package/unitypkg/Tests/Editor/UnityCliAdmissionCoordinatorIntegrationTests.cs +1329 -0
- package/unitypkg/Tests/Editor/UnityCliAdmissionPoolTests.cs +311 -114
- package/unitypkg/Tests/Editor/UnityCliAdmissionRepairStateTests.cs +94 -0
- package/unitypkg/Tests/Editor/UnityCliBridgeAdmissionIntegrationTests.cs +1229 -0
- package/unitypkg/Tests/Editor/UnityCliBridgeQueuePolicyTests.cs +412 -0
- package/unitypkg/Tests/Editor/UnityCliContinuationIntegrationTests.cs +292 -0
- package/unitypkg/Tests/Editor/UnityCliDiagnosticBoundaryTests.cs +120 -0
- package/unitypkg/Tests/Editor/UnityCliDurableStatusTests.cs +84 -0
- package/unitypkg/Tests/Editor/UnityCliExceptionProjectionTests.cs +72 -0
- package/unitypkg/Tests/Editor/UnityCliInstancePublicationRetryTests.cs +180 -97
- package/unitypkg/Tests/Editor/UnityCliMemoryReflectionIntegrationTests.cs +434 -0
- package/unitypkg/Tests/Editor/UnityCliRequestBudgetTests.cs +615 -0
- package/unitypkg/Tests/Editor/UnityCliRuntimeBridgeIntegrationTests.cs +520 -0
- package/unitypkg/Tests/Editor/UnityCliToolCatalogTests.cs +562 -0
- package/unitypkg/Tests/Runtime/UnityCli.Runtime.Tests.asmdef +23 -0
- package/unitypkg/Tests/Runtime/UnityCliRuntimeCatalogValidationTests.cs +29 -0
- package/unitypkg/package.json +1 -1
- package/contracts/static-capability-catalog.json +0 -48226
- package/dist/bridge/domains/diagnose.d.ts +0 -2
- package/dist/bridge/domains/diagnose.js +0 -11
- package/dist/bridge/domains/diagnose.js.map +0 -1
- package/dist/bridge/domains/extension.d.ts +0 -8
- package/dist/bridge/domains/extension.js +0 -20
- package/dist/bridge/domains/extension.js.map +0 -1
- package/dist/capabilities.d.ts +0 -5
- package/dist/capabilities.js +0 -84
- package/dist/capabilities.js.map +0 -1
- package/dist/static-capability-catalog.d.ts +0 -13
- package/dist/static-capability-catalog.js +0 -41
- package/dist/static-capability-catalog.js.map +0 -1
- package/dist/tools/diagnose/capabilities.d.ts +0 -13
- package/dist/tools/diagnose/capabilities.js +0 -34
- package/dist/tools/diagnose/capabilities.js.map +0 -1
- package/dist/tools/package/info.d.ts +0 -19
- package/dist/tools/package/info.js +0 -27
- package/dist/tools/package/info.js.map +0 -1
- package/dist/tools/package/list.d.ts +0 -27
- package/dist/tools/package/list.js +0 -21
- package/dist/tools/package/list.js.map +0 -1
- package/dist/tools/package/registry-get.d.ts +0 -10
- package/dist/tools/package/registry-get.js +0 -22
- package/dist/tools/package/registry-get.js.map +0 -1
- package/dist/tools/package/scoped-registry-list.d.ts +0 -14
- package/dist/tools/package/scoped-registry-list.js +0 -22
- package/dist/tools/package/scoped-registry-list.js.map +0 -1
- package/dist/tools/package/search.d.ts +0 -17
- package/dist/tools/package/search.js +0 -39
- package/dist/tools/package/search.js.map +0 -1
- package/dist/tools/package/status.d.ts +0 -21
- package/dist/tools/package/status.js +0 -37
- package/dist/tools/package/status.js.map +0 -1
- package/dist/tools/tools/describe.d.ts +0 -27
- package/dist/tools/tools/describe.js +0 -35
- package/dist/tools/tools/describe.js.map +0 -1
- package/dist/tools/tools/group-list.d.ts +0 -16
- package/dist/tools/tools/group-list.js +0 -38
- package/dist/tools/tools/group-list.js.map +0 -1
- package/dist/tools/tools/group.d.ts +0 -13
- package/dist/tools/tools/group.js +0 -34
- package/dist/tools/tools/group.js.map +0 -1
- package/dist/tools/tools/pagination.d.ts +0 -17
- package/dist/tools/tools/pagination.js +0 -28
- package/dist/tools/tools/pagination.js.map +0 -1
- package/dist/tools/tools/search.d.ts +0 -15
- package/dist/tools/tools/search.js +0 -42
- package/dist/tools/tools/search.js.map +0 -1
- package/unitypkg/Editor/Tools/diagnose/preflight.cs +0 -269
- package/unitypkg/Editor/Tools/editor/console.cs +0 -26
- package/unitypkg/Editor/Tools/extension/status.cs +0 -87
- package/unitypkg/Editor/Tools/go/inspect.cs +0 -49
- package/unitypkg/Editor/Tools/graphics/pipeline-quality.cs +0 -24
- package/unitypkg/Editor/Tools/graphics/probe-positions.cs +0 -58
- package/unitypkg/Editor/Tools/graphics/settings.cs +0 -104
- package/unitypkg/Editor/Tools/graphics/stats-counters.cs +0 -28
- package/unitypkg/Editor/Tools/graphics/stats-memory.cs +0 -21
- package/unitypkg/Editor/Tools/instances/list.cs +0 -71
- package/unitypkg/Editor/Tools/physics/raycast-all.cs +0 -67
- package/unitypkg/Editor/Tools/scene/build-settings.cs +0 -69
- package/unitypkg/Editor/Tools/scene/data.cs +0 -125
- package/unitypkg/Editor/Tools/tests/list.cs +0 -98
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
#if UNITY_EDITOR
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using System.Globalization;
|
|
5
|
+
using System.Reflection;
|
|
6
|
+
using System.Text;
|
|
7
|
+
using System.Threading;
|
|
8
|
+
using System.Threading.Tasks;
|
|
9
|
+
using UnityEditor;
|
|
10
|
+
using UnityEngine;
|
|
11
|
+
using UnityEngine.SceneManagement;
|
|
12
|
+
|
|
13
|
+
namespace UnityCli
|
|
14
|
+
{
|
|
15
|
+
public static partial class UnityCliBridge
|
|
16
|
+
{
|
|
17
|
+
private const string DoctorBusinessCommand = "internal.doctor.business";
|
|
18
|
+
private const string DoctorCatalogCommand = "internal.doctor.catalog";
|
|
19
|
+
private const string DoctorCompileCommand = "internal.doctor.compile";
|
|
20
|
+
private const string DoctorCatalogIdentity = "unity-cli-immutable-domain-catalog";
|
|
21
|
+
|
|
22
|
+
private static void RegisterDoctorDiagnosticCommands(BridgeCommandRegistry registry)
|
|
23
|
+
{
|
|
24
|
+
registry.Register<UnityCli.Protocol.BridgeRequest>("internal.doctor.business", "internal", false, 30000,
|
|
25
|
+
(request, cancellationToken) => new ValueTask<object>(DoctorBusinessDiagnostic(cancellationToken)));
|
|
26
|
+
registry.Register<UnityCli.Protocol.BridgeRequest>("internal.doctor.catalog", "internal", false, 30000,
|
|
27
|
+
(request, cancellationToken) => new ValueTask<object>(DoctorCatalogDiagnostic(cancellationToken)));
|
|
28
|
+
registry.Register<UnityCli.Protocol.BridgeRequest>("internal.doctor.compile", "internal", false, 30000,
|
|
29
|
+
(request, cancellationToken) => new ValueTask<object>(DoctorCompileDiagnostic(cancellationToken)));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/// <summary>业务诊断必须通过正常 admission 和主线程队列,不能替代 transport 或 pulse 结论。</summary>
|
|
33
|
+
private static object DoctorBusinessDiagnostic(CancellationToken cancellationToken)
|
|
34
|
+
{
|
|
35
|
+
cancellationToken.ThrowIfCancellationRequested();
|
|
36
|
+
var scene = SceneManager.GetActiveScene();
|
|
37
|
+
return new Dictionary<string, object>
|
|
38
|
+
{
|
|
39
|
+
{ "projectPath", ProjectRoot() },
|
|
40
|
+
{ "sceneLoaded", scene.IsValid() && scene.isLoaded },
|
|
41
|
+
{ "activeScenePath", scene.path ?? string.Empty },
|
|
42
|
+
{ "playMode", EditorApplication.isPlaying },
|
|
43
|
+
{ "accepted", true }
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// <summary>只投影唯一 published snapshot 的 aggregate;读取失败保持 E_TOOL_REGISTRY_UNHEALTHY。</summary>
|
|
48
|
+
private static object DoctorCatalogDiagnostic(CancellationToken cancellationToken)
|
|
49
|
+
{
|
|
50
|
+
cancellationToken.ThrowIfCancellationRequested();
|
|
51
|
+
var catalog = ProjectToolCatalogSnapshotReader.Read();
|
|
52
|
+
return new Dictionary<string, object>
|
|
53
|
+
{
|
|
54
|
+
{ "identity", DoctorCatalogIdentity },
|
|
55
|
+
{ "toolCount", (long)catalog.ToolCount },
|
|
56
|
+
{ "providerCounts", new Dictionary<string, object>
|
|
57
|
+
{
|
|
58
|
+
{ "builtIn", (long)catalog.BuiltInToolCount },
|
|
59
|
+
{ "extension", (long)catalog.ExtensionToolCount },
|
|
60
|
+
{ "projectInterface", (long)catalog.ProjectInterfaceToolCount },
|
|
61
|
+
{ "officialAttribute", (long)catalog.OfficialAttributeToolCount }
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{ "publicationDiagnostics", new Dictionary<string, object>
|
|
65
|
+
{
|
|
66
|
+
{ "assemblyCount", (long)catalog.AssemblyCount },
|
|
67
|
+
{ "providerAssemblyCount", (long)catalog.ProviderAssemblyCount },
|
|
68
|
+
{ "elapsedMilliseconds", catalog.ElapsedMilliseconds },
|
|
69
|
+
{ "discoveryPassCount", (long)catalog.DiscoveryPassCount },
|
|
70
|
+
{ "providerMetadataReadCount", (long)catalog.ProviderMetadataReadCount },
|
|
71
|
+
{ "aggregateSuccessLogCount", (long)catalog.AggregateSuccessLogCount }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/// <summary>编译诊断独立于 catalog 和业务 admission,并保持条目、时间与字节上限。</summary>
|
|
78
|
+
private static object DoctorCompileDiagnostic(CancellationToken cancellationToken)
|
|
79
|
+
{
|
|
80
|
+
const int maxScannedEntries = 5000;
|
|
81
|
+
const int maxScanMilliseconds = 50;
|
|
82
|
+
const int maxCompileErrorBytes = 64 * 1024;
|
|
83
|
+
const int maxCompileErrorLineBytes = 4096;
|
|
84
|
+
var scanTimer = System.Diagnostics.Stopwatch.StartNew();
|
|
85
|
+
var compiling = EditorApplication.isCompiling;
|
|
86
|
+
var scanComplete = true;
|
|
87
|
+
var compileErrorCount = 0L;
|
|
88
|
+
var compileErrorsTruncated = false;
|
|
89
|
+
var compileErrorBytes = 0;
|
|
90
|
+
var errors = new List<string>();
|
|
91
|
+
|
|
92
|
+
try
|
|
93
|
+
{
|
|
94
|
+
var logEntriesType = FindType("UnityEditor.LogEntries") ?? FindType("UnityEditorInternal.LogEntries");
|
|
95
|
+
if (logEntriesType == null) scanComplete = false;
|
|
96
|
+
else
|
|
97
|
+
{
|
|
98
|
+
var flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
|
|
99
|
+
var start = logEntriesType.GetMethod("StartGettingEntries", flags);
|
|
100
|
+
var end = logEntriesType.GetMethod("EndGettingEntries", flags);
|
|
101
|
+
var count = logEntriesType.GetMethod("GetCount", flags);
|
|
102
|
+
var getEntry = logEntriesType.GetMethod("GetEntryInternal", flags);
|
|
103
|
+
var getLines = logEntriesType.GetMethod("GetLinesAndModeFromEntryInternal", flags)
|
|
104
|
+
?? logEntriesType.GetMethod("GetLinesAndModeInternal", flags);
|
|
105
|
+
if ((start == null && count == null) || (getEntry == null && getLines == null)) scanComplete = false;
|
|
106
|
+
var total = start != null
|
|
107
|
+
? Convert.ToInt32(start.Invoke(null, Type.EmptyTypes), CultureInfo.InvariantCulture)
|
|
108
|
+
: count == null ? 0 : Convert.ToInt32(count.Invoke(null, Type.EmptyTypes), CultureInfo.InvariantCulture);
|
|
109
|
+
try
|
|
110
|
+
{
|
|
111
|
+
var scannedEntries = 0;
|
|
112
|
+
for (var index = total - 1; index >= 0; index--)
|
|
113
|
+
{
|
|
114
|
+
cancellationToken.ThrowIfCancellationRequested();
|
|
115
|
+
if (scannedEntries >= maxScannedEntries || scanTimer.ElapsedMilliseconds >= maxScanMilliseconds)
|
|
116
|
+
{
|
|
117
|
+
scanComplete = false;
|
|
118
|
+
compileErrorsTruncated = true;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
scannedEntries++;
|
|
122
|
+
string line = null;
|
|
123
|
+
var mode = 0;
|
|
124
|
+
try
|
|
125
|
+
{
|
|
126
|
+
if (getLines != null && getLines.GetParameters().Length == 4)
|
|
127
|
+
{
|
|
128
|
+
var args = new object[] { index, 1, 0, null };
|
|
129
|
+
getLines.Invoke(null, args);
|
|
130
|
+
mode = Convert.ToInt32(args[2], CultureInfo.InvariantCulture);
|
|
131
|
+
line = args[3] as string;
|
|
132
|
+
}
|
|
133
|
+
else if (getEntry != null && getEntry.GetParameters().Length == 4)
|
|
134
|
+
{
|
|
135
|
+
var args = new object[] { index, null, null, null };
|
|
136
|
+
getEntry.Invoke(null, args);
|
|
137
|
+
line = args[1] as string;
|
|
138
|
+
mode = args[2] == null ? 0 : Convert.ToInt32(args[2], CultureInfo.InvariantCulture);
|
|
139
|
+
}
|
|
140
|
+
else if (getLines != null && getLines.GetParameters().Length == 2)
|
|
141
|
+
{
|
|
142
|
+
var args = new object[] { index, null };
|
|
143
|
+
getLines.Invoke(null, args);
|
|
144
|
+
line = args[1] as string;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch { scanComplete = false; }
|
|
148
|
+
if (string.IsNullOrEmpty(line)) { scanComplete = false; continue; }
|
|
149
|
+
var compilerText = line.IndexOf("CS", StringComparison.OrdinalIgnoreCase) >= 0
|
|
150
|
+
&& line.IndexOf("error", StringComparison.OrdinalIgnoreCase) >= 0;
|
|
151
|
+
if (!compilerText && ((mode & 1) == 0 || line.IndexOf("Compile", StringComparison.OrdinalIgnoreCase) < 0)) continue;
|
|
152
|
+
|
|
153
|
+
compileErrorCount++;
|
|
154
|
+
var boundedLine = DoctorBoundedUtf8(line, maxCompileErrorLineBytes);
|
|
155
|
+
var boundedBytes = Encoding.UTF8.GetByteCount(boundedLine);
|
|
156
|
+
if (errors.Count < 20 && compileErrorBytes + boundedBytes <= maxCompileErrorBytes)
|
|
157
|
+
{
|
|
158
|
+
errors.Add(boundedLine);
|
|
159
|
+
compileErrorBytes += boundedBytes;
|
|
160
|
+
if (boundedLine.Length != line.Length) compileErrorsTruncated = true;
|
|
161
|
+
}
|
|
162
|
+
else compileErrorsTruncated = true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
finally
|
|
166
|
+
{
|
|
167
|
+
if (start != null && end != null) end.Invoke(null, Type.EmptyTypes);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (OperationCanceledException) { throw; }
|
|
172
|
+
catch (Exception exception)
|
|
173
|
+
{
|
|
174
|
+
scanComplete = false;
|
|
175
|
+
var readFailure = "Failed to read compile errors: " + exception.GetType().Name;
|
|
176
|
+
if (errors.Count < 20 && compileErrorBytes + Encoding.UTF8.GetByteCount(readFailure) <= maxCompileErrorBytes) errors.Insert(0, readFailure);
|
|
177
|
+
else compileErrorsTruncated = true;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (!scanComplete) compileErrorsTruncated = true;
|
|
181
|
+
var nextActions = new List<string>();
|
|
182
|
+
if (!scanComplete) nextActions.Add("Inspect the Unity Console because compile diagnostics could not be scanned completely.");
|
|
183
|
+
if (compileErrorCount > 0) nextActions.Add("Fix the listed compiler errors, then let Unity finish recompiling.");
|
|
184
|
+
if (compiling) nextActions.Add("Wait for Unity to finish compiling, then run doctor again.");
|
|
185
|
+
return new Dictionary<string, object>
|
|
186
|
+
{
|
|
187
|
+
{ "compiling", compiling },
|
|
188
|
+
{ "scanComplete", scanComplete },
|
|
189
|
+
{ "hasCompileErrors", compileErrorCount > 0 },
|
|
190
|
+
{ "compileErrorCount", compileErrorCount },
|
|
191
|
+
{ "compileErrorsTruncated", compileErrorsTruncated },
|
|
192
|
+
{ "compileErrors", errors },
|
|
193
|
+
{ "nextActions", nextActions }
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private static string DoctorBoundedUtf8(string value, int maxBytes)
|
|
198
|
+
{
|
|
199
|
+
if (string.IsNullOrEmpty(value) || Encoding.UTF8.GetByteCount(value) <= maxBytes) return value ?? string.Empty;
|
|
200
|
+
var length = Math.Min(value.Length, maxBytes);
|
|
201
|
+
while (length > 0 && Encoding.UTF8.GetByteCount(value.Substring(0, length)) > maxBytes) length--;
|
|
202
|
+
if (length > 0 && char.IsHighSurrogate(value[length - 1])) length--;
|
|
203
|
+
return value.Substring(0, length);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private static bool IsDoctorDiagnosticCommand(string command)
|
|
207
|
+
{
|
|
208
|
+
return string.Equals(command, DoctorBusinessCommand, StringComparison.Ordinal)
|
|
209
|
+
|| string.Equals(command, DoctorCatalogCommand, StringComparison.Ordinal)
|
|
210
|
+
|| string.Equals(command, DoctorCompileCommand, StringComparison.Ordinal);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private static bool IsDoctorAdmissionBypassCommand(string command)
|
|
214
|
+
{
|
|
215
|
+
return string.Equals(command, DoctorCatalogCommand, StringComparison.Ordinal)
|
|
216
|
+
|| string.Equals(command, DoctorCompileCommand, StringComparison.Ordinal);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
#endif
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#if UNITY_EDITOR
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using System.Threading;
|
|
5
|
+
using System.Threading.Tasks;
|
|
6
|
+
using UnityCli.Protocol;
|
|
7
|
+
|
|
8
|
+
namespace UnityCli
|
|
9
|
+
{
|
|
10
|
+
public static partial class UnityCliBridge
|
|
11
|
+
{
|
|
12
|
+
/// <summary>域专用公开status Tool共用的只读Bridge协调器;公开输入不包含内部digest或scope。</summary>
|
|
13
|
+
internal static class UnityCliDurableStatusCoordinator
|
|
14
|
+
{
|
|
15
|
+
internal const string AssetRefreshCommand = "internal.asset.refresh.public-status";
|
|
16
|
+
internal const string BuildPlayerCommand = "internal.build.player.public-status";
|
|
17
|
+
internal const string EditorPlayModeCommand = "internal.editor.play-mode.public-status";
|
|
18
|
+
internal const string PackageInstallCommand = "internal.package.install.public-status";
|
|
19
|
+
internal const string PackageRemoveCommand = "internal.package.remove.public-status";
|
|
20
|
+
internal const string TestRunCommand = "internal.test.run.public-status";
|
|
21
|
+
|
|
22
|
+
internal static bool IsCommand(string command)
|
|
23
|
+
{
|
|
24
|
+
return command == AssetRefreshCommand || command == BuildPlayerCommand || command == EditorPlayModeCommand
|
|
25
|
+
|| command == PackageInstallCommand || command == PackageRemoveCommand || command == TestRunCommand;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
internal static void Register(BridgeCommandRegistry registry)
|
|
29
|
+
{
|
|
30
|
+
registry.Register<BridgeRequest>("internal.asset.refresh.public-status", "internal", false, 30000, CoordinatorOwned, UnityCliBridgeQueuePolicy.WorkClass.SafeStatus);
|
|
31
|
+
registry.Register<BridgeRequest>("internal.build.player.public-status", "internal", false, 30000, CoordinatorOwned, UnityCliBridgeQueuePolicy.WorkClass.SafeStatus);
|
|
32
|
+
registry.Register<BridgeRequest>("internal.editor.play-mode.public-status", "internal", false, 30000, CoordinatorOwned, UnityCliBridgeQueuePolicy.WorkClass.SafeStatus);
|
|
33
|
+
registry.Register<BridgeRequest>("internal.package.install.public-status", "internal", false, 30000, CoordinatorOwned, UnityCliBridgeQueuePolicy.WorkClass.SafeStatus);
|
|
34
|
+
registry.Register<BridgeRequest>("internal.package.remove.public-status", "internal", false, 30000, CoordinatorOwned, UnityCliBridgeQueuePolicy.WorkClass.SafeStatus);
|
|
35
|
+
registry.Register<BridgeRequest>("internal.test.run.public-status", "internal", false, 30000, CoordinatorOwned, UnityCliBridgeQueuePolicy.WorkClass.SafeStatus);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private static ValueTask<object> CoordinatorOwned(BridgeRequest request, CancellationToken cancellationToken)
|
|
39
|
+
{
|
|
40
|
+
throw new InvalidOperationException("Durable status is coordinator-owned.");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
internal static Task<string> Execute(BridgeRequest request, CancellationToken cancellationToken)
|
|
44
|
+
{
|
|
45
|
+
cancellationToken.ThrowIfCancellationRequested();
|
|
46
|
+
try
|
|
47
|
+
{
|
|
48
|
+
var args = request.DeserializeArgs<Args>();
|
|
49
|
+
if (args == null || !IsSafeRequestId(args.RequestId))
|
|
50
|
+
throw new BridgeCommandException("E_SCHEMA_INVALID", "requestId is required and must be a safe root request identity.");
|
|
51
|
+
object data;
|
|
52
|
+
switch (request.Command)
|
|
53
|
+
{
|
|
54
|
+
case AssetRefreshCommand: data = ReadScope("asset-refresh", args.RequestId); break;
|
|
55
|
+
case BuildPlayerCommand: data = ReadScope("build", args.RequestId); break;
|
|
56
|
+
case EditorPlayModeCommand: data = ReadEditorPlayModeStatus(args.RequestId); break;
|
|
57
|
+
case PackageInstallCommand: data = UnityCliPackageResolveCoordinator.ReadPublicStatus(args.RequestId, "install"); break;
|
|
58
|
+
case PackageRemoveCommand: data = UnityCliPackageResolveCoordinator.ReadPublicStatus(args.RequestId, "remove"); break;
|
|
59
|
+
case TestRunCommand: data = ReadScope("test-run", args.RequestId); break;
|
|
60
|
+
default: throw new BridgeCommandException("E_TOOL_NOT_FOUND", "Durable status command is not registered.");
|
|
61
|
+
}
|
|
62
|
+
return Task.FromResult(UnityCliSerializer.Serialize(ProtocolEnvelopeFactory.Success(request.RequestId, data)));
|
|
63
|
+
}
|
|
64
|
+
catch (BridgeCommandException exception)
|
|
65
|
+
{
|
|
66
|
+
return Task.FromResult(SerializeBridgeExceptionEnvelope(request.RequestId, exception));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/// <summary>先读有界terminal cache,再读单scope active journal;读取不获取lease且不推进operation。</summary>
|
|
71
|
+
internal static object ReadScope(string scope, string requestId)
|
|
72
|
+
{
|
|
73
|
+
string requestDigest;
|
|
74
|
+
string statusDomain;
|
|
75
|
+
object terminal;
|
|
76
|
+
if (UnityCliActiveOperation.TryGetTerminalByRequestId(scope, requestId, out requestDigest, out statusDomain, out terminal))
|
|
77
|
+
return Terminal(requestId, terminal);
|
|
78
|
+
var root = UnityCliActiveOperation.Load(scope);
|
|
79
|
+
if (root == null || !string.Equals(Text(root, "requestId"), requestId, StringComparison.Ordinal))
|
|
80
|
+
throw new BridgeCommandException("E_REQUEST_NOT_FOUND", "The requested durable operation was not found in this Editor session.");
|
|
81
|
+
return Running(requestId, Text(root, "phase"));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
internal static object Running(string requestId, string phase)
|
|
85
|
+
{
|
|
86
|
+
return new Dictionary<string, object>
|
|
87
|
+
{
|
|
88
|
+
{ "requestId", requestId }, { "state", "running" }, { "phase", string.IsNullOrWhiteSpace(phase) ? "accepted" : phase }
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
internal static object Terminal(string requestId, object envelope)
|
|
93
|
+
{
|
|
94
|
+
return new Dictionary<string, object>
|
|
95
|
+
{
|
|
96
|
+
{ "requestId", requestId }, { "state", "completed" }, { "terminalEnvelope", envelope }
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private static string Text(Dictionary<string, object> value, string key)
|
|
101
|
+
{
|
|
102
|
+
object item;
|
|
103
|
+
return value != null && value.TryGetValue(key, out item) ? item as string : null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private static bool IsSafeRequestId(string requestId)
|
|
107
|
+
{
|
|
108
|
+
if (string.IsNullOrWhiteSpace(requestId) || requestId.Length > 200) return false;
|
|
109
|
+
foreach (var character in requestId)
|
|
110
|
+
if (!(char.IsLetterOrDigit(character) || character == '-' || character == '_' || character == '.' || character == ':')) return false;
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private sealed class Args { public string RequestId { get; set; } }
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
#endif
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
#if UNITY_EDITOR
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using System.Globalization;
|
|
5
|
+
using UnityEditor;
|
|
6
|
+
using UnityEngine;
|
|
7
|
+
using UnityEngine.SceneManagement;
|
|
8
|
+
|
|
9
|
+
namespace UnityCli
|
|
10
|
+
{
|
|
11
|
+
/// <summary>基于 next GameObject instance id 的前序游标;续页只做 O(depth) 定位,不重扫旧页面。</summary>
|
|
12
|
+
internal static class UnityCliHierarchyPager
|
|
13
|
+
{
|
|
14
|
+
/// <summary>单场景遍历只获取一次 root snapshot;子节点始终通过 child-at 向前推进。</summary>
|
|
15
|
+
internal sealed class Traversal
|
|
16
|
+
{
|
|
17
|
+
private readonly Scene scene;
|
|
18
|
+
private readonly GameObject boundaryParent;
|
|
19
|
+
private readonly Transform boundary;
|
|
20
|
+
private readonly int maxDepth;
|
|
21
|
+
private GameObject[] roots;
|
|
22
|
+
|
|
23
|
+
internal Traversal(Scene scene, GameObject boundaryParent, int maxDepth, UnityCliRequestBudget budget)
|
|
24
|
+
{
|
|
25
|
+
this.scene = scene;
|
|
26
|
+
this.boundaryParent = boundaryParent;
|
|
27
|
+
if (boundaryParent != null && !budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
28
|
+
boundary = boundaryParent == null ? null : boundaryParent.transform;
|
|
29
|
+
this.maxDepth = maxDepth;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
internal Scene Scene { get { return scene; } }
|
|
33
|
+
|
|
34
|
+
internal GameObject First(UnityCliRequestBudget budget)
|
|
35
|
+
{
|
|
36
|
+
if (boundaryParent != null)
|
|
37
|
+
{
|
|
38
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
39
|
+
var childCount = boundary.childCount;
|
|
40
|
+
if (childCount == 0) return null;
|
|
41
|
+
if (!budget.TryConsumeGetters(2)) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
42
|
+
return boundary.GetChild(0).gameObject;
|
|
43
|
+
}
|
|
44
|
+
roots = roots ?? UnityCliBridge.ObjectRefResolver.BoundedSceneRoots(scene, budget);
|
|
45
|
+
return roots.Length == 0 ? null : roots[0];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
internal GameObject Next(GameObject current, UnityCliRequestBudget budget)
|
|
49
|
+
{
|
|
50
|
+
if (current == null) return null;
|
|
51
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
52
|
+
var currentTransform = current.transform;
|
|
53
|
+
var relativeDepth = Depth(currentTransform, boundary, budget);
|
|
54
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
55
|
+
if (relativeDepth < maxDepth && currentTransform.childCount > 0)
|
|
56
|
+
{
|
|
57
|
+
if (!budget.TryConsumeGetters(2)) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
58
|
+
return currentTransform.GetChild(0).gameObject;
|
|
59
|
+
}
|
|
60
|
+
var cursor = currentTransform;
|
|
61
|
+
while (cursor != null && cursor != boundary)
|
|
62
|
+
{
|
|
63
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
64
|
+
var parent = cursor.parent;
|
|
65
|
+
if (parent != null)
|
|
66
|
+
{
|
|
67
|
+
if (!budget.TryConsumeGetter() || !budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
68
|
+
var sibling = cursor.GetSiblingIndex() + 1;
|
|
69
|
+
if (sibling < parent.childCount)
|
|
70
|
+
{
|
|
71
|
+
if (!budget.TryConsumeGetters(2)) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
72
|
+
return parent.GetChild(sibling).gameObject;
|
|
73
|
+
}
|
|
74
|
+
cursor = parent;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
78
|
+
var rootSibling = cursor.GetSiblingIndex() + 1;
|
|
79
|
+
roots = roots ?? UnityCliBridge.ObjectRefResolver.BoundedSceneRoots(scene, budget);
|
|
80
|
+
return rootSibling < roots.Length ? roots[rootSibling] : null;
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/// <summary>加载场景集合在请求开始时冻结,每个场景 root array 最多 materialize 一次。</summary>
|
|
87
|
+
internal sealed class LoadedSceneTraversal
|
|
88
|
+
{
|
|
89
|
+
private readonly List<Scene> scenes = new List<Scene>();
|
|
90
|
+
private readonly List<Traversal> traversals = new List<Traversal>();
|
|
91
|
+
private readonly Dictionary<int, int> sceneIndices = new Dictionary<int, int>();
|
|
92
|
+
|
|
93
|
+
internal LoadedSceneTraversal(UnityCliRequestBudget budget, int excludedSceneHandle = 0)
|
|
94
|
+
{
|
|
95
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
96
|
+
var sceneCount = SceneManager.sceneCount;
|
|
97
|
+
for (var sceneIndex = 0; sceneIndex < sceneCount; sceneIndex++)
|
|
98
|
+
{
|
|
99
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
100
|
+
var scene = SceneManager.GetSceneAt(sceneIndex);
|
|
101
|
+
if (!budget.TryConsumeGetters(2)) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
102
|
+
if (!scene.isLoaded || scene.handle == excludedSceneHandle) continue;
|
|
103
|
+
var handle = scene.handle;
|
|
104
|
+
sceneIndices[handle] = scenes.Count;
|
|
105
|
+
scenes.Add(scene);
|
|
106
|
+
traversals.Add(null);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
internal GameObject First(UnityCliRequestBudget budget)
|
|
111
|
+
{
|
|
112
|
+
for (var index = 0; index < traversals.Count; index++)
|
|
113
|
+
{
|
|
114
|
+
var first = GetTraversal(index, budget).First(budget);
|
|
115
|
+
if (first != null) return first;
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
internal GameObject Next(GameObject current, UnityCliRequestBudget budget)
|
|
121
|
+
{
|
|
122
|
+
if (current == null) return null;
|
|
123
|
+
int index;
|
|
124
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
125
|
+
if (!sceneIndices.TryGetValue(current.scene.handle, out index)) return null;
|
|
126
|
+
var next = GetTraversal(index, budget).Next(current, budget);
|
|
127
|
+
if (next != null) return next;
|
|
128
|
+
for (index += 1; index < traversals.Count; index += 1)
|
|
129
|
+
{
|
|
130
|
+
next = GetTraversal(index, budget).First(budget);
|
|
131
|
+
if (next != null) return next;
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private Traversal GetTraversal(int index, UnityCliRequestBudget budget)
|
|
137
|
+
{
|
|
138
|
+
var traversal = traversals[index];
|
|
139
|
+
if (traversal != null) return traversal;
|
|
140
|
+
traversal = new Traversal(scenes[index], null, int.MaxValue, budget);
|
|
141
|
+
traversals[index] = traversal;
|
|
142
|
+
return traversal;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
internal static int Depth(Transform value, Transform boundary, UnityCliRequestBudget budget)
|
|
147
|
+
{
|
|
148
|
+
var depth = 0;
|
|
149
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
150
|
+
var current = value.parent;
|
|
151
|
+
while (current != null && current != boundary)
|
|
152
|
+
{
|
|
153
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
154
|
+
depth++;
|
|
155
|
+
current = current.parent;
|
|
156
|
+
}
|
|
157
|
+
return depth;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
internal static string Cursor(string scope, string generation, string phase, GameObject next, UnityCliRequestBudget budget)
|
|
161
|
+
{
|
|
162
|
+
if (next == null) return null;
|
|
163
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
164
|
+
return UnityCliContinuationToken.Create(scope, generation, (phase ?? "scene") + ":" + next.GetInstanceID().ToString(CultureInfo.InvariantCulture));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
internal static GameObject ResolveCursor(string token, string scope, string generation, UnityCliRequestBudget budget, out string phase)
|
|
168
|
+
{
|
|
169
|
+
phase = null;
|
|
170
|
+
string position;
|
|
171
|
+
if (!UnityCliContinuationToken.TryParse(token, scope, generation, out position)) throw Stale();
|
|
172
|
+
var separator = position.IndexOf(':');
|
|
173
|
+
int instanceId;
|
|
174
|
+
if (separator <= 0 || !int.TryParse(position.Substring(separator + 1), NumberStyles.Integer, CultureInfo.InvariantCulture, out instanceId)) throw Stale();
|
|
175
|
+
phase = position.Substring(0, separator);
|
|
176
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
177
|
+
var value = EditorUtility.InstanceIDToObject(instanceId) as GameObject;
|
|
178
|
+
if (value == null) throw Stale();
|
|
179
|
+
return value;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
internal static string Path(GameObject gameObject, UnityCliRequestBudget budget)
|
|
183
|
+
{
|
|
184
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
185
|
+
var value = gameObject.name;
|
|
186
|
+
if (!budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
187
|
+
var current = gameObject.transform.parent;
|
|
188
|
+
while (current != null)
|
|
189
|
+
{
|
|
190
|
+
if (!budget.TryConsumeNode() || !budget.TryConsumeGetter() || !budget.TryConsumeGetter()) throw new UnityCliRequestBudgetExceededException(budget.ExhaustedDimension);
|
|
191
|
+
value = current.name + "/" + value;
|
|
192
|
+
current = current.parent;
|
|
193
|
+
}
|
|
194
|
+
return value;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
internal static UnityCliBridge.BridgeCommandException Stale()
|
|
198
|
+
{
|
|
199
|
+
return new UnityCliBridge.BridgeCommandException("E_CONTINUATION_STALE", "The hierarchy continuation no longer identifies the same Unity generation or selector.", "Start a new hierarchy read without cursor.");
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
#endif
|
|
@@ -263,7 +263,8 @@ namespace UnityCli
|
|
|
263
263
|
};
|
|
264
264
|
RecordDirectCompletionEvidence(request.RequestId, "internal.instances.prune", InstanceCleanupCompletion, result);
|
|
265
265
|
return new System.Threading.Tasks.ValueTask<object>(result);
|
|
266
|
-
}
|
|
266
|
+
},
|
|
267
|
+
UnityCliBridgeQueuePolicy.WorkClass.Mutation);
|
|
267
268
|
}
|
|
268
269
|
|
|
269
270
|
private static bool IsInstanceCleanupCommand(string command)
|