From d4b470ca582e3c69c40438895b90748d44fc4653 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Thu, 25 Jun 2026 10:30:41 +0900 Subject: feat(cli): add --file flag to 'dispatch send' subcommand Add the same --file 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. --- packages/cli/src/main.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'packages/cli/src/main.ts') 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 [--server ] dispatch read [--server ] dispatch open [--server ] - dispatch send --text "..." [--queue] [--open] [--cwd ] [--effort ] [--workspace ] [--server ] + dispatch send --text "..." [--file ] [--queue] [--open] [--cwd ] [--effort ] [--workspace ] [--server ] dispatch --text "..." [--file ] [--cwd ] [--conversation ] [--effort ] [--workspace ] [--server ] [--show-reasoning] [--open] dispatch --help @@ -156,10 +156,20 @@ async function main(): Promise { 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 { } 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 }), -- cgit v1.2.3