summaryrefslogtreecommitdiffhomepage
path: root/packages/cli
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli')
-rw-r--r--packages/cli/src/args.test.ts43
-rw-r--r--packages/cli/src/args.ts7
-rw-r--r--packages/cli/src/main.ts2
-rw-r--r--packages/cli/src/message.test.ts39
-rw-r--r--packages/cli/src/message.ts2
5 files changed, 92 insertions, 1 deletions
diff --git a/packages/cli/src/args.test.ts b/packages/cli/src/args.test.ts
index e6b43cf..14c4ffc 100644
--- a/packages/cli/src/args.test.ts
+++ b/packages/cli/src/args.test.ts
@@ -216,6 +216,49 @@ describe("parseArgs", () => {
expect(result.kind).toBe("error");
if (result.kind === "error") expect(result.message).toContain("--workspace requires a value");
});
+
+ it("parses --title flag", () => {
+ const result = parseArgs(["m", "--text", "x", "--title", "My Task"], { defaultServer });
+ expect(result).toEqual({
+ kind: "chat",
+ server: "http://localhost:24203",
+ modelName: "m",
+ text: "x",
+ file: undefined,
+ cwd: undefined,
+ conversationId: undefined,
+ reasoningEffort: undefined,
+ showReasoning: false,
+ open: false,
+ title: "My Task",
+ });
+ });
+
+ it("parses --title with --workspace together", () => {
+ const result = parseArgs(["m", "--text", "x", "--workspace", "ws", "--title", "T"], {
+ defaultServer,
+ });
+ expect(result.kind).toBe("chat");
+ if (result.kind === "chat") {
+ expect(result.workspaceId).toBe("ws");
+ expect(result.title).toBe("T");
+ }
+ });
+
+ it("omits title when --title is not given", () => {
+ const result = parseArgs(["m", "--text", "x"], { defaultServer });
+ expect(result.kind).toBe("chat");
+ if (result.kind === "chat") {
+ expect(result.title).toBeUndefined();
+ expect(result).not.toHaveProperty("title");
+ }
+ });
+
+ it("errors when --title has no value", () => {
+ const result = parseArgs(["m", "--text", "x", "--title"], { defaultServer });
+ expect(result.kind).toBe("error");
+ if (result.kind === "error") expect(result.message).toContain("--title requires a value");
+ });
});
describe("list", () => {
diff --git a/packages/cli/src/args.ts b/packages/cli/src/args.ts
index 52f1fba..581d4c2 100644
--- a/packages/cli/src/args.ts
+++ b/packages/cli/src/args.ts
@@ -27,6 +27,7 @@ export type ParsedCommand =
readonly showReasoning: boolean;
readonly open: boolean;
readonly workspaceId?: string | undefined;
+ readonly title?: string | undefined;
}
| {
readonly kind: "list";
@@ -307,6 +308,7 @@ export function parseArgs(argv: readonly string[], opts: ParseOpts): ParsedComma
let open = false;
let server = opts.defaultServer;
let workspaceId: string | undefined;
+ let title: string | undefined;
for (let i = 1; i < argv.length; i++) {
const arg = argv[i] as string;
@@ -338,6 +340,10 @@ export function parseArgs(argv: readonly string[], opts: ParseOpts): ParsedComma
case "--open":
open = true;
break;
+ case "--title":
+ if (i + 1 >= argv.length) return { kind: "error", message: "--title requires a value" };
+ title = argv[++i];
+ break;
case "--effort":
if (i + 1 >= argv.length)
return {
@@ -383,5 +389,6 @@ export function parseArgs(argv: readonly string[], opts: ParseOpts): ParsedComma
showReasoning,
open,
...(workspaceId !== undefined && { workspaceId }),
+ ...(title !== undefined && { title }),
};
}
diff --git a/packages/cli/src/main.ts b/packages/cli/src/main.ts
index 9fca347..c4fff1e 100644
--- a/packages/cli/src/main.ts
+++ b/packages/cli/src/main.ts
@@ -30,7 +30,7 @@ const USAGE = `Usage:
dispatch read <conversationId> [--server <url>]
dispatch open <conversationId> [--server <url>]
dispatch send <conversationId> --text "..." [--file <path>] [--queue] [--open] [--cwd <dir>] [--effort <level>] [--workspace <id>] [--server <url>]
- dispatch <modelName> --text "..." [--file <path>] [--cwd <dir>] [--conversation <id>] [--effort <level>] [--workspace <id>] [--server <url>] [--show-reasoning] [--open]
+ dispatch <modelName> --text "..." [--file <path>] [--cwd <dir>] [--conversation <id>] [--effort <level>] [--workspace <id>] [--title <title>] [--server <url>] [--show-reasoning] [--open]
dispatch --help
Effort levels: low, medium, high (default), xhigh, max`;
diff --git a/packages/cli/src/message.test.ts b/packages/cli/src/message.test.ts
index 536d64f..2deb197 100644
--- a/packages/cli/src/message.test.ts
+++ b/packages/cli/src/message.test.ts
@@ -111,6 +111,22 @@ describe("buildChatRequest", () => {
);
expect(req).not.toHaveProperty("workspaceId");
});
+
+ it("includes title when provided", () => {
+ const req = buildChatRequest(
+ { modelName: "m", text: "x", title: "My Task", showReasoning: false },
+ { cwd: "/work", message: "x" },
+ );
+ expect(req.title).toBe("My Task");
+ });
+
+ it("omits title when not provided", () => {
+ const req = buildChatRequest(
+ { modelName: "m", text: "x", showReasoning: false },
+ { cwd: "/work", message: "x" },
+ );
+ expect(req).not.toHaveProperty("title");
+ });
});
describe("workspace flag → ChatRequest", () => {
@@ -145,3 +161,26 @@ describe("workspace flag → ChatRequest", () => {
expect(req.workspaceId).toBe("shorthand");
});
});
+
+describe("title flag → ChatRequest", () => {
+ const defaultServer = "http://localhost:24203";
+
+ it("--title flag sets title on request", () => {
+ const parsed = parseArgs(["my-model", "--text", "hi", "--title", "My Task"], {
+ defaultServer,
+ });
+ expect(parsed.kind).toBe("chat");
+ if (parsed.kind !== "chat") return;
+ const req = buildChatRequest(parsed, { cwd: "/work", message: "hi" });
+ expect(req.title).toBe("My Task");
+ });
+
+ it("--title flag omitted sends no title", () => {
+ const parsed = parseArgs(["my-model", "--text", "hi"], { defaultServer });
+ expect(parsed.kind).toBe("chat");
+ if (parsed.kind !== "chat") return;
+ const req = buildChatRequest(parsed, { cwd: "/work", message: "hi" });
+ expect(req.title).toBeUndefined();
+ expect(req).not.toHaveProperty("title");
+ });
+});
diff --git a/packages/cli/src/message.ts b/packages/cli/src/message.ts
index ddbec6b..5db9966 100644
--- a/packages/cli/src/message.ts
+++ b/packages/cli/src/message.ts
@@ -39,6 +39,7 @@ interface ChatCmd {
readonly conversationId?: string | undefined;
readonly reasoningEffort?: ReasoningEffort | undefined;
readonly workspaceId?: string | undefined;
+ readonly title?: string | undefined;
readonly showReasoning: boolean;
}
@@ -55,5 +56,6 @@ export function buildChatRequest(cmd: ChatCmd, ctx: BuildCtx): ChatRequest {
...(cmd.cwd !== undefined ? { cwd: cmd.cwd } : { cwd: ctx.cwd }),
...(cmd.reasoningEffort !== undefined && { reasoningEffort: cmd.reasoningEffort }),
...(cmd.workspaceId !== undefined && { workspaceId: cmd.workspaceId }),
+ ...(cmd.title !== undefined && { title: cmd.title }),
};
}