summaryrefslogtreecommitdiffhomepage
path: root/packages/cli/src/main.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-25 10:30:41 +0900
committerAdam Malczewski <[email protected]>2026-06-25 10:30:41 +0900
commitd4b470ca582e3c69c40438895b90748d44fc4653 (patch)
tree1556ec4073013cec8d5599a6aa9911bedcfca7c3 /packages/cli/src/main.ts
parent8a74335c21a57ee63c9a0658754430d6520dbc87 (diff)
downloaddispatch-d4b470ca582e3c69c40438895b90748d44fc4653.tar.gz
dispatch-d4b470ca582e3c69c40438895b90748d44fc4653.zip
feat(cli): add --file flag to 'dispatch send' subcommand
Add the same --file <path> support that the summon (chat) command has to the 'dispatch send' subcommand. When --file is given, the file's contents are read and attached to the message (composed via composeMessage, identical to chat). - args.ts: add 'file' to the send ParsedCommand, make 'text' optional, parse --file, and require at least one of --text or --file. - main.ts: read the file and compose the message in the send case, using the composed message in both the --queue and streaming branches; update USAGE. - args.test.ts: cover --file parsing (alone, with --text, missing value) and update the existing send expectations + the both-missing error message.
Diffstat (limited to 'packages/cli/src/main.ts')
-rw-r--r--packages/cli/src/main.ts16
1 files changed, 13 insertions, 3 deletions
diff --git a/packages/cli/src/main.ts b/packages/cli/src/main.ts
index 9dfc317..b61be07 100644
--- a/packages/cli/src/main.ts
+++ b/packages/cli/src/main.ts
@@ -29,7 +29,7 @@ const USAGE = `Usage:
dispatch compact <conversationId> [--server <url>]
dispatch read <conversationId> [--server <url>]
dispatch open <conversationId> [--server <url>]
- dispatch send <conversationId> --text "..." [--queue] [--open] [--cwd <dir>] [--effort <level>] [--workspace <id>] [--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 --help
@@ -156,10 +156,20 @@ async function main(): Promise<void> {
process.stdout.write(`Signaled frontend to open ${conversationId}\n`);
}
+ let fileContent: string | undefined;
+ if (parsed.file) {
+ fileContent = await readFile(parsed.file, "utf-8");
+ }
+ const message = composeMessage({
+ ...(parsed.text !== undefined && { text: parsed.text }),
+ ...(parsed.file !== undefined && { file: parsed.file }),
+ ...(fileContent !== undefined && { fileContent }),
+ });
+
if (parsed.queue) {
const queued = await enqueueMessage(
{ fetchImpl: globalThis.fetch },
- { server: parsed.server, conversationId, text: parsed.text },
+ { server: parsed.server, conversationId, text: message },
);
const line = queued.startedTurn
? `Started turn for ${conversationId}`
@@ -168,7 +178,7 @@ async function main(): Promise<void> {
} else {
const request = {
conversationId,
- message: parsed.text,
+ message,
...(parsed.cwd !== undefined && { cwd: parsed.cwd }),
...(parsed.reasoningEffort !== undefined && { reasoningEffort: parsed.reasoningEffort }),
...(parsed.workspaceId !== undefined && { workspaceId: parsed.workspaceId }),