test: require cli spawn arg values

This commit is contained in:
Shakker
2026-05-12 01:05:32 +01:00
parent 5fca39feeb
commit 04cdba80dc

View File

@@ -343,9 +343,7 @@ describe("runCliAgent spawn path", () => {
let systemPromptPath = "";
supervisorSpawnMock.mockImplementationOnce(async (...args: unknown[]) => {
const input = (args[0] ?? {}) as { argv?: string[] };
const systemPromptArgIndex = input.argv?.indexOf("--append-system-prompt-file") ?? -1;
expect(systemPromptArgIndex).toBeGreaterThanOrEqual(0);
systemPromptPath = input.argv?.[systemPromptArgIndex + 1] ?? "";
systemPromptPath = requireArgAfter(input.argv, "--append-system-prompt-file");
expect(systemPromptPath).toContain("openclaw-cli-system-prompt-");
await expect(fs.readFile(systemPromptPath, "utf-8")).resolves.toBe(
"You are a helpful assistant.",
@@ -418,9 +416,7 @@ describe("runCliAgent spawn path", () => {
expect(resolveArgsInput.useResume).toBe(false);
expect(resolveArgsInput.baseArgs).toEqual(["-p", "--output-format", "stream-json"]);
const input = supervisorSpawnMock.mock.calls[0]?.[0] as { argv?: string[] };
const effortArgIndex = input.argv?.indexOf("--effort") ?? -1;
expect(effortArgIndex).toBeGreaterThanOrEqual(0);
expect(input.argv?.[effortArgIndex + 1]).toBe("high");
expect(requireArgAfter(input.argv, "--effort")).toBe("high");
});
it("passes OpenClaw skills to Claude as a session plugin", async () => {
@@ -443,9 +439,7 @@ describe("runCliAgent spawn path", () => {
let pluginDir = "";
supervisorSpawnMock.mockImplementationOnce(async (...args: unknown[]) => {
const input = (args[0] ?? {}) as { argv?: string[] };
const pluginArgIndex = input.argv?.indexOf("--plugin-dir") ?? -1;
expect(pluginArgIndex).toBeGreaterThanOrEqual(0);
pluginDir = input.argv?.[pluginArgIndex + 1] ?? "";
pluginDir = requireArgAfter(input.argv, "--plugin-dir");
const manifest = JSON.parse(
await fs.readFile(path.join(pluginDir, ".claude-plugin", "plugin.json"), "utf-8"),
) as { name?: string; skills?: string };
@@ -690,9 +684,7 @@ describe("runCliAgent spawn path", () => {
let promptFileText = "";
supervisorSpawnMock.mockImplementationOnce(async (...args: unknown[]) => {
const input = (args[0] ?? {}) as { argv?: string[] };
const configArgIndex = input.argv?.indexOf("-c") ?? -1;
expect(configArgIndex).toBeGreaterThanOrEqual(0);
const configArg = input.argv?.[configArgIndex + 1] ?? "";
const configArg = requireArgAfter(input.argv, "-c");
const match = requireRegexMatch(configArg, /^model_instructions_file="(.+)"$/);
promptFileText = await fs.readFile(match[1], "utf-8");
return createManagedRun({