From bc1c2aa44892852b3f0a3fb703a3a3b57f719bda Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 14 Nov 2026 17:34:52 -0800 Subject: [PATCH 1/3] Lab: describe_program and game_open commands describe_program prints the selected program's id and the static contract of its options (keys, types, defaults, bounds, enum entries and which are enabled, nested groups) as one line of JSON; prechecks report unsupported until the precheck list reaches lab/tooling. game_open reports whether a game is in front (not Home, the user select or a black screen). Both read only. BatchOption gains keyed_options() so the contract can name each option by the key set takes. --- Common/Cpp/Options/BatchOption.cpp | 3 + Common/Cpp/Options/BatchOption.h | 7 + .../Source/CommonFramework/Windows/Lab.md | 32 ++- .../CommonFramework/Windows/LabChannel.cpp | 24 ++ .../CommonFramework/Windows/LabChannel.h | 6 + .../Windows/LabProgramContract.cpp | 138 ++++++++++ .../Windows/LabProgramContract.h | 47 ++++ .../Windows/LabProgramContract_Tests.cpp | 243 ++++++++++++++++++ .../Windows/LabProgramContract_Tests.h | 21 ++ .../ComputerPrograms_UnitTestRunner.cpp | 2 + .../NintendoSwitch_CommandFileRunner.cpp | 44 ++++ .../NintendoSwitch_CommandFileRunner.h | 16 ++ ...NintendoSwitch_CommandFileRunner_Tests.cpp | 65 ++++- .../NintendoSwitch_LabCommands.cpp | 5 + .../NintendoSwitch_LabCommands.h | 1 + SerialPrograms/cmake/SourceFiles.cmake | 4 + 16 files changed, 656 insertions(+), 2 deletions(-) create mode 100644 SerialPrograms/Source/CommonFramework/Windows/LabProgramContract.cpp create mode 100644 SerialPrograms/Source/CommonFramework/Windows/LabProgramContract.h create mode 100644 SerialPrograms/Source/CommonFramework/Windows/LabProgramContract_Tests.cpp create mode 100644 SerialPrograms/Source/CommonFramework/Windows/LabProgramContract_Tests.h diff --git a/Common/Cpp/Options/BatchOption.cpp b/Common/Cpp/Options/BatchOption.cpp index a3747e0ad6..049991d192 100644 --- a/Common/Cpp/Options/BatchOption.cpp +++ b/Common/Cpp/Options/BatchOption.cpp @@ -95,6 +95,9 @@ FixedLimitVector BatchOption::options() const{ } return ret; } +const std::vector>& BatchOption::keyed_options() const{ + return m_data->m_options; +} diff --git a/Common/Cpp/Options/BatchOption.h b/Common/Cpp/Options/BatchOption.h index c8ac257570..6a5cf4296a 100644 --- a/Common/Cpp/Options/BatchOption.h +++ b/Common/Cpp/Options/BatchOption.h @@ -7,6 +7,9 @@ #ifndef PokemonAutomation_Options_BatchOption_H #define PokemonAutomation_Options_BatchOption_H +#include +#include +#include #include "Common/Cpp/Containers/Pimpl.h" #include "Common/Cpp/Containers/FixedLimitVector.h" #include "ConfigOption.h" @@ -42,6 +45,10 @@ class BatchOption : public UiState{ bool horizontal() const; FixedLimitVector options() const; + // Each option with the key it is saved under in to_json(), in the order + // they were added. Static options have an empty key. + const std::vector>& keyed_options() const; + private: struct Data; diff --git a/SerialPrograms/Source/CommonFramework/Windows/Lab.md b/SerialPrograms/Source/CommonFramework/Windows/Lab.md index d64089d611..3a0bda6b0b 100644 --- a/SerialPrograms/Source/CommonFramework/Windows/Lab.md +++ b/SerialPrograms/Source/CommonFramework/Windows/Lab.md @@ -112,6 +112,7 @@ program. | `start [SECONDS]` | What clicking Start Program does. Refused unless the program is `STOPPED`. First waits up to `SECONDS` (default 30) for `controller=ready`, and refuses with `controller not connected` if it never is, instead of starting a program that would fail with "Incompatible Controller". | | `stop` | What clicking Stop Program does. Refused unless the program is `RUNNING`. The request goes on; the program stops in the background. | | `state` | Prints the state file's lines into the journal. (In the Command File Runner program, `state [image]` prints the detectors that fire instead; from the channel use `detect` per detector.) | +| `describe_program` | Prints the selected program's id and the static contract of its options as one line, `describe_program `; see [Describe program](#describe-program). Reads only: needs no owner token and no console. Refused when the selected panel is not a program. | | `snapshot LABEL [TIMEOUT_MS]` | Saves the first video frame newer than this line as `_