diff options
Diffstat (limited to 'packages/cli/src/message.ts')
| -rw-r--r-- | packages/cli/src/message.ts | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/packages/cli/src/message.ts b/packages/cli/src/message.ts index ec4d6d1..ddbec6b 100644 --- a/packages/cli/src/message.ts +++ b/packages/cli/src/message.ts @@ -8,52 +8,52 @@ import type { ChatRequest, ReasoningEffort } from "@dispatch/transport-contract"; interface ComposeInput { - readonly text?: string; - readonly file?: string; - readonly fileContent?: string; + readonly text?: string; + readonly file?: string; + readonly fileContent?: string; } function basename(filePath: string): string { - const segments = filePath.split("/"); - return segments[segments.length - 1] ?? filePath; + const segments = filePath.split("/"); + return segments[segments.length - 1] ?? filePath; } export function composeMessage(input: ComposeInput): string { - const { text, fileContent } = input; - const file = input.file; - - if (text && file) { - return `${text}\n\nAttached file (${basename(file)}):\n${fileContent ?? ""}`; - } - if (file) { - return `Attached file (${basename(file)}):\n${fileContent ?? ""}`; - } - return text ?? ""; + const { text, fileContent } = input; + const file = input.file; + + if (text && file) { + return `${text}\n\nAttached file (${basename(file)}):\n${fileContent ?? ""}`; + } + if (file) { + return `Attached file (${basename(file)}):\n${fileContent ?? ""}`; + } + return text ?? ""; } interface ChatCmd { - readonly modelName: string; - readonly text?: string | undefined; - readonly file?: string | undefined; - readonly cwd?: string | undefined; - readonly conversationId?: string | undefined; - readonly reasoningEffort?: ReasoningEffort | undefined; - readonly workspaceId?: string | undefined; - readonly showReasoning: boolean; + readonly modelName: string; + readonly text?: string | undefined; + readonly file?: string | undefined; + readonly cwd?: string | undefined; + readonly conversationId?: string | undefined; + readonly reasoningEffort?: ReasoningEffort | undefined; + readonly workspaceId?: string | undefined; + readonly showReasoning: boolean; } interface BuildCtx { - readonly cwd: string; - readonly message: string; + readonly cwd: string; + readonly message: string; } export function buildChatRequest(cmd: ChatCmd, ctx: BuildCtx): ChatRequest { - return { - message: ctx.message, - model: cmd.modelName, - ...(cmd.conversationId !== undefined && { conversationId: cmd.conversationId }), - ...(cmd.cwd !== undefined ? { cwd: cmd.cwd } : { cwd: ctx.cwd }), - ...(cmd.reasoningEffort !== undefined && { reasoningEffort: cmd.reasoningEffort }), - ...(cmd.workspaceId !== undefined && { workspaceId: cmd.workspaceId }), - }; + return { + message: ctx.message, + model: cmd.modelName, + ...(cmd.conversationId !== undefined && { conversationId: cmd.conversationId }), + ...(cmd.cwd !== undefined ? { cwd: cmd.cwd } : { cwd: ctx.cwd }), + ...(cmd.reasoningEffort !== undefined && { reasoningEffort: cmd.reasoningEffort }), + ...(cmd.workspaceId !== undefined && { workspaceId: cmd.workspaceId }), + }; } |
