From 24b566bdbd9cbca6525679a22f22074861e66a78 Mon Sep 17 00:00:00 2001 From: hatayama Date: Mon, 27 Jul 2026 18:49:24 +0900 Subject: [PATCH] fix: Report delegated CLI version in V2 mode notice The dispatcher delegates commands to the V2 `uloop-cli` implicitly, and the stderr notice was the only signal that a V2 CLI ran. "executing in V2 mode" alone did not say which V2 CLI served the command, so a behavior difference against V3 could not be traced back to a concrete version. Include the delegated package and version in the notice, reusing the existing `dispatcherV2CLIPackageName` constant. The notice text is extracted into a pure function so it can be tested without launching node. --- .../internal/dispatcher/dispatcher_v2_run.go | 8 +++++++- .../internal/dispatcher/dispatcher_v2_run_test.go | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 cli/dispatcher/internal/dispatcher/dispatcher_v2_run_test.go diff --git a/cli/dispatcher/internal/dispatcher/dispatcher_v2_run.go b/cli/dispatcher/internal/dispatcher/dispatcher_v2_run.go index a36560fc5f..a85f2d7998 100644 --- a/cli/dispatcher/internal/dispatcher/dispatcher_v2_run.go +++ b/cli/dispatcher/internal/dispatcher/dispatcher_v2_run.go @@ -87,6 +87,12 @@ func dispatcherV2ProjectDetectedError(projectRoot string, v2Project dispatcherV2 } } +// dispatcherV2ModeNotice builds the stderr notice announcing delegation to the V2 CLI. +// Why: delegation happens implicitly, so the executed CLI generation and version are otherwise invisible to the caller. +func dispatcherV2ModeNotice(version string) string { + return "uloop: executing in V2 mode (" + dispatcherV2CLIPackageName + "@" + version + ")\n" +} + // runDispatcherV2CLI installs and executes the V2 CLI while preserving the original command arguments. // Why: the dispatcher must select the CLI generation before command parsing can change user-supplied arguments. func runDispatcherV2CLI(ctx context.Context, version string, args []string, stdout io.Writer, stderr io.Writer) (int, error) { @@ -106,7 +112,7 @@ func runDispatcherV2CLI(ctx context.Context, version string, args []string, stdo if err != nil { return 0, err } - _, err = io.WriteString(stderr, "uloop: executing in V2 mode\n") + _, err = io.WriteString(stderr, dispatcherV2ModeNotice(version)) if err != nil { return 0, err } diff --git a/cli/dispatcher/internal/dispatcher/dispatcher_v2_run_test.go b/cli/dispatcher/internal/dispatcher/dispatcher_v2_run_test.go new file mode 100644 index 0000000000..8770586a95 --- /dev/null +++ b/cli/dispatcher/internal/dispatcher/dispatcher_v2_run_test.go @@ -0,0 +1,13 @@ +package dispatcher + +import "testing" + +func TestDispatcherV2ModeNoticeReportsDelegatedPackageAndVersion(t *testing.T) { + // Verifies the notice names the delegated V2 CLI package and its version so the caller can identify the executed generation. + notice := dispatcherV2ModeNotice("2.2.0") + + want := "uloop: executing in V2 mode (" + dispatcherV2CLIPackageName + "@2.2.0)\n" + if notice != want { + t.Fatalf("notice = %q, want %q", notice, want) + } +}