ACPX plugin: allow configurable command and expected version

This commit is contained in:
Onur
2026-02-28 10:37:02 +01:00
committed by Onur Solmaz
parent 134296276a
commit 921ebfb25e
10 changed files with 299 additions and 75 deletions

View File

@@ -2,12 +2,13 @@ import path from "node:path";
import { describe, expect, it } from "vitest";
import {
ACPX_BUNDLED_BIN,
ACPX_PINNED_VERSION,
createAcpxPluginConfigSchema,
resolveAcpxPluginConfig,
} from "./config.js";
describe("acpx plugin config parsing", () => {
it("resolves a strict plugin-local acpx command", () => {
it("resolves bundled acpx with pinned version by default", () => {
const resolved = resolveAcpxPluginConfig({
rawConfig: {
cwd: "/tmp/workspace",
@@ -16,18 +17,74 @@ describe("acpx plugin config parsing", () => {
});
expect(resolved.command).toBe(ACPX_BUNDLED_BIN);
expect(resolved.expectedVersion).toBe(ACPX_PINNED_VERSION);
expect(resolved.allowPluginLocalInstall).toBe(true);
expect(resolved.cwd).toBe(path.resolve("/tmp/workspace"));
});
it("rejects command overrides", () => {
expect(() =>
resolveAcpxPluginConfig({
rawConfig: {
command: "acpx-custom",
},
workspaceDir: "/tmp/workspace",
}),
).toThrow("unknown config key: command");
it("accepts command override and disables plugin-local auto-install", () => {
const resolved = resolveAcpxPluginConfig({
rawConfig: {
command: "/home/user/repos/acpx/dist/cli.js",
},
workspaceDir: "/tmp/workspace",
});
expect(resolved.command).toBe("/home/user/repos/acpx/dist/cli.js");
expect(resolved.expectedVersion).toBeUndefined();
expect(resolved.allowPluginLocalInstall).toBe(false);
});
it("resolves relative command paths against workspace directory", () => {
const resolved = resolveAcpxPluginConfig({
rawConfig: {
command: "../acpx/dist/cli.js",
},
workspaceDir: "/home/user/repos/openclaw",
});
expect(resolved.command).toBe(path.resolve("/home/user/repos/openclaw", "../acpx/dist/cli.js"));
expect(resolved.expectedVersion).toBeUndefined();
expect(resolved.allowPluginLocalInstall).toBe(false);
});
it("keeps bare command names as-is", () => {
const resolved = resolveAcpxPluginConfig({
rawConfig: {
command: "acpx",
},
workspaceDir: "/tmp/workspace",
});
expect(resolved.command).toBe("acpx");
expect(resolved.expectedVersion).toBeUndefined();
expect(resolved.allowPluginLocalInstall).toBe(false);
});
it("accepts exact expectedVersion override", () => {
const resolved = resolveAcpxPluginConfig({
rawConfig: {
command: "/home/user/repos/acpx/dist/cli.js",
expectedVersion: "0.1.99",
},
workspaceDir: "/tmp/workspace",
});
expect(resolved.command).toBe("/home/user/repos/acpx/dist/cli.js");
expect(resolved.expectedVersion).toBe("0.1.99");
expect(resolved.allowPluginLocalInstall).toBe(false);
});
it("treats expectedVersion=any as no version constraint", () => {
const resolved = resolveAcpxPluginConfig({
rawConfig: {
command: "/home/user/repos/acpx/dist/cli.js",
expectedVersion: "any",
},
workspaceDir: "/tmp/workspace",
});
expect(resolved.expectedVersion).toBeUndefined();
});
it("rejects commandArgs overrides", () => {