mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 19:44:44 +00:00
test: require cli spawn arg values
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user