From d90b2c4ac286e8a8491c9c31fabe57d2c611d9c5 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 18 Jul 2026 19:25:28 +0100 Subject: [PATCH] Expose Unity host snapshots through Brokkr CLI --- brokkr-command/Program.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/brokkr-command/Program.cs b/brokkr-command/Program.cs index e35ed76..8ef3f44 100644 --- a/brokkr-command/Program.cs +++ b/brokkr-command/Program.cs @@ -7,6 +7,33 @@ using var cache = await CultCacheMessagePack.OpenAsync(options.CachePath, new Cu { UseDirectoryStore = true }); +if (string.Equals(options.Action, "readHost", StringComparison.Ordinal)) +{ + await cache.PullAllBackingStoresAsync(); + var hostKey = new CultRecordKey("unity/host/current"); + if (!cache.TryGet(hostKey, out BrokkrHostSnapshot? host) || host == null) + { + throw new InvalidOperationException($"Brokkr host snapshot '{hostKey.Value}' is unavailable."); + } + + Console.WriteLine($"project: {host.projectPath}"); + Console.WriteLine($"observed: {host.observedAt}"); + Console.WriteLine($"scene: {host.activeScenePath}"); + Console.WriteLine($"state: playing={host.isPlaying} paused={host.isPaused} compiling={host.isCompiling} updating={host.isUpdating}"); + Console.WriteLine($"objects: {host.sceneObjects.Length}"); + foreach (var sceneObject in host.sceneObjects.OrderBy(item => item.path, StringComparer.Ordinal)) + { + var components = string.Join(", ", sceneObject.components.Select(component => component.typeName)); + Console.WriteLine($"- {sceneObject.path} active={sceneObject.activeSelf} layer={sceneObject.layer} components=[{components}]"); + foreach (var component in sceneObject.components) + foreach (var property in component.properties.Where(property => + !property.path.StartsWith("m_", StringComparison.Ordinal) && + !string.IsNullOrWhiteSpace(property.value))) + Console.WriteLine($" {component.typeName}.{property.path}={property.value}"); + } + return; +} + var command = new BrokkrUnityCommand { commandId = options.CommandId,