SboxSuperuser/Superuser.Commands.cs

Static partial class Superuser with helper methods for command registration and discovery. BeginCommandRegistration finds an authoritative runtime and returns a CommandRegistrationScope configured with the runtime command registry and an attribute-based discovery callback. GetCommandDescriptors returns the host runtime's command descriptors or an empty list.

Reflection
using SboxSuperuser.Engine.CommandDiscovery;

namespace SboxSuperuser;

public static partial class Superuser
{
	/// <summary>Starts a host-main-thread module batch; commit to activate and retain the scope until module shutdown.</summary>
	public static CommandRegistrationScope BeginCommandRegistration( string moduleId )
	{
		var runtime = FindAuthorityRuntime() ?? throw new InvalidOperationException( "An eligible authoritative runtime is required." );
		return new CommandRegistrationScope( runtime.Commands, moduleId, AttributeCommandDiscovery.Discover );
	}

	/// <summary>Gets local registered command metadata; this host-only catalog is not permission-filtered client help.</summary>
	public static IReadOnlyList<CommandDescriptor> GetCommandDescriptors()
	{
		return FindAuthorityRuntime()?.Commands.Descriptors ?? Array.Empty<CommandDescriptor>();
	}
}