summaryrefslogtreecommitdiffhomepage
path: root/packages/cli/src/message.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-27 01:12:40 +0900
committerAdam Malczewski <[email protected]>2026-06-27 01:12:40 +0900
commit98b0638838a8e754927d8c030ce8bded18d63e7d (patch)
tree0d4e21c3d4792fcd77e1040373b260e38efa34ce /packages/cli/src/message.ts
parentd92a4af6191d7d20acf861adf605ad0227b6b287 (diff)
parent61e45e60d699ed1ca46f94a8f181c92a940317c6 (diff)
downloaddispatch-98b0638838a8e754927d8c030ce8bded18d63e7d.tar.gz
dispatch-98b0638838a8e754927d8c030ce8bded18d63e7d.zip
Merge branch 'dev' into feature/heartbeat
# Conflicts: # packages/host-bin/package.json # packages/host-bin/src/main.ts # packages/session-orchestrator/src/orchestrator.ts # packages/system-prompt/src/service.test.ts # packages/system-prompt/src/service.ts # packages/system-prompt/src/types.ts # packages/transport-contract/package.json # packages/transport-http/package.json # packages/transport-http/src/app.test.ts # packages/transport-http/src/app.ts # packages/transport-http/src/extension.ts # packages/transport-http/tsconfig.json # tsconfig.json
Diffstat (limited to 'packages/cli/src/message.ts')
-rw-r--r--packages/cli/src/message.ts66
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 }),
+ };
}