fix(cli): support mode when importing agents

This commit is contained in:
Keith Kowal
2026-09-11 14:57:01 -07:00
parent fa93c4290e
commit 89cb1bf34d
12 changed files with 82 additions and 6 deletions
+5
View File
@@ -46,6 +46,11 @@ describe("canonical CLI surface", () => {
expect(help).toContain("--forge <forge>");
});
it("offers provider mode selection when importing an agent", () => {
const importCommand = createCli().commands.find((command) => command.name() === "import");
expect(importCommand?.helpInformation()).toContain("--mode <mode>");
});
it("uses background for execution and reserves detach for ownership", () => {
const run = createCli().commands.find((command) => command.name() === "run");
expect(run?.helpInformation()).toContain("--background");
@@ -57,4 +57,32 @@ describe("resolveImportCwd", () => {
});
expect(result.data.provider).toBe("pi");
});
it("passes the requested mode to the import request", async () => {
importAgent.mockResolvedValueOnce({
id: "agent-2",
status: "idle",
provider: "claude",
cwd: "/tmp/project",
title: "Imported Claude session",
});
await runImportCommand(
"claude-session-1",
{
daemonTarget: { kind: "endpoint", host: "example.test:12345" },
provider: "claude",
cwd: "/tmp/project",
mode: "auto",
},
{} as never,
);
expect(importAgent).toHaveBeenCalledWith({
provider: "claude",
sessionId: "claude-session-1",
cwd: "/tmp/project",
modeId: "auto",
});
});
});
@@ -11,6 +11,7 @@ export function addImportOptions(cmd: Command): Command {
.argument("<id>", "Provider session/thread ID to import")
.requiredOption("--provider <provider>", "Agent provider id")
.option("--cwd <path>", "Working directory for providers that require it")
.option("--mode <mode>", "Provider-specific mode (e.g., plan, default, bypass)")
.option(
"--label <key=value>",
"Add label(s) to the agent (can be used multiple times)",
@@ -22,6 +23,7 @@ export function addImportOptions(cmd: Command): Command {
export interface AgentImportOptions extends CommandOptions {
provider?: string;
cwd?: string;
mode?: string;
label?: string[];
host?: string;
}
@@ -119,6 +121,7 @@ export async function runImportCommand(
provider,
sessionId,
cwd,
...(options.mode ? { modeId: options.mode } : {}),
...(Object.keys(labels).length > 0 ? { labels } : {}),
});