Files
paseo/packages/cli/src/cli-surface.test.ts
T
Arnold HueteandMohamed Boudra b6375b1426 Set Archive on finish from the CLI and MCP (#8479)
Schedules created through the CLI or MCP archived every run's workspace and agent, and only the app's switch could change that. Add --archive-on-finish and --no-archive-on-finish to paseo schedule create and update, and archiveOnFinish to create_schedule and update_schedule. Omitting the option stores nothing, so the default stays on.

A repeated named create_schedule that changes only Archive on finish refreshes the existing schedule instead of creating a duplicate, and keeps the saved value when the request omits it.

Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
2026-11-25 17:06:48 +07:00

154 lines
6.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { createCli } from "./cli.js";
describe("canonical CLI surface", () => {
it.each(["send", "agent send"])("%s accepts an explicit behavior override", async (path) => {
const cli = createCli();
const owner =
path === "send" ? cli : cli.commands.find((command) => command.name() === "agent")!;
const send = owner.commands.find((command) => command.name() === "send")!;
send.action(() => {});
await send.parseAsync(["target", "message", "--behavior", "interrupt"], { from: "user" });
expect(send.opts().behavior).toBe("interrupt");
await send.parseAsync(["target", "message", "--behavior", "steer"], { from: "user" });
expect(send.opts().behavior).toBe("steer");
await send.parseAsync(["target", "message", "--behavior", "queue"], { from: "user" });
expect(send.opts().behavior).toBe("queue");
send.exitOverride().configureOutput({ writeErr: () => {} });
await expect(
send.parseAsync(["target", "message", "--behavior", "wait"], { from: "user" }),
).rejects.toThrow();
});
it("offers daemon host selection as a global option", () => {
expect(createCli().helpInformation()).toContain("--host <host>");
});
it("shows project, workspace, and heartbeat commands while hiding worktree compatibility", () => {
const cli = createCli();
const help = cli.helpInformation();
expect(help).toContain("project");
expect(help).toContain("workspace");
expect(help).toContain("heartbeat");
expect(help).not.toContain("worktree");
});
it("offers identical top-level and daemon config reload commands", () => {
const cli = createCli();
const reload = cli.commands.find((command) => command.name() === "reload");
const daemon = cli.commands.find((command) => command.name() === "daemon");
const nestedReload = daemon?.commands.find((command) => command.name() === "reload");
expect(reload?.helpInformation()).toContain("--host <host>");
expect(reload?.helpInformation()).toContain("--json");
expect(nestedReload?.helpInformation()).toContain("--host <host>");
expect(nestedReload?.helpInformation()).toContain("--json");
});
it("names explicit workspace creation without exposing older syntax", () => {
const run = createCli().commands.find((command) => command.name() === "run");
const help = run?.helpInformation();
expect(help).toContain("--new-workspace <local|worktree>");
expect(help).not.toContain("--isolation");
expect(help).not.toContain("--worktree <name>");
});
it("offers the worktree creation options on run", () => {
const run = createCli().commands.find((command) => command.name() === "run");
const help = run?.helpInformation();
expect(help).toContain("--worktree-mode <mode>");
expect(help).toContain("--worktree-slug <slug>");
expect(help).toContain("--new-branch <name>");
expect(help).toContain("--branch <name>");
expect(help).toContain("--pr-number <n>");
expect(help).toContain("--forge <forge>");
});
it("uses --no-wait for execution, --internal for visibility, and reserves detach for ownership", () => {
const run = createCli().commands.find((command) => command.name() === "run");
const help = run?.helpInformation();
expect(help).toContain("--no-wait");
expect(help).not.toContain("--background");
expect(help).not.toContain("--background");
expect(help).not.toContain("--detach");
});
it("hides internal agents and workspaces from listings unless --internal is passed", () => {
const cli = createCli();
const ls = cli.commands.find((command) => command.name() === "ls");
const workspace = cli.commands.find((command) => command.name() === "workspace");
const workspaceLs = workspace?.commands.find((command) => command.name() === "ls");
const workspaceCreate = workspace?.commands.find((command) => command.name() === "create");
expect(ls?.helpInformation()).toContain("--background");
expect(workspaceLs?.helpInformation()).toContain("--background");
expect(workspaceCreate?.helpInformation()).toContain("--background");
});
it("offers thinking configuration when running, updating, and scheduling agents", () => {
const cli = createCli();
const run = cli.commands.find((command) => command.name() === "run");
const agent = cli.commands.find((command) => command.name() === "agent");
const update = agent?.commands.find((command) => command.name() === "update");
const schedule = cli.commands.find((command) => command.name() === "schedule");
const scheduleCreate = schedule?.commands.find((command) => command.name() === "create");
expect(run?.helpInformation()).toContain("--thinking <id>");
expect(update?.helpInformation()).toContain("--thinking <id>");
expect(scheduleCreate?.helpInformation()).toContain("--thinking <id>");
});
it("offers archive on finish when creating and updating schedules", () => {
const schedule = createCli().commands.find((command) => command.name() === "schedule");
for (const name of ["create", "update"]) {
const help = schedule?.commands.find((command) => command.name() === name)?.helpInformation();
expect(help).toContain("--archive-on-finish");
expect(help).toContain("--no-archive-on-finish");
}
});
it("offers opening an existing agent in the desktop app", () => {
const agent = createCli().commands.find((command) => command.name() === "agent");
const open = agent?.commands.find((command) => command.name() === "open");
expect(open?.helpInformation()).toContain("<agent-id>");
expect(open?.helpInformation()).toContain("--server <server-id>");
});
it("offers the complete local plugin lifecycle", () => {
const plugin = createCli().commands.find((command) => command.name() === "plugin");
expect(plugin?.commands.map((command) => command.name())).toEqual([
"init",
"ls",
"status",
"logs",
"install",
"update",
"reload",
"enable",
"disable",
"remove",
]);
expect(
plugin?.commands.find((command) => command.name() === "init")?.helpInformation(),
).toContain("--id <id>");
expect(
plugin?.commands.find((command) => command.name() === "install")?.helpInformation(),
).toContain("--id <id>");
});
});
it("preserves omitted and explicit false workspace background intent", () => {
const readOptions = (args: string[]) => {
const workspace = createCli().commands.find((command) => command.name() === "workspace")!;
const create = workspace.commands.find((command) => command.name() === "create")!;
create.parseOptions(args);
return create.opts();
};
expect(readOptions([]).background).toBeUndefined();
expect(readOptions(["--background"]).background).toBe(true);
expect(readOptions(["--no-background"]).background).toBe(false);
});