From 9cae5107d1483a0629680eceeac7c4478aeb08c7 Mon Sep 17 00:00:00 2001 From: Onur <2453968+osolmaz@users.noreply.github.com> Date: Sat, 28 Feb 2026 21:02:25 +0100 Subject: [PATCH] ACPX extension: support acpx any-version probe via --help --- extensions/acpx/src/ensure.test.ts | 16 +++++++++++++--- extensions/acpx/src/ensure.ts | 20 ++++++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/extensions/acpx/src/ensure.test.ts b/extensions/acpx/src/ensure.test.ts index 81b88da3ab5..7690eba6a3b 100644 --- a/extensions/acpx/src/ensure.test.ts +++ b/extensions/acpx/src/ensure.test.ts @@ -45,6 +45,11 @@ describe("acpx ensure", () => { version: ACPX_PINNED_VERSION, expectedVersion: ACPX_PINNED_VERSION, }); + expect(spawnAndCollectMock).toHaveBeenCalledWith({ + command: "/plugin/node_modules/.bin/acpx", + args: ["--version"], + cwd: "/plugin", + }); }); it("reports version mismatch", async () => { @@ -70,9 +75,9 @@ describe("acpx ensure", () => { }); }); - it("accepts any installed version when expectedVersion is unset", async () => { + it("accepts command availability when expectedVersion is unset", async () => { spawnAndCollectMock.mockResolvedValueOnce({ - stdout: "acpx 9.9.9\n", + stdout: "Usage: acpx [options]\n", stderr: "", code: 0, error: null, @@ -86,9 +91,14 @@ describe("acpx ensure", () => { expect(result).toEqual({ ok: true, - version: "9.9.9", + version: "unknown", expectedVersion: undefined, }); + expect(spawnAndCollectMock).toHaveBeenCalledWith({ + command: "/custom/acpx", + args: ["--help"], + cwd: "/custom", + }); }); it("installs and verifies pinned acpx when precheck fails", async () => { diff --git a/extensions/acpx/src/ensure.ts b/extensions/acpx/src/ensure.ts index dd661152fd4..8238e85a9f4 100644 --- a/extensions/acpx/src/ensure.ts +++ b/extensions/acpx/src/ensure.ts @@ -25,6 +25,10 @@ function extractVersion(stdout: string, stderr: string): string | null { return match?.[0] ?? null; } +function isExpectedVersionConfigured(value: string | undefined): value is string { + return typeof value === "string" && value.trim().length > 0; +} + export async function checkAcpxVersion(params: { command: string; cwd?: string; @@ -33,9 +37,11 @@ export async function checkAcpxVersion(params: { const expectedVersion = params.expectedVersion?.trim() || undefined; const installCommand = buildAcpxLocalInstallCommand(expectedVersion ?? ACPX_PINNED_VERSION); const cwd = params.cwd ?? ACPX_PLUGIN_ROOT; + const hasExpectedVersion = isExpectedVersionConfigured(expectedVersion); + const probeArgs = hasExpectedVersion ? ["--version"] : ["--help"]; const result = await spawnAndCollect({ command: params.command, - args: ["--version"], + args: probeArgs, cwd, }); @@ -64,12 +70,22 @@ export async function checkAcpxVersion(params: { return { ok: false, reason: "execution-failed", - message: stderr || `acpx --version failed with code ${result.code ?? "unknown"}`, + message: + stderr || + `acpx ${hasExpectedVersion ? "--version" : "--help"} failed with code ${result.code ?? "unknown"}`, expectedVersion, installCommand, }; } + if (!hasExpectedVersion) { + return { + ok: true, + version: "unknown", + expectedVersion, + }; + } + const installedVersion = extractVersion(result.stdout, result.stderr); if (!installedVersion) { return {